Skip to content

Commit

Permalink
Adds a status message when updating the gazetteer fields for a layer
Browse files Browse the repository at this point in the history
  • Loading branch information
capooti committed Apr 5, 2018
1 parent 6291906 commit 2617553
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,18 @@ <h2 class="page-title">{{ layer.title }}</h2>

{{ block.super }}
{% endblock body_outer %}

{% block extra_script %}
{{ block.super }}

<script type="text/javascript">
jQuery(document).ready(function(){
{% if status_message %}
$('#status-message-text').text('The following fields of this layer are now part of the gazetteer:');
$('#status-message-text-body').text("{{ status_message }}");
$('#status-message').addClass('alert-success').show();
{% endif %}
});
</script>

{% endblock extra_script %}
6 changes: 5 additions & 1 deletion geonode/contrib/worldmap/gazetteer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def set_none_if_empty(str):
'base.change_resourcebase_metadata',
'permissions message from grazetteer')

if request.method == "POST":
status_message = None
if request.method == 'POST':
status_message = ''
gazetteer_name = set_none_if_empty(request.POST.get('gazetteer-name', ''))
start_attribute = set_none_if_empty(request.POST.get('start-attribute', ''))
end_attribute = set_none_if_empty(request.POST.get('end-attribute', ''))
Expand All @@ -79,6 +81,7 @@ def set_none_if_empty(str):
gaz_att.is_end_date = True
gaz_att.date_format = sel_end_date_format
gaz_att.save()
status_message += ' %s' % attribute.attribute
else:
print 'Removing %s from gazetteer...' % attribute
gaz_att, created = GazetteerAttribute.objects.get_or_create(attribute=attribute)
Expand Down Expand Up @@ -106,4 +109,5 @@ def set_none_if_empty(str):
return render_to_response(template, RequestContext(request, {
"layer": layer,
"gazetteer_attributes": gazetteer_attributes,
"status_message": status_message,
}))
4 changes: 2 additions & 2 deletions geonode/contrib/worldmap/wm_extra/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,9 +1003,9 @@ def layer_searchable_fields(
'permissions message from searchable layers')

status_message = None
if request.method == "POST":
if request.method == 'POST':
attributes_list = request.POST.getlist('attributes')
status_message = ""
status_message = ''
for attribute in layer.attributes:
ext_att, created = ExtLayerAttribute.objects.get_or_create(attribute=attribute)
if attribute.attribute in attributes_list:
Expand Down

0 comments on commit 2617553

Please sign in to comment.