def group_update(request, group_id, *args, **kwargs): """ Update an existing group. On GET, returns the update form for the existing group. On POST, attempts to validate and update the group. """ group = get_object_or_404(AccountGroup, pk=group_id) if not authenticate_group(request.user, group): raise PermissionDenied() if request.method == 'POST': group_form = AccountGroupForm(request.POST, instance=group) if group_form.is_valid(): group_form.save() return HttpResponseRedirect('/group') else: group_form = AccountGroupForm(instance=group) # Update the CSRF token kwargs.update(csrf(request)) context = RequestContext(request, dict(section="groups", form=group_form, group=group, mode="update", **kwargs)) return render_to_response("groups/form.html", context)
def group_update(request, group_id, *args, **kwargs): """ Update an existing group. On GET, returns the update form for the existing group. On POST, attempts to validate and update the group. """ group = get_object_or_404(AccountGroup, pk=group_id) if not authenticate_group(request.user, group): raise PermissionDenied() if request.method == 'POST': group_form = AccountGroupForm(request.POST, instance=group) if group_form.is_valid(): group_form.save() return HttpResponseRedirect('/group') else: group_form = AccountGroupForm(instance=group) # Update the CSRF token kwargs.update(csrf(request)) context = RequestContext( request, dict(section="groups", form=group_form, group=group, mode="update", **kwargs)) return render_to_response("groups/form.html", context)
def group_create(request, *args, **kwargs): """ Create a new group. On GET, returns the form for creating a new group. On POST, attempts to validate and create a new group. """ if request.method == 'POST': group_form = AccountGroupForm(request.POST) if group_form.is_valid(): group_form.save() return HttpResponseRedirect('/group') else: group_form = AccountGroupForm() # Update the CSRF token kwargs.update(csrf(request)) context = RequestContext(request, dict(section="groups", form=group_form, mode="create", **kwargs)) return render_to_response("groups/form.html", context)
def group_create(request, *args, **kwargs): """ Create a new group. On GET, returns the form for creating a new group. On POST, attempts to validate and create a new group. """ if request.method == 'POST': group_form = AccountGroupForm(request.POST) if group_form.is_valid(): group_form.save() return HttpResponseRedirect('/group') else: group_form = AccountGroupForm() # Update the CSRF token kwargs.update(csrf(request)) context = RequestContext( request, dict(section="groups", form=group_form, mode="create", **kwargs)) return render_to_response("groups/form.html", context)