def _send_invitation(request, project):
    """ The logged in project leader OR administrator wants to invite somebody.
    """
    form = forms.InviteUserApplicationForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():

            email = form.cleaned_data['email']
            applicant, existing_person = get_applicant_from_email(email)

            # If applicant is None then there were multiple persons found.
            if applicant is None:
                return render(
                    template_name='kgapplications/'
                                  'project_common_invite_multiple.html',
                    context={'form': form, 'email': email},
                    request=request)

            if existing_person and 'existing' not in request.POST:
                return render(
                    template_name='kgapplications/'
                                  'project_common_invite_existing.html',
                    context={'form': form, 'person': applicant},
                    request=request)

            application = form.save(commit=False)
            application.applicant = applicant
            application.project = project
            application.save()
            state_machine = get_application_state_machine()
            response = state_machine.start(request, application)
            return response

    return render(
        template_name='kgapplications/project_common_invite_other.html',
        context={'form': form, 'project': project, },
        request=request)
def _send_invitation ( request , project ) : form = forms . InviteUserApplicationForm ( request . POST or None ) if request . method == 'POST' : if form . is_valid ( ) : email = form . cleaned_data [ 'email' ] applicant , existing_person = get_applicant_from_email ( email ) if applicant is None : return render ( template_name = 'kgapplications/' 'project_common_invite_multiple.html' , context = { 'form' : form , 'email' : email } , request = request ) if existing_person and 'existing' not in request . POST : return render ( template_name = 'kgapplications/' 'project_common_invite_existing.html' , context = { 'form' : form , 'person' : applicant } , request = request ) application = form . save ( commit = False ) application . applicant = applicant application . project = project application . save ( ) state_machine = get_application_state_machine ( ) response = state_machine . start ( request , application ) return response return render ( template_name = 'kgapplications/project_common_invite_other.html' , context = { 'form' : form , 'project' : project , } , request = request )
The logged in project leader OR administrator wants to invite somebody.