コード例 #1
0
ファイル: models.py プロジェクト: jerkos/be-my-change
 def count_for_actions(action_ids: list):
     return db.session.query(
         Commentary.action_id,
         func.count(Commentary.action_id))\
         .filter(
             and_(
                 Commentary.action_id.in_(action_ids),
                 Commentary.is_journal == None
             )
         ).group_by(Commentary.action_id)\
         .all()
コード例 #2
0
ファイル: models.py プロジェクト: Xexi11/DAM-ProjectCore
 def status(cls):
     current_datetime = datetime.datetime.now()
     return case(
         [
             (current_datetime < cls.finish_register_date,
              type_coerce(TournamentStatusEnum.open, Enum(TournamentStatusEnum))),
             (and_(current_datetime > cls.finish_register_date, current_datetime < cls.finish_date),
              type_coerce(TournamentStatusEnum.in_game, Enum(TournamentStatusEnum)))
         ],
         else_=type_coerce(TournamentStatusEnum.closed, Enum(TournamentStatusEnum))
     )
コード例 #3
0
ファイル: house_views.py プロジェクト: htengteng/Ihome
def my_housing():
    """我的房源信息"""
    houses = None
    try:
        houses = House.query.filter(
            and_(House.user_id == session['user_id'],
                 House.is_delected == False)).all()
    except Exception as e:
        print(e)
    print(houses)
    house_list = [house.to_dict() for house in houses]
    return jsonify(code=status_code.ok, house_list=house_list)
コード例 #4
0
ファイル: models.py プロジェクト: strixZombis/DAM-ProjectCore
 def status(cls):
     current_datetime = datetime.datetime.now()
     return case([
         (current_datetime < cls.start_date,
          type_coerce(EventStatusEnum.open, Enum(EventStatusEnum))),
         (and_(current_datetime > cls.start_date,
               current_datetime < cls.finish_date),
          type_coerce(EventStatusEnum.ongoing, Enum(EventStatusEnum))),
         (current_datetime > cls.finish_date,
          type_coerce(EventStatusEnum.closed, Enum(EventStatusEnum))),
     ],
                 else_=type_coerce(EventStatusEnum.undefined,
                                   Enum(EventStatusEnum)))
コード例 #5
0
 def loginUser(self, email, password):
     # initialize session
     self.create_session()
     # query database to query the user
     #NOTE: password should be encrypted and saved
     user = self.session.query(User).filter(
         and_(User.email == email, User.password == password)).first()
     # if user doesn't exist send an error message
     if user is None:
         return {"error": "email or password is incorrect"}
     # if the password is correct than return the accesstoken
     # use email id to create JWT token
     token = create_access_token(identity=user.email, expires_delta=False)
     # return the user info with the token
     self.end_session()
     return {"accesstoken": token}