def invite_someone_do(request): remaining_invitations = InvitationKey.objects.remaining_invitations_for_user(request.user) form = InvitationKeyForm(data=request.POST) if form.is_valid(): if remaining_invitations > 0: invitation = InvitationKey.objects.create_invitation(request.user) invitation.send_to(form.cleaned_data["email"]) # Yay! Redirect back to invite page, with message saying who # was just invited. return HttpResponseRedirect( reverse(invite_someone) + "?invited=" + urllib.quote(form.cleaned_data["email"]) ) else: # yes, there's an email; no, the guy can't invite return invite_someone(request, form=form, error_message="No more invites.") else: return invite_someone(request, form=form)
def invite_someone_do(request): remaining_invitations = (InvitationKey.objects. remaining_invitations_for_user(request.user)) form = InvitationKeyForm(data=request.POST) if form.is_valid(): if remaining_invitations > 0: invitation = InvitationKey.objects.create_invitation(request.user) invitation.send_to(form.cleaned_data["email"]) # Yay! Redirect back to invite page, with message saying who # was just invited. return HttpResponseRedirect( reverse(invite_someone) + '?invited=' + urllib.quote(form.cleaned_data['email'])) else: # yes, there's an email; no, the guy can't invite return invite_someone(request, form=form, error_message='No more invites.') else: return invite_someone(request, form=form)
def invite_someone(request, form=None, success_message=''): if form is None: invite_someone_form = InvitationKeyForm() else: invite_someone_form = form remaining_invites = InvitationKey.objects.remaining_invitations_for_user( request.user) return (request, 'account/invite_someone.html', { 'success_message': success_message, 'invite_someone_form': invite_someone_form, 'remaining_invites': remaining_invites })
def caselistadmin(request, slug): try: cldata = get_caselist_data_by_slug(request, slug) if not is_caselist_admin(request.user, cldata['CaseList']): raise Http404 cldata['CaseListForm'] = CaseListForm(instance=cldata['CaseList']) cldata['UserFormSet'] = UserCaseListSelectFormSet( queryset=cldata['Users'], initial=[{ 'selected': u'on', }]) cldata['InviteUser'] = InvitationKeyForm() except CaseList.DoesNotExist: raise Http404 return render(request, 'rateslide/caselistadmin.html', cldata)
def invite_someone(request, form=None, success_message=''): if form is None: invite_someone_form = InvitationKeyForm() else: invite_someone_form = form remaining_invites = InvitationKey.objects.remaining_invitations_for_user( request.user) if request.GET.get('invited'): account_notification = 'E-mail has been sent.' else: account_notification = '' return (request, 'account/invite_someone.html', { 'success_message': success_message, 'invite_someone_form': invite_someone_form, 'remaining_invites': remaining_invites, 'account_notification': account_notification, })