예제 #1
0
def delete_page(request, title, *args, **kw):
    """docstring for delete_page"""
    page = get_object_or_404(Article, title=title)
    if not check_permission(request.user, page.group, "wiki", "d"):
        raise PermissionDenied()

    if request.POST:
        if request.POST["result"] == _("Cancel"):
            return HttpResponseRedirect(page.get_absolute_url())
        else:
            form = ConfirmForm(request.POST)
            if form.is_valid():
                page.delete()
                return HttpResponseRedirect(reverse("group", kwargs={"group_slug": page.group.slug}))
    else:
        form = ConfirmForm(initial={"resource_name": page.title})

    return render_to_response(
        "ct_framework/confirm.html", RequestContext(request, {"form": form, "title": _("Delete this page?")})
    )
예제 #2
0
def template_fileresource_delete(request, object_id, next=None):
    obj = get_object_or_404(FileResource, pk=object_id)
    next = next or '%s?tView=files' % reverse('template-detail',kwargs={'object_id':obj.attached_to.id})
    if not check_permission(request.user, obj.attached_to.workgroup, 'resource', 'd'):
        raise PermissionDenied()
    if request.POST:
        if request.POST['result'] == _('Cancel'):
            return HttpResponseRedirect(next)
        else:
            form = ConfirmForm(request.POST)
            if form.is_valid():
                obj.delete()
                return HttpResponseRedirect(next)
    else:
        form = ConfirmForm(initial={ 'resource_name': obj.name })
    return render_to_response('ct_framework/confirm.html', 
        RequestContext( request, 
            {   'form': form,
                'title': _('Delete this file?')
            })
        )
예제 #3
0
def remove_member(request, group_slug, object_id):
    """docstring for remove_member"""

    memb = get_object_or_404(GroupMembership, pk=object_id, group__slug=group_slug)
    if not check_permission(request.user, memb.group, "group", "w"):
        raise PermissionDenied()

    if request.POST:
        if request.POST["result"] == _("Cancel"):
            pass
            # messages.warning(request, _('Cancelled'))
        else:
            form = ConfirmForm(request.POST)
            if form.is_valid():
                memb.remove()
                messages.success(request, _("Group member removed."))
        return HttpResponseRedirect("%s#membership" % reverse("group-edit", kwargs={"group_slug": memb.group.slug}))
    else:
        form = ConfirmForm(initial={"resource_name": "%s (%s)" % (memb.user.get_full_name(), memb.user.username)})

    return render_to_response(
        "ct_framework/confirm.html",
        RequestContext(request, {"form": form, "title": _("Remove member from this group?")}),
    )