Beispiel #1
0
 def find_by_login(cls, login, active=True):
     query = DBSESSION().query(cls)
     query = query.options(load_only('pwd_hash'))
     query = query.filter_by(login=login)
     if active:
         query = query.filter_by(active=True)
     return query.first()
Beispiel #2
0
 def find_by_login(cls, login, active=True):
     query = DBSESSION().query(cls)
     query = query.options(load_only('pwd_hash'))
     query = query.filter_by(login=login)
     if active:
         query = query.filter_by(active=True)
     return query.first()
Beispiel #3
0
    def get_by_internal_id(cls, internal_id):
        query = DBSESSION().query(cls.id).filter_by(internal_id=internal_id)
        query = query.first()

        if query is not None:
            result = query[0]
        else:
            result = None
        return result
    def get_by_internal_id(cls, internal_id):
        query = DBSESSION().query(cls.id).filter_by(internal_id=internal_id)
        query = query.first()

        if query is not None:
            result = query[0]
        else:
            result = None
        return result
Beispiel #5
0
 def get_next_order(cls):
     """
     :returns: The next available order
     :rtype: int
     """
     query = DBSESSION().query(func.max(cls.order)).filter_by(active=True)
     query = query.first()
     if query is not None and query[0] is not None:
         result = query[0] + 1
     else:
         result = 0
     return result
 def get_next_order(cls):
     """
     :returns: The next available order
     :rtype: int
     """
     query = DBSESSION().query(func.max(cls.order)).filter_by(active=True)
     query = query.first()
     if query is not None and query[0] is not None:
         result = query[0] + 1
     else:
         result = 0
     return result
Beispiel #7
0
 def get_next_order_by_category(cls, category_id):
     """
     :param int category_id: The id of the category to check for
     :returns: The next order available in types from the given category
     :rtype: int
     """
     query = DBSESSION().query(func.max(cls.order)).filter_by(
         category_id=category_id).filter_by(active=True)
     query = query.first()
     if query is not None and query[0] is not None:
         result = query[0] + 1
     else:
         result = 0
     return result
Beispiel #8
0
 def get_next_order(cls):
     """
     :returns: The next available order
     :rtype: int
     """
     query = DBSESSION().query(func.max(cls.order)).filter_by(active=True)
     query = query.filter_by(
         type_=cls.__mapper_args__['polymorphic_identity'])
     query = query.first()
     if query is not None and query[0] is not None:
         result = query[0] + 1
     else:
         result = 0
     return result
Beispiel #9
0
 def get_next_order(cls):
     """
     :returns: The next available order
     :rtype: int
     """
     query = DBSESSION().query(func.max(cls.order)).filter_by(active=True)
     query = query.filter_by(
         type_=cls.__mapper_args__['polymorphic_identity']
     )
     query = query.first()
     if query is not None and query[0] is not None:
         result = query[0] + 1
     else:
         result = 0
     return result
 def get_next_order_by_category(cls, category_id):
     """
     :param int category_id: The id of the category to check for
     :returns: The next order available in types from the given category
     :rtype: int
     """
     query = DBSESSION().query(func.max(cls.order)).filter_by(
         category_id=category_id
     ).filter_by(active=True)
     query = query.first()
     if query is not None and query[0] is not None:
         result = query[0] + 1
     else:
         result = 0
     return result
Beispiel #11
0
    def _get_next_official_number(self, year=None):
        """
        Return the next available official number

        :param int year: The year we'd like to query a number for
        """
        next_ = 1
        if year is None:
            year = datetime.date.today().year

        query = DBSESSION().query(func.max(Task.official_number))
        query = query.filter(extract('year', Task.date) == year)
        last = query.first()[0]
        if last:
            next_ = last + 1

        return next_
Beispiel #12
0
 def last(cls, grid_class, company_id):
     query = DBSESSION().query(grid_class).filter_by(company_id=company_id)
     query = query.order_by(desc(grid_class.date))
     return query.first()
Beispiel #13
0
 def last(cls, grid_class, company_id):
     query = DBSESSION().query(grid_class).filter_by(company_id=company_id)
     query = query.order_by(desc(grid_class.date))
     return query.first()