Exemple #1
0
def join_org(request):
    user = request.session['user']
    if request.method == 'POST':
        print request.POST
        form = MemberForm(user, request.POST)
        print "h1"
        if form.is_valid():
            print "hello"
            org = form.cleaned_data['choices']
            print org
            member = Membership(user=user,org=org,accepted=False)
            member.save()
            return HttpResponseRedirect(reverse('main.views.dashboard'))
    else:
        return render_to_response('main/join_team.html',
                              {'form':MemberForm(user)},
                              context_instance=RequestContext(request))
Exemple #2
0
def create_org(request):
    if request.method == 'POST':
        form = OrgForm(request.POST)
        if form.is_valid():
            user = request.session['user']
            name = form.cleaned_data['name']
            choice = form.cleaned_data['choices']
            parent = form.cleaned_data['parent_choices']
            if parent is None:
                org = Org(name=name,creator=user,org_type=choice, accepted=True)
            else:
                org = Org(name=name,creator=user,org_type=choice, accepted=False,parent=parent)
            org.save()
            member = Membership(user=user,org=org,accepted=True)
            member.save()
            return HttpResponseRedirect(reverse('main.views.dashboard'))
        else:
            print "not valid"
    else:
        return render_to_response('main/new_team.html',
                              {'form':OrgForm()},
                              context_instance=RequestContext(request))