def dispatch(self, request, *args, **kwargs):
'''
Require session data to be set to proceed, otherwise go back to step 1.
Because they have the same expiration date, this also implies that the
TemporaryRegistration object is not yet expired.
'''
if REG_VALIDATION_STR not in request.session:
return HttpResponseRedirect(reverse('registration'))
try:
self.temporaryRegistration = TemporaryRegistration.objects.get(
id=self.request.session[REG_VALIDATION_STR].get('temporaryRegistrationId')
)
except ObjectDoesNotExist:
messages.error(request,_('Invalid registration identifier passed to sign-up form.'))
return HttpResponseRedirect(reverse('registration'))
expiry = parse_datetime(
self.request.session[REG_VALIDATION_STR].get('temporaryRegistrationExpiry',''),
)
if not expiry or expiry < timezone.now():
messages.info(request,_('Your registration session has expired. Please try again.'))
return HttpResponseRedirect(reverse('registration'))
return super(StudentInfoView,self).dispatch(request,*args,**kwargs)
评论列表
文章目录