Beispiel #1
0
    def get_histories(self, query=True, n=-1):
        session = BaseRepository.get_session(self)
        if n == -1:
            histories = session.query(History).filter(query).all()
        else:
            histories = session.query(History).filter(query).limit(n).all()

        return list(histories)
    def update_person(self, updated_person):
        if type(updated_person) is not Person:
            return
        session = BaseRepository.get_session(self)
        person = session.query(Person).filter_by(id=updated_person.id).first()
        properties = dir(person)
        for prop in properties:
            if prop != 'id' and not prop.startswith('_') and not prop.endswith('_'):
                setattr(person, prop, getattr(updated_person, prop))

        session.commit()
Beispiel #3
0
    def update_history(self, updated_history):
        if type(updated_history) is not History:
            return
        session = BaseRepository.get_session(self)
        history = session.query(History).filter_by(id=updated_history.id).first()
        properties = dir(history)
        for prop in properties:
            if prop != 'id' and not prop.startswith('_') and not prop.endswith('_'):
                setattr(history, prop, getattr(updated_history, prop))

        session.commit()
    def update_photo_database(self, updated_photo_database):
        if type(updated_photo_database) is not PhotoDatabase:
            return
        session = BaseRepository.get_session(self)
        photo_database = session.query(PhotoDatabase).filter_by(
            id=updated_photo_database.id).first()
        properties = dir(photo_database)
        for prop in properties:
            if prop != 'id' and not prop.startswith('_') and not prop.endswith(
                    '_'):
                setattr(photo_database, prop,
                        getattr(updated_photo_database, prop))

        session.commit()
 def add_person(self, person):
     if type(person) is not Person:
         return
     session = BaseRepository.get_session(self)
     session.add(person)
     session.commit()
 def get_persons(self, dataset_id):
     session = BaseRepository.get_session(self)
     persons = session.query(Person).filter_by(photo_database_id=dataset_id).all()
     return list(persons)
 def get_person_by_name(self, name):
     session = BaseRepository.get_session(self)
     person = session.query(Person).filter_by(name=name).first()
     return person
 def get_person(self, id):
     session = BaseRepository.get_session(self)
     person = session.query(Person).filter_by(id=id).first()
     return person
 def add_photo_database(self, photo_database):
     if type(photo_database) is not PhotoDatabase:
         return
     session = BaseRepository.get_session(self)
     session.add(photo_database)
     session.commit()
 def get_photo_databases(self, query=True):
     session = BaseRepository.get_session(self)
     photo_databases = session.query(PhotoDatabase).filter(query).all()
     return list(photo_databases)
 def get_photo_database_by_name(self, name):
     session = BaseRepository.get_session(self)
     photo_database = session.query(PhotoDatabase).filter_by(
         name=name).first()
     return photo_database
 def get_photo_database(self, id):
     session = BaseRepository.get_session(self)
     photo_database = session.query(PhotoDatabase).filter_by(id=id).first()
     return photo_database
Beispiel #13
0
 def add_history(self, history):
     if type(history) is not History:
         return
     session = BaseRepository.get_session(self)
     session.add(history)
     session.commit()
Beispiel #14
0
 def get_history(self, id):
     session = BaseRepository.get_session(self)
     history = session.query(History).filter_by(id=id).first()
     return history