Пример #1
0
def createGroup(request):
    if(request.method == "POST"):
        form = GroupCreateForm(data=request.POST)
        if form.is_valid():
            group = form.save(commit=False)
            group.creator = request.user
            group.save()
            m = Membership(user=request.user, group=group, status=1)
            m.save()
            messages.info(request, "Group \"" + group.name + "\" created.")
            return redirect('/')
    else:
        form = GroupCreateForm()
    return render_to_response('form_base.html', {"form": form, "heading": "Group Creation"}, context_instance=RequestContext(request))
Пример #2
0
def createGroup(request):
    if (request.method == "POST"):
        form = GroupCreateForm(data=request.POST)
        if form.is_valid():
            group = form.save(commit=False)
            group.creator = request.user
            group.save()
            m = Membership(user=request.user, group=group, status=1)
            m.save()
            messages.info(request, "Group \"" + group.name + "\" created.")
            return redirect('/')
    else:
        form = GroupCreateForm()
    return render_to_response('form_base.html', {
        "form": form,
        "heading": "Group Creation"
    },
                              context_instance=RequestContext(request))
Пример #3
0
def editGroup(request, group_id):
    group = get_object_or_404(Group, uid=group_id)
    if request.user != group.creator and request.user not in group.admins():
        # message about authentication
        return redirect("usermanage.views.listGroups")
    try:
        membership = Membership.objects.get(group=group, user=request.user)
        if membership.is_staff():
            if request.method == "POST":
                form = GroupCreateForm(data=request.POST, instance=group)
                if form.is_valid():
                    group = form.save()
                    # need to check if permissions change
                    return redirect("usermanage.views.listGroups")
            else:
                form = GroupCreateForm(instance=group)
            return render_to_response('form_base.html', {"form": form, "heading": "Edit Group"}, context_instance=RequestContext(request))
    except ObjectDoesNotExist or MultipleObjectsReturned:
        return redirect("usermanage.views.listGroups")
Пример #4
0
def editGroup(request, group_id):
    group = get_object_or_404(Group, uid=group_id)
    if request.user != group.creator and request.user not in group.admins():
        # message about authentication
        return redirect("usermanage.views.listGroups")
    try:
        membership = Membership.objects.get(group=group, user=request.user)
        if membership.is_staff():
            if request.method == "POST":
                form = GroupCreateForm(data=request.POST, instance=group)
                if form.is_valid():
                    group = form.save()
                    # need to check if permissions change
                    return redirect("usermanage.views.listGroups")
            else:
                form = GroupCreateForm(instance=group)
            return render_to_response('form_base.html', {
                "form": form,
                "heading": "Edit Group"
            },
                                      context_instance=RequestContext(request))
    except ObjectDoesNotExist or MultipleObjectsReturned:
        return redirect("usermanage.views.listGroups")