[docs]defget_context_data(self,**kwargs)->dict[str,Any]:context=super().get_context_data(**kwargs)tracks=[]query_string=urlparse(context[self.redirect_field_name]).queryquery=parse_qs(query_string)ifqueryisnotNone:tracks=[get_object_or_404(Track,pk=pk)forpk_stringinquery.get('t',[])forpkinpk_string.split(',')]return{**context,'is_vote':bool(tracks),# this is naive, but we don't use ?t= for a lot'registration_form':RegistrationForm(),}
[docs]defform_valid(self,form:RegistrationForm)->HttpResponse:resp=super().form_valid(form)messages.success(self.request,'Registration complete! Log in to edit your profile.')returnresp
[docs]defform_valid(self,form:SetPasswordForm)->HttpResponse:form.save()messages.success(self.request,'you have set a password. please log in with it. your username is'f' {form.user.get_username()}',)returnsuper().form_valid(form)