예제 #1
0
 def add_description(cls, _id, description):
     user = session.query(cls).filter(cls.id == int(_id)).update(
         {cls.description: description})
     session.commit()
     return user
예제 #2
0
 def admins_telegram_keys(cls):
     return {
         user.telegram_id: user.as_dict()
         for user in session.query(cls).filter(cls.admin).all()
     }
예제 #3
0
 def delete(cls, _id):
     user = session.query(cls).filter(cls.id == int(_id)).update(
         {cls.deleted: True})
     session.commit()
     return user
예제 #4
0
 def first_paginate(cls, first=0, last=0):
     return PaginateQuery(
         session.query(cls).filter(cls.deleted == False, cls.admin == None),
         cls.id, PAGINATE_MAX_LEN + 1, first, last).next()
예제 #5
0
 def users_telegram_keys(cls):
     return {
         user.telegram_id: user.as_dict()
         for user in session.query(cls).all()
     }
예제 #6
0
 def get(cls, _id):
     return session.query(cls).filter(cls.id == _id).first()
예제 #7
0
 def paginate_right(cls, first, last):
     return PaginateQuery(
         session.query(cls).filter(cls.deleted == False, cls.admin == None),
         cls.id, PAGINATE_PAGE_LEN, first, last).next()
예제 #8
0
 def all(cls):
     return session.query(cls).filter(cls.deleted == False).all()
예제 #9
0
 def get_token(cls, token):
     return session.query(cls).filter(
         cls.token == token, cls.used == False,
         cls.fresh_until > datetime.datetime.now()).first()
예제 #10
0
 def get_unused_tokens(cls):
     return session.query(cls).filter(
         cls.used == False,
         cls.fresh_until > datetime.datetime.now()).all()
예제 #11
0
 def first_paginate(cls, user_id, first=0, last=0):
     return PaginateQuery(
         session.query(cls).filter(cls.user_id == int(user_id)), cls.id,
         PAGINATE_MAX_LEN + 1, first, last, True).next(True)
예제 #12
0
 def paginate_right(cls, user_id, first, last):
     return PaginateQuery(
         session.query(cls).filter(cls.user_id == int(user_id)), cls.id,
         PAGINATE_PAGE_LEN, first, last, True).next()