Exemplo n.º 1
0
def key_list(request, secret=True):
    check_permissions(request.user, [PERMISSION_KEY_VIEW])

    if secret:
        object_list = Key.get_all(gpg, secret=True)
        title = _(u'private keys')
    else:
        object_list = Key.get_all(gpg)
        title = _(u'public keys')

    return render_to_response('generic_list.html', {
        'object_list':
        object_list,
        'title':
        title,
        'hide_object':
        True,
        'extra_columns': [
            {
                'name': _(u'Key ID'),
                'attribute': 'key_id',
            },
            {
                'name': _(u'Owner'),
                'attribute': encapsulate(lambda x: u', '.join(x.uids)),
            },
        ]
    },
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def key_list(request, secret=True):
    check_permissions(request.user, [PERMISSION_KEY_VIEW])
    
    if secret:
        object_list = Key.get_all(gpg, secret=True)
        title = _(u'private keys')
    else:
        object_list = Key.get_all(gpg)
        title = _(u'public keys')

    return render_to_response('generic_list.html', {
        'object_list': object_list,
        'title': title,
        'hide_object': True,
        'extra_columns': [
            {
                'name': _(u'Key ID'),
                'attribute': 'key_id',
            },
            {
                'name': _(u'Owner'),
                'attribute': encapsulate(lambda x: u', '.join(x.uids)),
            },
        ]
    }, context_instance=RequestContext(request))
Exemplo n.º 3
0
def key_delete(request, fingerprint, key_type):
    check_permissions(request.user, [PERMISSION_KEY_DELETE])

    secret = key_type == 'sec'
    key = Key.get(gpg, fingerprint, secret=secret)

    post_action_redirect = None
    previous = request.POST.get(
        'previous',
        request.GET.get('previous', request.META.get('HTTP_REFERER', '/')))
    next = request.POST.get(
        'next',
        request.GET.get(
            'next',
            post_action_redirect if post_action_redirect else request.META.get(
                'HTTP_REFERER', '/')))

    if request.method == 'POST':
        try:
            gpg.delete_key(key)
            messages.success(
                request,
                _(u'Key: %s, deleted successfully.') % fingerprint)
            return HttpResponseRedirect(next)
        except Exception, msg:
            messages.error(request, msg)
            return HttpResponseRedirect(previous)
Exemplo n.º 4
0
def key_delete(request, fingerprint, key_type):
    check_permissions(request.user, [PERMISSION_KEY_DELETE])
    
    secret = key_type == 'sec'
    key = Key.get(gpg, fingerprint, secret=secret)

    post_action_redirect = None
    previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', '/')))
    next = request.POST.get('next', request.GET.get('next', post_action_redirect if post_action_redirect else request.META.get('HTTP_REFERER', '/')))

    if request.method == 'POST':
        try:
            gpg.delete_key(key)
            messages.success(request, _(u'Key: %s, deleted successfully.') % fingerprint)
            return HttpResponseRedirect(next)
        except Exception, msg:
            messages.error(request, msg)
            return HttpResponseRedirect(previous)