Esempio n. 1
0
def map_thumbnail(request, mapid):
    map_obj = _resolve_map(request, mapid)
    try:
        image = None
        try:
            image = _prepare_thumbnail_body_from_opts(
                request.body, request=request)
        except BaseException:
            image = _render_thumbnail(request.body)

        if not image:
            return HttpResponse(
                content=_('couldn\'t generate thumbnail'),
                status=500,
                content_type='text/plain'
            )
        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'
        )
Esempio n. 2
0
def layer_thumbnail(request, layername):
    if request.method == 'POST':
        layer_obj = _resolve_layer(request, layername)

        try:
            try:
                preview = json.loads(request.body).get('preview', None)
            except:
                preview = None

            if preview and preview == 'react':
                format, image = json.loads(
                    request.body)['image'].split(';base64,')
                image = base64.b64decode(image)
            else:
                image = _render_thumbnail(request.body)

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

            return HttpResponse('Thumbnail saved')
        except BaseException:
            return HttpResponse(
                content='error saving thumbnail',
                status=500,
                content_type='text/plain'
            )
Esempio n. 3
0
def layer_thumbnail(request, layername):
    if request.method == "POST":
        layer_obj = _resolve_layer(request, layername)
        try:
            image = _render_thumbnail(request.body)

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

            return HttpResponse("Thumbnail saved")
        except:
            return HttpResponse(content="error saving thumbnail", status=500, mimetype="text/plain")
Esempio n. 4
0
def map_thumbnail(request, mapid):
    if request.method == 'POST':
        map_obj = _resolve_map(request, mapid)
        try:
            image = _render_thumbnail(request.body)

            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')
Esempio n. 5
0
def layer_thumbnail(request, layername):
    if request.method == 'POST':
        layer_obj = _resolve_layer(request, layername)
        try:
            image = _render_thumbnail(request.body)

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

            return HttpResponse('Thumbnail saved')
        except:
            return HttpResponse(content='error saving thumbnail',
                                status=500,
                                mimetype='text/plain')
Esempio n. 6
0
def map_thumbnail(request, mapid):
    if request.method == 'POST':
        map_obj = _resolve_map(request, mapid)
        try:
            image = _render_thumbnail(request.body)

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

            return HttpResponse('Thumbnail saved')
        except:
            return HttpResponse(
                content='error saving thumbnail',
                status=500,
                content_type='text/plain'
            )
Esempio n. 7
0
def layer_thumbnail(request, layername):
    if request.method == 'POST':
        layer_obj = _resolve_layer(request, layername)
        try:
            image = _render_thumbnail(request.body)

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

            return HttpResponse('Thumbnail saved')
        except:
            return HttpResponse(
                content='error saving thumbnail',
                status=500,
                content_type='text/plain'
            )
Esempio n. 8
0
def map_thumbnail(request, mapid):
    map_obj = _resolve_map(request, mapid)
    try:
        image = None
        try:
            image = _prepare_thumbnail_body_from_opts(request.body,
                                                      request=request)
        except Exception:
            image = _render_thumbnail(request.body)

        if not image:
            return HttpResponse(content=_('couldn\'t generate thumbnail'),
                                status=500,
                                content_type='text/plain')
        filename = "map-%s-thumb.png" % map_obj.uuid
        map_obj.save_thumbnail(filename, image)

        return HttpResponse(_('Thumbnail saved'))
    except Exception:
        return HttpResponse(content=_('error saving thumbnail'),
                            status=500,
                            content_type='text/plain')
Esempio n. 9
0
def layer_thumbnail(request, layername):
    if request.method == 'POST':
        layer_obj = _resolve_layer(request, layername)
        try:
            preview = json.loads(request.body).get('preview', None)
            if preview and preview == 'react':
                format, image = json.loads(
                    request.body)['image'].split(';base64,')
                image = base64.b64decode(image)
            else:
                image = _render_thumbnail(request.body)

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

            return HttpResponse('Thumbnail saved')
        except:
            return HttpResponse(content='error saving thumbnail',
                                status=500,
                                content_type='text/plain')
Esempio n. 10
0
def map_thumbnail(request, mapid):
    if request.method == 'POST':
        map_obj = _resolve_map(request, mapid)
        try:
            # Base64 PNG data uploaded from the client!
            if(request.body[0:22] == 'data:image/png;base64,'):
                image = b64decode(request.body[22:])
            # try the old way.
            else:
                image = _render_thumbnail(request.body)

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

            return HttpResponse('Thumbnail saved')
        except:
            return HttpResponse(
                content='error saving thumbnail',
                status=500,
                content_type='text/plain'
            )
Esempio n. 11
0
def layer_thumbnail(request, layername):
    layer_obj = _resolve_layer(request, layername)
    if request.method == 'POST':

        try:
            # Base64 PNG data uploaded from the client!
            if(request.body[0:22] == 'data:image/png;base64,'):
                image = b64decode(request.body[22:])
            # try the old way.
            else:
                image = _render_thumbnail(request.body)

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

            return HttpResponse('Thumbnail saved')
        except:
            return HttpResponse(
                content='error saving thumbnail',
                status=500,
                content_type='text/plain'
            )
    else:
        if(layer_obj.has_thumbnail()):
            #layer_obj.get_thumbnail_url()

            return HttpResponse(
                content=layer_obj.get_thumbnail_url(),
                content_type='text/plain'
            )
        else:
            return HttpResponse(
                content='No Thumbnail',
                content_type='text/plain'
            )