예제 #1
0
파일: bapi.py 프로젝트: manshufeier/qbsy
 def getLogList(self, _param):
     '''
     获取日志列表
     @param _param: 
     @return: 
     '''
     query = ActionLog.objects.select_related('user').order_by('-id')
     fields = ['id', 'action', 'model', 'objsid', 'created']
     return gen_pager_array(
         query,
         func=lambda o: obj2dic(
             o, fields, {'user': o.user.showname if o.user else None}),
         param=_param)
예제 #2
0
파일: bapi.py 프로젝트: manshufeier/qbsy
 def login(self, username, password):
     """
     用户登录
     @param username: 
     @param password: 
     @return: 
     """
     user = User.objects.filter(username=username).first()
     if user and user.password == User.pwdhash(password, user.salt):
         if user.status == User.STATUS_CANCELED:
             raise ex(u'该用户已被锁定无法登陆')
         self.session_set('me', user.get_json())
         self.logAtion(ActionLog.ACTION_LOGIN)
         logingoto = self.session_get_once('logingoto')
         return obj2dic(user, ['id', 'username', 'token'],
                        {'goto': logingoto or '/xadmin/'})
     else:
         raise ex(u'用户名或密码错误')
예제 #3
0
 def to_simple_json(self):
     return obj2dic(self, ['id'], {})
예제 #4
0
 def to_json(self):
     return obj2dic(self, ['id', 'created'], {})
예제 #5
0
 def to_json(self):
     from base.utils import obj2dic
     return obj2dic(
         self, ['id', 'date', 'type', 'title', 'content', 'icon', 'image'])