Example #1
0
    def process_request(self, env, request, user_uuid=None, task_id=None, item_id=None, params=None, ext=None):
        #~ print ''
        #~ print 'process_request: ', request, user_uuid, task_id, item_id, params

        user_info = {}
        is_admin = task_id == 0
        if is_admin:
            task = self.admin
        else:
            task = self.get_task()
        if self.under_maintenance:
            return {'status': common.UNDER_MAINTAINANCE, 'data': None}
        if request == 'login':
            return {'status': common.RESPONSE, 'data': self.login(params[0], params[1], is_admin, env)}
        if ext:
            obj = task
        else:
            if self.admin.safe_mode:
                now = common.now()
                if common.hour_diff(now - self.last_users_update) > 1:
                    self.update_users()
                user_info = self.get_user_info(user_uuid, is_admin, env)
                if not user_info:
                    return {'status': common.NOT_LOGGED, 'data': common.NOT_LOGGED}
            obj = task
            if task:
                obj = task.item_by_ID(item_id)

        return {'status': common.RESPONSE, 'data': self.get_response(is_admin, env, request, user_info, task_id, obj, params, ext)}
Example #2
0
    def process_request(self, env, request, user_uuid, task_id, item_id,
                        params, web):
        #~ print ''
        #~ print 'process_request: ', request, user_uuid, task_id, item_id, params, web

        is_admin = task_id == 0
        user_info = {}
        if self.under_maintenance:
            return {'status': common.UNDER_MAINTAINANCE, 'data': None}
        if request == 'login':
            return {
                'status': common.RESPONSE,
                'data': self.login(params[0], params[1], is_admin, env)
            }
        if is_admin:
            task = self.admin
        else:
            task = self.get_task()
        if self.admin.safe_mode:
            now = common.now()
            if common.hour_diff(now - self.last_users_update) > 1:
                self.update_users()
            user_info = self.get_user_info(user_uuid, is_admin, env)
            if not user_info:
                return {'status': common.NOT_LOGGED, 'data': common.NOT_LOGGED}
        obj = task
        if task:
            obj = task.item_by_ID(item_id)

        return {
            'status':
            common.RESPONSE,
            'data':
            self.get_response(is_admin, env, request, user_info, task_id, obj,
                              params, web)
        }
Example #3
0
 def update_users(self):
     now = common.now()
     for key in self.users.keys():
         if common.hour_diff(now - self.users[key][2]) > 12:
             self.logout(key)
     self.last_users_update = common.now()
Example #4
0
 def update_users(self):
     now = common.now()
     for key in self.users.keys():
         if common.hour_diff(now - self.users[key][2]) > 12:
             self.logout(key)
     self.last_users_update = common.now()