def view(self, request, application, label, roles, actions):
        """ Django view method. """
        status = None
        applicant = application.applicant
        attrs = []

        saml_session = saml.is_saml_session(request)

        # certain actions are supported regardless of what else happens
        if 'cancel' in request.POST:
            return "cancel"
        if 'prev' in request.POST:
            return 'prev'

        # test for conditions where shibboleth registration not required
        if applicant.saml_id is not None:
            status = "You have already registered a shibboleth id."
            form = None
            done = True

        elif application.content_type.model != 'applicant':
            status = "You are already registered in the system."
            form = None
            done = True

        elif (applicant.institute is not None
                and applicant.institute.saml_entityid is None):
            status = "Your institute does not have shibboleth registered."
            form = None
            done = True

        elif Institute.objects.filter(
                saml_entityid__isnull=False).count() == 0:
            status = "No institutes support shibboleth here."
            form = None
            done = True

        else:
            # shibboleth registration is required

            # Do construct the form
            form = saml.SAMLInstituteForm(
                request.POST or None,
                initial={'institute': applicant.institute})
            done = False
            status = None

            # Was it a POST request?
            if request.method == 'POST':

                # Did the login form get posted?
                if 'login' in request.POST and form.is_valid():
                    institute = form.cleaned_data['institute']
                    applicant.institute = institute
                    applicant.save()
                    # We do not set application.insitute here, that happens
                    # when application, if it is a ProjectApplication, is
                    # submitted

                    # if institute supports shibboleth, redirect back here via
                    # shibboleth, otherwise redirect directly back he.
                    url = base.get_url(request, application, roles, label)
                    if institute.saml_entityid is not None:
                        url = saml.build_shib_url(
                            request, url, institute.saml_entityid)
                    return HttpResponseRedirect(url)

                # Did we get a logout request?
                elif 'logout' in request.POST:
                    if saml_session:
                        url = saml.logout_url(request)
                        return HttpResponseRedirect(url)
                    else:
                        return HttpResponseBadRequest("<h1>Bad Request</h1>")

            # did we get a shib session yet?
            if saml_session:
                attrs, _ = saml.parse_attributes(request)
                saml_session = True

        # if we are done, we can proceed to next state
        if request.method == 'POST':
            if 'cancel' in request.POST:
                return "cancel"
            if 'prev' in request.POST:
                return 'prev'

            if not done:
                if saml_session:
                    applicant = _get_applicant_from_saml(request)
                    if applicant is not None:
                        application.applicant = applicant
                        application.save()
                    else:
                        applicant = application.applicant

                    applicant = saml.add_saml_data(
                        applicant, request)
                    applicant.save()

                    done = True
                else:
                    status = "Please login to SAML before proceeding."

        if request.method == 'POST' and done:
            for action in actions:
                if action in request.POST:
                    return action
            return HttpResponseBadRequest("<h1>Bad Request</h1>")

        # render the page
        return render(
            template_name='kgapplications/project_aed_shibboleth.html',
            context={
                'form': form,
                'done': done,
                'status': status,
                'actions': actions,
                'roles': roles,
                'application': application,
                'attrs': attrs,
                'saml_session': saml_session,
            },
            request=request)
def view ( self , request , application , label , roles , actions ) : status = None applicant = application . applicant attrs = [ ] saml_session = saml . is_saml_session ( request ) if 'cancel' in request . POST : return "cancel" if 'prev' in request . POST : return 'prev' if applicant . saml_id is not None : status = "You have already registered a shibboleth id." form = None done = True elif application . content_type . model != 'applicant' : status = "You are already registered in the system." form = None done = True elif ( applicant . institute is not None and applicant . institute . saml_entityid is None ) : status = "Your institute does not have shibboleth registered." form = None done = True elif Institute . objects . filter ( saml_entityid__isnull = False ) . count ( ) == 0 : status = "No institutes support shibboleth here." form = None done = True else : form = saml . SAMLInstituteForm ( request . POST or None , initial = { 'institute' : applicant . institute } ) done = False status = None if request . method == 'POST' : if 'login' in request . POST and form . is_valid ( ) : institute = form . cleaned_data [ 'institute' ] applicant . institute = institute applicant . save ( ) url = base . get_url ( request , application , roles , label ) if institute . saml_entityid is not None : url = saml . build_shib_url ( request , url , institute . saml_entityid ) return HttpResponseRedirect ( url ) elif 'logout' in request . POST : if saml_session : url = saml . logout_url ( request ) return HttpResponseRedirect ( url ) else : return HttpResponseBadRequest ( "<h1>Bad Request</h1>" ) if saml_session : attrs , _ = saml . parse_attributes ( request ) saml_session = True if request . method == 'POST' : if 'cancel' in request . POST : return "cancel" if 'prev' in request . POST : return 'prev' if not done : if saml_session : applicant = _get_applicant_from_saml ( request ) if applicant is not None : application . applicant = applicant application . save ( ) else : applicant = application . applicant applicant = saml . add_saml_data ( applicant , request ) applicant . save ( ) done = True else : status = "Please login to SAML before proceeding." if request . method == 'POST' and done : for action in actions : if action in request . POST : return action return HttpResponseBadRequest ( "<h1>Bad Request</h1>" ) return render ( template_name = 'kgapplications/project_aed_shibboleth.html' , context = { 'form' : form , 'done' : done , 'status' : status , 'actions' : actions , 'roles' : roles , 'application' : application , 'attrs' : attrs , 'saml_session' : saml_session , } , request = request )
Django view method.