示例#1
0
    def get(self, ):
        result_data = {
            'error_code': 0,
            'reason': 'ok',
            'data': [],
        }
        uuid = self.get_argument('uuid', None)
        user_data = UserModel.get_by_uuid(uuid)
        if user_data:
            user_data.locked = True
            # print(self.dbs.dirty)
            self.dbs.add(user_data)
            try:

                self.dbs.commit()
                # print(user_data.locked)

            except Exception as e:
                print(e)
                self.dbs.rollback()
                result_data['error_code'] = 400
                result_data['reason'] = '删除失败'
            finally:
                self.dbs.close()

        self.write_json(result_data)
示例#2
0
 def get(self, ):
     uuid = self.get_argument('uuid', None)
     data = UserModel.get_by_uuid(uuid)
     self.render(
         'control/edit-data.html',
         data=data,
     )
示例#3
0
 def wrapper(*args, **kwargs):
     self =  args[0] #该url处理器本身
     if self.current_user:
         if UserModel.get_by_uuid(self.current_user.uuid).id == 1:
             return handler_method_func(*args, **kwargs)
     # self.write('not admin user!!!')
     self.redirect('/')
示例#4
0
    def wrapper(*args, **kwargs):
        self = args[0]
        score = self.get_argument('score', None)  # 总分
        rightnum = self.get_argument('rightNum', None)  # 答对数目
        wrongnum = self.get_argument('wrongNum', None)  # 答错数目
        loudanum = self.get_argument('loudaNum', None)  # 漏答数目


        #判断用户是否登录
        # print(self.current_user.uuid)
        if self.current_user:
            user_id = UserModel.get_by_uuid(self.current_user.uuid).id


            save_source = SourceModel(score=score,
                                      rightnum=rightnum,
                                      wrongnum=wrongnum,
                                      loudanum=loudanum,
                                      user_id=user_id)
            self.dbs.add(save_source)
            try:
                self.dbs.commit()
            except Exception as e:
                self.dbs.rollback()


        return handler(*args, **kwargs)
示例#5
0
 def get_current_user(self):
     '''
     用户已经登录:
         --返回用户实例
     :return:
         User对象
     '''
     uuid = self.get_secure_cookie('uuid', None)
     if uuid:
         return UserModel.get_by_uuid(uuid)
     return None
示例#6
0
 def get(self):
     result_data = {
         'error_code': 0,
         'reason': 'ok',
         'data': [],
     }
     uuid = self.get_argument('uuid', None)
     username = self.get_argument('username', None)
     password = self.get_argument('password', None)
     nickname = self.get_argument('nickname', None)
     locked = bool(self.get_argument('locked', None))
     if not CheckArgs.check_argument_reg(username, password, password):
         result_data['error_code'] = 400
         result_data['reason'] = '输入非法!'
     if uuid:
         '''有uuid则为修改信息'''
         data_info = UserModel.get_by_uuid(uuid)
         data_info.username = username
         data_info.nickname = nickname
         data_info.password = password
         data_info.locked = locked
     else:
         '''添加用户'''
         data_info = UserModel(
             username=username,
             nickname=nickname,
             password=password,
             locked=locked,
         )
     self.dbs.add(data_info)
     try:
         self.dbs.commit()
     except Exception as e:
         print(e)
         self.dbs.rollback()
         result_data['error_code'] = 400
         result_data['reason'] = '数据提交错误!'
     finally:
         self.dbs.close()
     self.write_json(result_data)