Exemplo n.º 1
0
def addUserToGroup(request, group_id, user_id):
    group = get_object_or_404(Group, uid=group_id)
    user = get_object_or_404(User, pk=user_id)
    if user not in group.users.all():
        membership = Membership(group=group, user=user)
        membership.save()
        return HttpResponse(simplejson.dumps({"success": True, "error_code": 0}), mimetype='application/json')
    else:
        return HttpResponse(simplejson.dumps({"success": False, "error_code": 1}), mimetype='application/json')
Exemplo n.º 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))
Exemplo n.º 3
0
def addUserToGroup(request, group_id, user_id):
    group = get_object_or_404(Group, uid=group_id)
    user = get_object_or_404(User, pk=user_id)
    if user not in group.users.all():
        membership = Membership(group=group, user=user)
        membership.save()
        return HttpResponse(simplejson.dumps({
            "success": True,
            "error_code": 0
        }),
                            mimetype='application/json')
    else:
        return HttpResponse(simplejson.dumps({
            "success": False,
            "error_code": 1
        }),
                            mimetype='application/json')
Exemplo n.º 4
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))