classreg.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:django-danceschool 作者: django-danceschool 项目源码 文件源码
def dispatch(self,request,*args,**kwargs):
        ''' Always check that the temporary registration has not expired '''
        regSession = self.request.session.get(REG_VALIDATION_STR,{})

        if not regSession:
            return HttpResponseRedirect(reverse('registration'))

        try:
            reg = TemporaryRegistration.objects.get(
                id=self.request.session[REG_VALIDATION_STR].get('temporaryRegistrationId')
            )
        except ObjectDoesNotExist:
            messages.error(request,_('Invalid registration identifier passed to summary view.'))
            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'))

        # If OK, pass the registration and proceed
        kwargs.update({
            'reg': reg,
        })
        return super(RegistrationSummaryView,self).dispatch(request, *args, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号