Skip to content

Commit 9209fb6

Browse files
authored
Merge pull request #363 from preranaandure/master
Add new field prefill requested.
2 parents ddddbbf + e779eab commit 9209fb6

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

disturbance/components/proposals/models.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ class Proposal(DirtyFieldsMixin, RevisionedMixin):
549549
migrated = models.BooleanField(default=False)
550550
shapefile_json = JSONField('Source/Submitter (multi) polygon geometry', blank=True, null=True)
551551
shapefile_geom = MultiPolygonField('Source/Submitter gdf.exploded (multi) polygon geometry', srid=4326, blank=True, null=True) # for 'pgsql2shp' from KB
552-
reissued = models.BooleanField(default=False)
552+
reissued = models.BooleanField(default=False)
553+
prefill_requested = models.BooleanField(default=False)
553554

554555
class Meta:
555556
app_label = 'disturbance'
@@ -1574,6 +1575,7 @@ def validate_map_files(self, request):
15741575
if 'id' in shapefile_json['features'][0]:
15751576
shapefile_json['features'][0]['id']=self.id
15761577
self.shapefile_json=shapefile_json
1578+
self.prefill_requested=False
15771579
else:
15781580
msg = 'no features found in shapefile' if num_features == 0 else f'too many features: {num_features} (max {MAX_NO_POLYGONS})'
15791581
raise ValidationError(f'Cannot upload a Shapefile - {msg}')

disturbance/components/proposals/serializers.py

+2
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ class Meta:
296296
'history_add_info_assessor',
297297
'refresh_timestamp',
298298
'prefill_timestamp',
299+
'prefill_requested',
299300
'layer_data',
300301
'region_name',
301302
'district_name',
@@ -474,6 +475,7 @@ class Meta:
474475
'history_add_info_assessor',
475476
'refresh_timestamp',
476477
'prefill_timestamp',
478+
'prefill_requested',
477479
'latest_referrals',
478480
'allowed_assessors',
479481
'proposed_issuance_approval',

disturbance/components/proposals/sqs_utils/api.py

+1
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ def prefill_proposal(self, request, *args, **kwargs):
617617
start_time = time.time()
618618

619619
proposal = instance
620+
proposal.prefill_requested=True
620621
# current_ts = request.data.get('current_ts') # format required '%Y-%m-%dT%H:%M:%S'
621622
if proposal.prefill_timestamp:
622623
current_ts= proposal.prefill_timestamp.strftime('%Y-%m-%dT%H:%M:%S')

disturbance/frontend/disturbance/src/components/external/proposal_external.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,8 @@ export default {
899899
let vm=this;
900900
let blank_fields = []
901901
if(vm.proposal.application_type == 'Disturbance'){
902-
if(vm.proposal && vm.$refs.mapSection.$refs.map_doc.documents.length == 0 || vm.proposal.shapefile_json==null){
903-
blank_fields.push(' You must upload and validate the shapefile');
902+
if(vm.proposal && vm.$refs.mapSection.$refs.map_doc.documents.length == 0 || vm.proposal.shapefile_json==null || vm.proposal.prefill_requested == false){
903+
blank_fields.push(' You must upload and validate the shapefile. Please Prefill the Proposal after validating the shapefile.');
904904
}
905905
}
906906
if(blank_fields.length==0){
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.29 on 2025-01-13 02:22
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('disturbance', '0298_auto_20241021_1132'),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='proposal',
17+
name='prefill_requested',
18+
field=models.BooleanField(default=False),
19+
),
20+
migrations.AlterField(
21+
model_name='activitymatrix',
22+
name='name',
23+
field=models.CharField(choices=[('Disturbance', 'Disturbance'), ('Ecological Thinning', 'Ecological Thinning')], default='Disturbance', max_length=24, verbose_name='Activity matrix name'),
24+
),
25+
]

0 commit comments

Comments
 (0)