Skip to content

Commit

Permalink
improve map_thumbnail view
Browse files Browse the repository at this point in the history
  • Loading branch information
hisham waleed karam committed Jan 30, 2019
1 parent 9ca3957 commit e03d14b
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions geonode/maps/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
from django.shortcuts import render, get_object_or_404
from django.conf import settings
from django.utils.translation import ugettext as _
from django.views.decorators.http import require_http_methods

try:
# Django >= 1.7
import json
Expand Down Expand Up @@ -1357,30 +1359,29 @@ def ajax_url_lookup(request):
content_type='text/plain'
)


@require_http_methods(["POST",])
def map_thumbnail(request, mapid):
if request.method == 'POST':
map_obj = _resolve_map(request, mapid)
map_obj = _resolve_map(request, mapid)
try:
image = None
try:
image = None
try:
image = _prepare_thumbnail_body_from_opts(request.body,
request=request)
except BaseException:
image = _render_thumbnail(request.body)
image = _prepare_thumbnail_body_from_opts(request.body,
request=request)
except BaseException:
image = _render_thumbnail(request.body)

if not image:
return
filename = "map-%s-thumb.png" % map_obj.uuid
map_obj.save_thumbnail(filename, image)
if not image:
return
filename = "map-%s-thumb.png" % map_obj.uuid
map_obj.save_thumbnail(filename, image)

return HttpResponse(_('Thumbnail saved'))
except BaseException:
return HttpResponse(
content=_('error saving thumbnail'),
status=500,
content_type='text/plain'
)
return HttpResponse(_('Thumbnail saved'))
except BaseException:
return HttpResponse(
content=_('error saving thumbnail'),
status=500,
content_type='text/plain'
)


def map_metadata_detail(
Expand Down

0 comments on commit e03d14b

Please sign in to comment.