Skip to content

Commit

Permalink
UI fixes:
Browse files Browse the repository at this point in the history
related with:
GeoNode#54 GeoNode#53
  • Loading branch information
lucernae committed May 16, 2016
1 parent 0e000ed commit 706907f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 41 deletions.
12 changes: 12 additions & 0 deletions geosafe/templates/geosafe/analysis/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,18 @@
'<span class="alert-danger">No usable layer in current extent</span>',
'alert-danger');
}
else if(exp_count == 0){
show_info_text(
'<span class="text-danger">Extent Changed</span>',
'<span class="alert-danger">No usable exposure layer in current extent</span>',
'alert-danger');
}
else if(haz_count == 0){
show_info_text(
'<span class="text-danger">Extent Changed</span>',
'<span class="alert-danger">No usable hazard layer in current extent</span>',
'alert-danger');
}
}

function filter_layer(bounds){
Expand Down
56 changes: 15 additions & 41 deletions geosafe/views/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ class AnalysisCreateView(CreateView):
template_name = 'geosafe/analysis/create.html'
context_object_name = 'analysis'

def get_context_data(self, **kwargs):
@classmethod
def options_panel_dict(cls, bbox=None):
"""Prepare a dictionary to be used in the template view
:return: dict containing metadata for options panel
:rtype: dict
"""
purposes = [
{
'name': 'exposure',
Expand All @@ -77,11 +83,11 @@ def get_context_data(self, **kwargs):
]
}
]
sections = [];
sections = []
for p in purposes:
categories = []
for idx, c in enumerate(p.get('categories')):
layers = retrieve_layers(p.get('name'), c)
layers = retrieve_layers(p.get('name'), c, bbox=bbox)
category = {
'name': c,
'layers': layers,
Expand All @@ -94,7 +100,7 @@ def get_context_data(self, **kwargs):
}
sections.append(section)

impact_layers = retrieve_layers('impact')
impact_layers = retrieve_layers('impact', bbox=bbox)
sections.append({
'name': 'impact',
'categories': [
Expand All @@ -104,6 +110,10 @@ def get_context_data(self, **kwargs):
}
]
})
return sections

def get_context_data(self, **kwargs):
sections = self.options_panel_dict()
try:
analysis = Analysis.objects.get(id=self.kwargs.get('pk'))
except:
Expand Down Expand Up @@ -317,43 +327,7 @@ def layer_panel(request, bbox=None):
return HttpResponseBadRequest()

try:

purposes = [
{
'name': 'exposure',
'categories': ['population', 'road', 'structure'],
},
{
'name': 'hazard',
'categories': ['flood', 'earthquake', 'volcano'],
}
]
sections = [];
for p in purposes:
categories = []
for c in p.get('categories'):
layers = retrieve_layers(p.get('name'), c, bbox)
category = {
'name': c,
'layers': layers
}
categories.append(category)
section = {
'name': p.get('name'),
'categories': categories
}
sections.append(section)

impact_layers = retrieve_layers('impact', bbox=bbox)
sections.append({
'name': 'impact',
'categories': [
{
'name': 'impact',
'layers': impact_layers
}
]
})
sections = AnalysisCreateView.options_panel_dict(bbox=bbox)
form = AnalysisCreationForm(
user=request.user,
exposure_layer=retrieve_layers('exposure', bbox=bbox),
Expand Down

0 comments on commit 706907f

Please sign in to comment.