Skip to content

Commit

Permalink
- Allow pluggable GIS client to hook their custom Style Edit Page
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Nov 9, 2018
1 parent 62601dd commit 8f1f4cb
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
12 changes: 12 additions & 0 deletions geonode/client/hooksets.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def layer_embed_template(self, context=None):
def layer_download_template(self, context=None):
return 'geoext/layers/layer_geoext_map.html'

def layer_style_edit_template(self, context=None):
return 'geoext/layers/layer_geoext_map.html'

# Maps
def map_detail_template(self, context=None):
return 'geoext/maps/map_include.html'
Expand Down Expand Up @@ -108,6 +111,9 @@ def layer_embed_template(self, context=None):
def layer_download_template(self, context=None):
return 'leaflet/layers/layer_leaflet_map.html'

def layer_style_edit_template(self, context=None):
return 'leaflet/layers/layer_leaflet_map.html'

# Maps
def map_detail_template(self, context=None):
return 'leaflet/maps/map_view.html'
Expand Down Expand Up @@ -155,6 +161,9 @@ def layer_embed_template(self, context=None):
def layer_download_template(self, context=None):
return 'geonode-client/layer_map.html'

def layer_style_edit_template(self, context=None):
return 'geonode-client/layer_map.html'

# Maps
def map_detail_template(self, context=None):
return 'geonode-client/map_detail.html'
Expand Down Expand Up @@ -224,6 +233,9 @@ def layer_embed_template(self, context=None):
def layer_download_template(self, context=None):
return 'geoext/layers/layer_geoext_map.html'

def layer_style_edit_template(self, context=None):
return 'worldmap/layers/layer_worldmap_map.html'

# Maps
def map_detail_template(self, context=None):
return 'worldmap/maps/map_include.html'
Expand Down
5 changes: 5 additions & 0 deletions geonode/client/templatetags/client_lib_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def render(self, context):
t = context.template.engine.get_template(
hookset.layer_download_template(
context=context))
elif self.tag_name == 'get_layer_style_edit':
t = context.template.engine.get_template(
hookset.layer_style_edit_template(
context=context))

# MAPS
if self.tag_name == 'get_map_detail':
Expand Down Expand Up @@ -148,6 +152,7 @@ def do_get_client_library_template(parser, token):
register.tag('get_layer_update', do_get_client_library_template)
register.tag('get_layer_embed', do_get_client_library_template)
register.tag('get_layer_download', do_get_client_library_template)
register.tag('get_layer_style_edit', do_get_client_library_template)

register.tag('get_map_detail', do_get_client_library_template)
register.tag('get_map_new', do_get_client_library_template)
Expand Down
7 changes: 5 additions & 2 deletions geonode/layers/templates/layers/layer_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
{% block title %}{{ resource.title|default:resource.alternate }} — {{ block.super }}{% endblock %}

{% block head %}

{% if TWITTER_CARD %}
{% include "base/_resourcebase_twittercard.html" %}
{% endif %}
Expand Down Expand Up @@ -461,7 +460,11 @@ <h4>{% trans "Metadata" %}</h4>
<div class="col-sm-3">
<i class="fa fa-tint fa-3x"></i>
<h4>{% trans "Styles" %}</h4>
<a class="btn btn-default btn-block btn-xs style-edit" data-dismiss="modal" href="#">{% trans "Edit" %}</a>
{% if preview == 'geoext' or preview == 'react' or preview == 'leaflet' or preview == 'maploom' %}
<a class="btn btn-default btn-block btn-xs style-edit" data-dismiss="modal" href="#">{% trans "Edit" %}</a>
{% else %}
<a class="btn btn-default btn-block btn-xs style-edit" href="{% url "layer_sld_edit" resource.service_typename %}">{% trans "Edit" %}</a>
{% endif %}
{% if resource.storeType != "remoteStore" %}
<a class="btn btn-default btn-block btn-xs" href="{% url "layer_sld_upload" resource.service_typename %}">{% trans "Upload" %}</a>
<a class="btn btn-default btn-block btn-xs" href="{% url "layer_style_manage" resource.service_typename %}">{% trans "Manage" %}</a>
Expand Down
27 changes: 27 additions & 0 deletions geonode/layers/templates/layers/layer_style_edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "layers/layer_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load dialogos_tags %}
{% load agon_ratings_tags %}
{% load bootstrap_tags %}
{% load pagination_tags %}
{% load base_tags %}
{% load guardian_tags %}
{% load client_lib_tags %}

{% block title %}{{ resource.title|default:resource.alternate }} — {{ block.super }}{% endblock %}

{% block head %}
{% if TWITTER_CARD %}
{% include "base/_resourcebase_twittercard.html" %}
{% endif %}

{% if OPENGRAPH_ENABLED %}
{% include "base/_resourcebase_opengraph.html" %}
{% endif %}

{% get_layer_style_edit %}
{{ block.super }}
{% endblock %}

{% block body_class %}layers{% endblock %}
2 changes: 2 additions & 0 deletions geonode/layers/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
views.layer_metadata_upload, name='layer_metadata_upload'),
url(r'^(?P<layername>[^/]*)/style_upload$',
views.layer_sld_upload, name='layer_sld_upload'),
url(r'^(?P<layername>[^/]*)/style_edit$',
views.layer_sld_edit, name='layer_sld_edit'),
url(r'^(?P<layername>[^/]*)/feature_catalogue$',
views.layer_feature_catalogue, name='layer_feature_catalogue'),
url(r'^metadata/batch/(?P<ids>[^/]*)/$',
Expand Down
7 changes: 7 additions & 0 deletions geonode/layers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,13 @@ def layer_sld_upload(
})


def layer_sld_edit(
request,
layername,
template='layers/layer_style_edit.html'):
return layer_detail(request, layername, template)


@login_required
def layer_batch_metadata(request, ids):
return batch_modify(request, ids, 'Layer')
Expand Down

0 comments on commit 8f1f4cb

Please sign in to comment.