add temporary access when database is empty

This commit is contained in:
Thomas Peetz
2026-02-10 08:36:43 +01:00
parent 69fb3c1e97
commit cc9d54f671
4 changed files with 19 additions and 9 deletions
+4
View File
@@ -8,3 +8,7 @@ from src.db.models.admin import Profile
def get_profile(username: AnyStr, db: Session) -> Optional[Profile]:
profile = db.query(Profile).filter(Profile.email == username).first()
return profile
def is_database_empty(db: Session) -> bool:
profiles = db.query(Profile).all()
return len(profiles) == 0
+4 -4
View File
@@ -12,11 +12,11 @@ def create_new_video(video: AddLinkForm, db: Session) -> MediaVideo:
print(video.url)
media_video = MediaVideo()
media_video.id = str(uuid.uuid4())
media_video.url = video.url # type: ignore
media_video.url = video.url
media_video.created_date = datetime.now()
media_video.last_modified_date = datetime.now()
media_video.review = True # type: ignore
media_video.should_download = True # type: ignore
media_video.review = True
media_video.should_download = True
db.add(media_video)
db.commit()
db.refresh(media_video)
@@ -27,7 +27,7 @@ def create_new_mediafile(link: str, db: Session) -> MediaFile:
logger.info("create MediaFile with url {link}")
media_file: MediaFile = MediaFile()
media_file.id = str(uuid.uuid4())
media_file.url = link # type: ignore
media_file.url = link
media_file.created_date = datetime.now()
media_file.last_modified_date = datetime.now()
media_file.version = 0