Beispiel #1
0
def add_acl(request):
    "add an acl"
    if request.method == 'POST':
        form = ACLForm(request.POST)
        if form.is_valid():
            try:
                form.save()
                msg = _('The ACL rule was created successfully')
                messages.info(request, msg)
                return HttpResponseRedirect(reverse('acl-rules'))
            except DatabaseError, e:
                print e
                msg = _('The ACL rule could not be created')
                messages.info(request, msg)
                return HttpResponseRedirect(reverse('acl-rules'))
Beispiel #2
0
def add_acl(request):
    "add an acl"
    if request.method == "POST":
        form = ACLForm(request.POST)
        if form.is_valid():
            try:
                form.save()
                msg = _("The ACL rule was created successfully")
                messages.info(request, msg)
                return HttpResponseRedirect(reverse("acl-rules"))
            except DatabaseError, e:
                print e
                msg = _("The ACL rule could not be created")
                messages.info(request, msg)
                return HttpResponseRedirect(reverse("acl-rules"))
Beispiel #3
0
def edit_acl(request, aclid):
    "Edit an acl"
    acl = get_object_or_404(AclRule, pk=aclid)
    if request.method == "POST":
        form = ACLForm(request.POST, instance=acl)
        if form.is_valid():
            try:
                form.save()
                msg = _("The ACL Rule has been updated")
            except DatabaseError:
                msg = _("The ACL Rule could not be updated")
            messages.info(request, msg)
            return HttpResponseRedirect(reverse("acl-rules"))
    else:
        form = ACLForm(instance=acl)
    return render_to_response("web/config/edit_acl.html", locals(), context_instance=RequestContext(request))
Beispiel #4
0
def delete_acl(request, aclid):
    "Delete a time period"
    acl = get_object_or_404(AclRule, pk=aclid)
    if request.method == 'POST':
        form = ACLForm(request.POST, instance=acl)
        if form.is_valid():
            try:
                acl.delete()
                msg = _('The ACL Rule has been deleted')
            except DatabaseError:
                msg = _('The ACL Rule could not be deleted')
            messages.info(request, msg)
            return HttpResponseRedirect(reverse('acl-rules'))
    else:
        form = ACLForm(instance=acl)
    return render_to_response('web/config/delete_acl.html',
                              locals(),
                              context_instance=RequestContext(request))