Пример #1
0
    def dispatch(self):
        self.__scope = None
        auth_token = self.request.cookies.get('auth_token')
        if users.is_current_user_admin():
            self.__locked = False
            if self.request.get('logg_ut') == 'true':
                self.redirect(users.create_logout_url('/prioriter'))
            else:
                self.__scope = TravelGrantsApplication.query(
                    TravelGrantsApplication.application_year ==
                    myapp.APPLICATION_YEAR)
        elif auth_token:
            self.__locked = myapp.time_locked(11, 29, 5)
            auth_token = SHA256.new(auth_token).hexdigest()
            if self.request.get('logg_ut') == 'true':
                ndb.delete_multi_async(
                    Otp.query(
                        ndb.OR(
                            Otp.token == auth_token,
                            Otp.valid_until < datetime.datetime.now())).fetch(
                                options=ndb.QueryOptions(keys_only=True)))
                self.response.delete_cookie('auth_token')
                self.redirect('/prioriter')
            else:
                otp = get_otp_by_token(auth_token)
                if otp:
                    self.__scope = TravelGrantsApplication.query(
                        ndb.AND(
                            TravelGrantsApplication.learning_association ==
                            otp.learning_association,
                            TravelGrantsApplication.application_year ==
                            myapp.APPLICATION_YEAR))
                    otp.put()  # Refresh expiration

        super(PrioritizeHandler, self).dispatch()
Пример #2
0
    def dispatch(self):
        self.__scope = None
        auth_token = self.request.cookies.get('auth_token')
        if users.is_current_user_admin():
            self.__locked = False
            if self.request.get('logg_ut') == 'true':
                self.redirect(users.create_logout_url('/prioriter'))
            else:
                self.__scope = TravelGrantsApplication.query(TravelGrantsApplication.application_year == myapp.APPLICATION_YEAR)
        elif auth_token:
            self.__locked = myapp.time_locked(12, 2, 5)
            auth_token = SHA256.new(auth_token).hexdigest()
            if self.request.get('logg_ut') == 'true':
                ndb.delete_multi_async(Otp.query(ndb.OR(Otp.token==auth_token, Otp.valid_until<datetime.datetime.now())).fetch(options=ndb.QueryOptions(keys_only=True)))
                self.response.delete_cookie('auth_token')
                self.redirect('/prioriter')
            else:
                otp = get_otp_by_token(auth_token)
                if otp:
                    self.__scope = TravelGrantsApplication.query(ndb.AND(TravelGrantsApplication.learning_association == otp.learning_association, TravelGrantsApplication.application_year == myapp.APPLICATION_YEAR))
                    otp.put() # Refresh expiration

        super(PrioritizeHandler, self).dispatch()
Пример #3
0
 def dispatch(self):
     self.__locked = myapp.time_locked(11, 18, 5)
     self.__grace_locked = myapp.time_locked(11, 18, 7)
     super(MainHandler, self).dispatch()
Пример #4
0
 def dispatch(self):
     self.__locked = myapp.time_locked(11, 21, 5)
     self.__grace_locked = myapp.time_locked(11, 21, 7)
     super(MainHandler, self).dispatch()