示例#1
0
def group_add(request,template="admin/config/group/add.tpl"):
    if request.method == "GET":
        return render_response(template)
    elif request.method == "POST":
        form = GroupForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            description = form.cleaned_data['description']
            try:
                group = Group.objects.create(name=name,description=description)
                group.save()
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'group_add'}).close();</script>")
示例#2
0
def group_edit(request,group_id=0,template="admin/config/group/edit.tpl"):
    group = Group.get_by_id(group_id)
    if request.method == "GET":
        return render_response(template,group=group)
    elif request.method == "POST":
        form = GroupForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            description = form.cleaned_data['description']
            try:
                group.name = name
                group.description = description
                group.save()
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'group_edit'}).close();</script>")