Skip to content

Commit

Permalink
Merge branch '3.3.x' into dashboard_33x
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Fabiani authored Jul 29, 2021
2 parents 459652b + f1ff696 commit d912ca2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
20 changes: 11 additions & 9 deletions geonode/maps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,16 +586,18 @@ def get_legend(self):
capability = layer_params.get('capability', {})
# Use '' to represent default layer style
style_name = capability.get('style', '')
href = None
layer_obj = Layer.objects.filter(alternate=self.name).first()
if ':' in style_name:
style_name = style_name.split(':')[1]
elif layer_obj.default_style:
style_name = layer_obj.default_style.name
href = layer_obj.get_legend_url(style_name=style_name)
style = Style.objects.filter(name=style_name).first()
if style:
# replace map-legend display name if style has a title
style_name = style.sld_title or style_name
if layer_obj:
if ':' in style_name:
style_name = style_name.split(':')[1]
elif layer_obj.default_style:
style_name = layer_obj.default_style.name
href = layer_obj.get_legend_url(style_name=style_name)
style = Style.objects.filter(name=style_name).first()
if style:
# replace map-legend display name if style has a title
style_name = style.sld_title or style_name
return {style_name: href}
except Exception as e:
logger.exception(e)
Expand Down
7 changes: 6 additions & 1 deletion geonode/proxy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
from geonode import geoserver # noqa
from geonode.monitoring import register_event

TIMEOUT = 300
TIMEOUT = 30

LINK_TYPES = [L for L in _LT if L.startswith("OGC:")]

Expand Down Expand Up @@ -188,6 +188,11 @@ def proxy(request, url=None, response_callback=None,
headers=headers,
timeout=timeout,
user=request.user)
if response is None:
return HttpResponse(
content=content,
reason=content,
status=500)
content = response.content or response.reason
status = response.status_code
content_type = response.headers.get('Content-Type')
Expand Down
10 changes: 6 additions & 4 deletions geonode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,13 +1473,15 @@ def request(self, url, method='GET', data=None, headers={}, stream=False,
msg = f"Request exception [{e}] - TOUT [{_req_tout}] to URL: {url} - headers: {headers}"
logger.exception(Exception(msg))
response = None
content = str(e)
else:
response = session.get(url, headers=headers, timeout=self.timeout)

try:
content = ensure_string(response.content) if not stream else response.raw
except Exception:
content = None
if response:
try:
content = ensure_string(response.content) if not stream else response.raw
except Exception as e:
content = str(e)

return (response, content)

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ pinax-notifications==6.0.0
pinax-ratings==4.0.0

# GeoNode org maintained apps.
-e git+https://github.com/allyoucanmap/geonode-mapstore-client.git@annotations-base-app-3.3.x#egg=django_geonode_mapstore_client
# django-geonode-mapstore-client>=3.3.0,<4.0.0
-e git+https://github.com/GeoNode/geonode-mapstore-client.git@3.3.x#egg=django_geonode_mapstore_client
geonode-avatar==5.0.7
geonode-oauth-toolkit==2.2.1
geonode-user-messages==2.0.2
Expand Down

0 comments on commit d912ca2

Please sign in to comment.