Example #1
0
def invite(request):
    if request.method == 'POST':
        f = forms.InviteForm(request.POST)
        if f.is_valid():
            profile = request.user.get_profile()
            invite = f.save(profile)
            invite.send(sender=profile)
            return HttpResponseRedirect(reverse(invited, args=[invite.id]))
    else:
        f = forms.InviteForm()
    data = dict(form=f)

    return render(request, 'phonebook/invite.html', data)
Example #2
0
def invite(request):
    if request.method == 'POST':
        f = forms.InviteForm(request.POST)
        if f.is_valid():
            ldap = UserSession.connect(request)
            unique_id = request.user.unique_id
            try:
                person = ldap.get_by_unique_id(unique_id, use_master=True)
            except NO_SUCH_PERSON:
                log.info('profile_uid Sending 404 for [%s]' % unique_id)
                raise Http404

            invite = f.save(commit=False)
            invite.inviter = request.user.unique_id
            invite.save()
            invite.send(sender=person)

            return HttpResponseRedirect(reverse(invited, args=[invite.id]))
    else:
        f = forms.InviteForm()
    data = dict(form=f, foo='bar')

    return render(request, 'phonebook/invite.html', data)