示例#1
0
文件: views.py 项目: kamni/zorna
def add_group(request):
    if request.user.is_superuser:
        if request.method == 'POST':
            form = UserGroupForm(request.POST)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('list_groups'))
            else:
                form = UserGroupForm(request.POST)
        else:
            form = UserGroupForm()

        context = RequestContext(request)
        extra_context = {'form': form, 'title': _("Add new group")}
        return render_to_response('account/edit_group.html', extra_context, context_instance=context)
    else:
        return HttpResponseRedirect('/')
示例#2
0
文件: views.py 项目: kamni/zorna
def edit_group(request, group):
    if request.user.is_superuser:
        group = UserGroup.objects.get(pk=group)
        if request.method == 'POST':
            form = UserGroupForm(request.POST, instance=group)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('list_groups'))
            else:
                form = UserGroupForm(request.POST)
        else:
            form = UserGroupForm(instance=group)

        context = RequestContext(request)
        extra_context = {'form': form, 'title': _("Update group")}
        return render_to_response('account/edit_group.html', extra_context, context_instance=context)
    else:
        return HttpResponseRedirect('/')
示例#3
0
def add_group(request):
    if request.user.is_superuser:
        if request.method == 'POST':
            form = UserGroupForm(request.POST)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('list_groups'))
            else:
                form = UserGroupForm(request.POST)
        else:
            form = UserGroupForm()

        context = RequestContext(request)
        extra_context = {'form': form, 'title': _("Add new group")}
        return render_to_response('account/edit_group.html',
                                  extra_context,
                                  context_instance=context)
    else:
        return HttpResponseRedirect('/')
示例#4
0
def edit_group(request, group):
    if request.user.is_superuser:
        group = UserGroup.objects.get(pk=group)
        if request.method == 'POST':
            form = UserGroupForm(request.POST, instance=group)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('list_groups'))
            else:
                form = UserGroupForm(request.POST)
        else:
            form = UserGroupForm(instance=group)

        context = RequestContext(request)
        extra_context = {'form': form, 'title': _("Update group")}
        return render_to_response('account/edit_group.html',
                                  extra_context,
                                  context_instance=context)
    else:
        return HttpResponseRedirect('/')