def set_photo_order(*_, first: PhotoDB, photoes: []): if not photoes: exit() else: first.set_next(photoes[0].id) photoes[0].set_pred(first.id) for i in range(1, len(photoes) - 1): photoes[i].set_pred(photoes[i - 1].id) photoes[i].set_next(photoes[i + 1]) photoes[-1].set_pred(photoes[-2]) db.session.commit()
def add_all_photoes(names: [], conspect: ConspectDB): for name in names: photo = PhotoDB(filename=name, id_conspect=conspect.id) db.session.add(photo) db.session.commit()
def remove_from_conspect(photo: PhotoDB): photo.id_conspect = None db.session.commit()
def add_photo_to_conspect(photo: PhotoDB, conspect: ConspectDB): photo.id_conspect = conspect.id db.session.commit()
def add_photo(filename: str): photo = PhotoDB(filename=filename) db.session.add(photo) db.session.commit() return photo