Skip to content

Commit

Permalink
Merge pull request #2244 from WikiWatershed/tt/add-wkaoi-to-project-m…
Browse files Browse the repository at this point in the history
…odel

Add WKAoI field to Project Model

Connects #1899
  • Loading branch information
rajadain committed Sep 12, 2017
2 parents 0ff5238 + 2154535 commit 1f96784
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
19 changes: 19 additions & 0 deletions src/mmw/apps/modeling/migrations/0022_project_wkaoi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('modeling', '0021_old_scenarios'),
]

operations = [
migrations.AddField(
model_name='project',
name='wkaoi',
field=models.CharField(help_text='Well-Known Area of Interest ID for faster geoprocessing', max_length=255, null=True),
),
]
4 changes: 4 additions & 0 deletions src/mmw/apps/modeling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class Project(models.Model):
null=True,
help_text='Serialized JSON representation of additional'
' data gathering steps, such as MapShed.')
wkaoi = models.CharField(
null=True,
max_length=255,
help_text='Well-Known Area of Interest ID for faster geoprocessing')

def __unicode__(self):
return self.name
Expand Down
11 changes: 8 additions & 3 deletions src/mmw/js/src/modeling/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ var ModelingController = {

App.map.set({
'areaOfInterest': project.get('area_of_interest'),
'areaOfInterestName': project.get('area_of_interest_name')
'areaOfInterestName': project.get('area_of_interest_name'),
'wellKnownAreaOfInterest': project.get('wkaoi'),
});
initScenarioEvents(project);
initViews(project, lock);
Expand Down Expand Up @@ -168,7 +169,8 @@ var ModelingController = {
.done(function() {
App.map.set({
'areaOfInterest': project.get('area_of_interest'),
'areaOfInterestName': project.get('area_of_interest_name')
'areaOfInterestName': project.get('area_of_interest_name'),
'wellKnownAreaOfInterest': project.get('wkaoi'),
});
if (project.get('scenarios').isEmpty()) {
// No scenarios available. Set the `needs_reset` flag so
Expand Down Expand Up @@ -197,6 +199,7 @@ function itsiResetProject(project) {
'user_id': App.user.get('id'),
'area_of_interest': App.map.get('areaOfInterest'),
'area_of_interest_name': App.map.get('areaOfInterestName'),
'wkaoi': App.map.get('wellKnownAreaOfInterest'),
'needs_reset': false
});

Expand Down Expand Up @@ -276,6 +279,7 @@ function projectCleanUp() {
App.rootView.subHeaderRegion.empty();
App.rootView.sidebarRegion.empty();
App.rootView.compareRegion.empty();
App.clearAnalyzeCollection();
}

function projectErrorState() {
Expand Down Expand Up @@ -347,7 +351,8 @@ function reinstateProject(number, lock) {
.done(function() {
App.map.set({
'areaOfInterest': project.get('area_of_interest'),
'areaOfInterestName': project.get('area_of_interest_name')
'areaOfInterestName': project.get('area_of_interest_name'),
'wellKnownAreaOfInterest': project.get('wkaoi'),
});
setPageTitle();
lock.resolve();
Expand Down
3 changes: 2 additions & 1 deletion src/mmw/js/src/modeling/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ var ProjectMenuView = Marionette.ItemView.extend({
App.projectNumber = undefined;
App.map.set({
'areaOfInterest': null,
'areaOfInterestName': null
'areaOfInterestName': null,
'wellKnownAreaOfInterest': null,
});

router.navigate('projects/', { trigger: true });
Expand Down
6 changes: 4 additions & 2 deletions src/mmw/js/src/projects/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ var ProjectsView = Marionette.LayoutView.extend({
App.projectNumber = undefined;
App.map.set({
'areaOfInterest': null,
'areaOfInterestName': null
'areaOfInterestName': null,
'wellKnownAreaOfInterest': null,
});

router.navigate('', { trigger: true });
Expand Down Expand Up @@ -170,7 +171,8 @@ var ProjectRowView = Marionette.ItemView.extend({
App.clearAnalyzeCollection();
App.map.set({
'areaOfInterest': null,
'areaOfInterestName': ''
'areaOfInterestName': '',
'wellKnownAreaOfInterest': null,
});
router.navigate('/project/' + this.model.id, { trigger: true });
}
Expand Down

0 comments on commit 1f96784

Please sign in to comment.