コード例 #1
0
def del_user_lib(self,id):
    if User.by_id(id) is None:
        return {'status':False,'msg':'error'}
    user = User.by_id(id)
    dbSession.delete(user)
    dbSession.commit()
    return {'status':True, 'msg': '删除成功'}
コード例 #2
0
def register(self, name, password, twice_passwd, phone):
    print name, password, twice_passwd
    if name == '' and password == '':
        return {'status': False, 'msg': '请输入用户名或密码'}
    if password == twice_passwd:
        return {'status': False, 'msg': '请输入相同的密码'}
    user = User()
    user.name = name
    user.mobile = phone
    user.password = password
    self.db.add(user)
    self.db.commit()
    return {'status': True, 'msg': '注册成功'}
コード例 #3
0
 def get_current_user(self):
     """获取当前用户"""
     username = self.session.get("user_name")
     user = None
     if username:
         pass
         user = User.by_name(username)
     return user if user else None
コード例 #4
0
def user_see(self,uid):
    user = User.by_id(uid)
    kw = {
        'username': user.name,
        'userid': user.id,
        'usertel': user.mobile
    }
    return kw
コード例 #5
0
def get_some_info_lib(self,name):
    blog_count = dbSession.query(func.count(Blog.id)).scalar()
    comment_count = dbSession.query(func.count(Comment.id)).scalar()
    flink_count = dbSession.query(func.count(Flink.id)).scalar()
    project_count = dbSession.query(func.count(Article.id)).scalar()
    admin_count = dbSession.query(func.count(User.id)).scalar()
    user = User.by_name(name)
    return user,blog_count,comment_count,flink_count,project_count,admin_count
コード例 #6
0
def login(self, name, password):
    """02登录函数"""
    if name == '' and password == '':
        return {'status': False, 'msg': '请输入用户名或密码'}
    user = User.by_name(name)  #注意
    if user:  #注意
        user.last_login = datetime.now()
        user.loginnum += 1
        self.db.add(user)
        self.db.commit()
        self.session.set('user_name', user.name)
        self.set_secure_cookie('user_name', user.name, max_age=100)
        return {'status': True, 'msg': '登录成功'}
    return {'status': False, 'msg': '用户名输入错误或者密码不正确'}
コード例 #7
0
def get_user_info(self):
    """获取用户信息"""
    user =  User.all()
    counts = dbSession.query(func.count(User.id)).scalar()
    return user,counts