@login_required
def invitation_create(request, template_name='invitations/invitation_form.html', success_template_name='invitations/invitation_success.html'):
 try:
  allotment = request.user.invitation_allotment
  if (allotment.amount == 0):
   return invitation_error(request)
 except InvitationAllotment.DoesNotExist:
  return invitation_error(request)
 if (request.method == 'POST'):
  form = InvitationForm(request.POST)
  if form.is_valid():
   invitation = form.save(commit=False)
   invitation.token = Invitation.objects.create_token(invitation.email)
   invitation.from_user = request.user
   invitation.save()
   allotment.decrement(1)
   send_invitation_email(invitation)
   return render(request, success_template_name)
 else:
  form = InvitationForm()
 return render(request, template_name, {'form': form})

@ login_required def invitation_create ( request , template_name = 'invitations/invitation_form.html' , success_template_name = 'invitations/invitation_success.html' ) : try : allotment = request . user . invitation_allotment if ( allotment . amount == 0 ) : return invitation_error ( request ) except InvitationAllotment . DoesNotExist : return invitation_error ( request ) if ( request . method == 'POST' ) : form = InvitationForm ( request . POST ) if form . is_valid ( ) : invitation = form . save ( commit = False ) invitation . token = Invitation . objects . create_token ( invitation . email ) invitation . from_user = request . user invitation . save ( ) allotment . decrement ( 1 ) send_invitation_email ( invitation ) return render ( request , success_template_name ) else : form = InvitationForm ( ) return render ( request , template_name , { 'form' : form } )
returns a form for a user to send an invitation .