"""Views for the users application."""from__future__importannotationsfromtypingimportTYPE_CHECKINGfromdjango.contribimportmessagesfromdjango.contrib.auth.viewsimportLoginViewfromsetup_wizardimportSetupWizardStatefromsetup_wizard.viewsimportStartupWizardRedirectfromtrustpoint.settingsimportDOCKER_CONTAINERifTYPE_CHECKING:fromtypingimportAnyfromdjango.httpimportHttpRequest,HttpResponse
[docs]classTrustpointLoginView(LoginView):"""Login view for the trustpoint application."""
[docs]defget(self,request:HttpRequest,*args:Any,**kwargs:Any)->HttpResponse:"""Redirects to the appropriate startup wizard section if the setup wizard is not completed. Args: request: The django request object. *args: All positional arguments are passed to super().get(). **kwargs: All keyword arguments are passed to super().get(). Returns: The HttpResponse object, which may be a redirect. """for_inmessages.get_messages(self.request):passifnotDOCKER_CONTAINER:returnsuper().get(request,*args,**kwargs)wizard_state=SetupWizardState.get_current_state()ifwizard_state==SetupWizardState.WIZARD_COMPLETED:returnsuper().get(request,*args,**kwargs)returnStartupWizardRedirect.redirect_by_state(wizard_state)
[docs]defpost(self,request:HttpRequest,*args:Any,**kwargs:Any)->HttpResponse:"""Redirects to the appropriate startup wizard section if the setup wizard is not completed. Args: request: The django request object. *args: All positional arguments are passed to super().post(). **kwargs: All keyword arguments are passed to super().post(). Returns: The HttpResponse object, which may be a redirect. """for_inmessages.get_messages(self.request):passifnotDOCKER_CONTAINER:returnsuper().post(request,*args,**kwargs)wizard_state=SetupWizardState.get_current_state()ifwizard_state==SetupWizardState.WIZARD_COMPLETED:returnsuper().post(request,*args,**kwargs)returnStartupWizardRedirect.redirect_by_state(wizard_state)