コード例 #1
0
ファイル: views.py プロジェクト: davicustodio/geonode
def layer_remove(request, layername, template='layers/layer_remove.html'):
    layer = _resolve_layer(
        request,
        layername,
        'base.delete_resourcebase',
        _PERMISSION_MSG_DELETE)

    if (request.method == 'GET'):
        return render_to_response(template, RequestContext(request, {
            "layer": layer
        }))
    if (request.method == 'POST'):
        try:
            delete_layer.delay(object_id=layer.id)
        except Exception as e:
            message = '{0}: {1}.'.format(_('Unable to delete layer'), layer.typename)

            if 'referenced by layer group' in getattr(e, 'message', ''):
                message = _('This layer is a member of a layer group, you must remove the layer from the group '
                            'before deleting.')

            messages.error(request, message)
            return render_to_response(template, RequestContext(request, {"layer": layer}))
        return HttpResponseRedirect(reverse("layer_browse"))
    else:
        return HttpResponse("Not allowed", status=403)
コード例 #2
0
ファイル: views.py プロジェクト: ianedwardthomas/geonode
def layer_remove(request, layername, template='layers/layer_remove.html'):
    layer = _resolve_layer(
        request,
        layername,
        'base.delete_resourcebase',
        _PERMISSION_MSG_DELETE)

    if (request.method == 'GET'):
        return render_to_response(template, RequestContext(request, {
            "layer": layer
        }))
    if (request.method == 'POST'):
        try:
            with transaction.atomic():
                delete_layer.delay(object_id=layer.id)
        except Exception as e:
            traceback.print_exc()
            message = '{0}: {1}.'.format(_('Unable to delete layer'), layer.typename)

            if 'referenced by layer group' in getattr(e, 'message', ''):
                message = _('This layer is a member of a layer group, you must remove the layer from the group '
                            'before deleting.')

            messages.error(request, message)
            return render_to_response(template, RequestContext(request, {"layer": layer}))
        return HttpResponseRedirect(reverse("layer_browse"))
    else:
        return HttpResponse("Not allowed", status=403)
コード例 #3
0
ファイル: views.py プロジェクト: GeoDash/geodash
def layer_remove(request, layername, template='layers/layer_remove.html'):
    layer = _resolve_layer(
        request,
        layername,
        'base.delete_resourcebase',
        _PERMISSION_MSG_DELETE)

    if (request.method == 'GET'):
        return render_to_response(template, RequestContext(request, {
            "layer": layer
        }))
    if (request.method == 'POST'):
        try:
            with transaction.atomic():
                delete_layer.delay(object_id=layer.id)

                # notify layer owner that someone have deleted the layer
                if request.user != layer.owner:
                    recipient = layer.owner
                    notify.send(request.user, recipient=recipient, actor=request.user,
                    target=layer, verb='deleted your layer')
        except Exception as e:
            message = '{0}: {1}.'.format(_('Unable to delete layer'), layer.typename)

            if 'referenced by layer group' in getattr(e, 'message', ''):
                message = _('This layer is a member of a layer group, you must remove the layer from the group '
                            'before deleting.')

            messages.error(request, message)
            return render_to_response(template, RequestContext(request, {"layer": layer}))
        return HttpResponseRedirect(reverse("layer_browse"))
    else:
        return HttpResponse("Not allowed", status=403)
コード例 #4
0
def layer_remove(request, layername, template='layers/layer_remove.html'):
    layer = _resolve_layer(request, layername, 'base.delete_resourcebase',
                           _PERMISSION_MSG_DELETE)

    if (request.method == 'GET'):
        return render_to_response(template,
                                  RequestContext(request, {"layer": layer}))
    if (request.method == 'POST'):
        delete_layer.delay(object_id=layer.id)
        return HttpResponseRedirect(reverse("layer_browse"))
    else:
        return HttpResponse("Not allowed", status=403)
コード例 #5
0
ファイル: views.py プロジェクト: darndtrvr/geonode
def layer_remove(request, layername, template="layers/layer_remove.html"):
    layer = _resolve_layer(request, layername, "base.delete_resourcebase", _PERMISSION_MSG_DELETE)

    if request.method == "GET":
        return render_to_response(template, RequestContext(request, {"layer": layer}))
    if request.method == "POST":
        try:
            delete_layer.delay(object_id=layer.id)
        except Exception as e:
            message = "{0}: {1}.".format(_("Unable to delete layer"), layer.typename)

            if "referenced by layer group" in getattr(e, "message", ""):
                message = _(
                    "This layer is a member of a layer group, you must remove the layer from the group "
                    "before deleting."
                )

            messages.error(request, message)
            return render_to_response(template, RequestContext(request, {"layer": layer}))
        return HttpResponseRedirect(reverse("layer_browse"))
    else:
        return HttpResponse("Not allowed", status=403)
コード例 #6
0
# in shp_path set a path containing *.shp files
doc_path = '/tmp/docs/'
shp_path = '/tmp/shp/'
n_users = 50
n_keywords = 100
n_layers = 500
n_docs = 500

# Reset keywords
Tag.objects.all().delete()

# 1. create users
Profile.objects.exclude(username='******').exclude(
    username='******').delete()
create_users(n_users)

# 2. create documents
Document.objects.all().delete()
for d in range(0, n_docs):
    t = Timer(lambda: create_document(d))
    print 'Document %s generated in: %s' % (d, t.timeit(number=1))

# 3. create layers
# first we delete layers
for layer in Layer.objects.all():
    delete_layer.delay(object_id=layer.id)

for l in range(0, n_layers):
    t = Timer(lambda: create_layer(l))
    print 'Layer %s generated in: %s' % (l, t.timeit(number=1))
コード例 #7
0
# in shp_path set a path containing *.shp files
doc_path = '/tmp/docs/'
shp_path = '/tmp/shp/'
n_users = 50
n_keywords = 100
n_layers = 500
n_docs = 500

# Reset keywords
Tag.objects.all().delete()

# 1. create users
Profile.objects.exclude(username='******').exclude(username='******').delete()
create_users(n_users)

# 2. create documents
Document.objects.all().delete()
for d in range(0, n_docs):
    t = Timer(lambda: create_document(d))
    print 'Document %s generated in: %s' % (d, t.timeit(number=1))

# 3. create layers
# first we delete layers
for layer in Layer.objects.all():
    delete_layer.delay(object_id=layer.id)

for l in range(0, n_layers):
    t = Timer(lambda: create_layer(l))
    print 'Layer %s generated in: %s' % (l, t.timeit(number=1))