Introduced None title Handling

Changed filename titles to be recognized as empty and replace empty titles with an unknown string.
dev
Peery 4 years ago
parent 2575f45421
commit 907f90ffdd

@ -320,7 +320,8 @@ class ArtNetManager:
#image_db_result = self.db_connection.get_art_by_path(self.all_images[self.curr_image_index]) #image_db_result = self.db_connection.get_art_by_path(self.all_images[self.curr_image_index])
s = self.all_images[self.curr_image_index].split(os.path.sep) s = self.all_images[self.curr_image_index].split(os.path.sep)
if image_db_result is not None: if image_db_result is not None:
image_title = image_db_result["title"] if len(image_db_result["title"]) > 0 else "-Title Unknown-" image_title = image_db_result["title"] if isinstance(image_db_result["title"], str) and \
len(image_db_result["title"]) > 0 else self.window.UNKNOWN_TITLE
image_author = self.db_connection.get_authors_of_art_by_ID(image_db_result["ID"]) image_author = self.db_connection.get_authors_of_art_by_ID(image_db_result["ID"])
image_link = image_db_result["link"] image_link = image_db_result["link"]
art_ID = image_db_result["ID"] art_ID = image_db_result["ID"]

@ -21,9 +21,9 @@ class DBAdapter:
Updates or saves the given image data to the DB Updates or saves the given image data to the DB
:param ID: :param ID:
:param title: :param title:
:param authors: :param authors: list of presences List[Tuple[str, str]]
:param path: :param path:
:param tags: :param tags: list of tag names List[str]
:param link: :param link:
:param md5_hash: md5 hash as a hex digest :param md5_hash: md5 hash as a hex digest
:return: :return:
@ -549,6 +549,7 @@ class DBAdapter:
:return: :return:
""" """
name = name.strip().lower() name = name.strip().lower()
implications = [self.get_tag_ID(x) for x in implications]
d = { d = {
"id": tag_id, "id": tag_id,
"name": name, "name": name,
@ -572,7 +573,7 @@ class DBAdapter:
self.remove_alias_by_ID(tag_id, old_alias) self.remove_alias_by_ID(tag_id, old_alias)
if implications is not None: if implications is not None:
old_implicants = self.get_tag_implications(name) old_implicants = self.get_tag_implications_by_ID(tag_id)
for implicant in implications: for implicant in implications:
if implicant in old_implicants: # is this already set? if implicant in old_implicants: # is this already set?
continue continue

@ -19,6 +19,9 @@ from ArtNet.web.link_generator import LinkGenerator
class Window(QtWidgets.QMainWindow): class Window(QtWidgets.QMainWindow):
UNKNOWN_TITLE = "-Title Unknown-"
UNKNOWN_PRESENCE = "(Not in Database)"
def __init__(self, main): def __init__(self, main):
super(Window, self).__init__() super(Window, self).__init__()
@ -130,7 +133,7 @@ class Window(QtWidgets.QMainWindow):
:return: :return:
""" """
new_title = self.curr_image_title new_title = self.curr_image_title
if new_title == self.curr_file_name or len(new_title) == 0: if new_title == self.curr_file_name or len(new_title) == 0 or new_title == Window.UNKNOWN_TITLE:
new_title = None new_title = None
image_data = { image_data = {
"ID": self.curr_art_id, "ID": self.curr_art_id,
@ -143,7 +146,7 @@ class Window(QtWidgets.QMainWindow):
} }
for presence in self.curr_presences: for presence in self.curr_presences:
if presence[-1] == "(Not in Database)": if presence[-1] == Window.UNKNOWN_PRESENCE:
msg = QtWidgets.QMessageBox() msg = QtWidgets.QMessageBox()
msg.setWindowTitle("Invalid Presence Domain") msg.setWindowTitle("Invalid Presence Domain")
msg.setInformativeText("You've tried to save with a not working presence entry! " + msg.setInformativeText("You've tried to save with a not working presence entry! " +
@ -302,10 +305,10 @@ class Window(QtWidgets.QMainWindow):
""" """
if len(presences) > 1: if len(presences) > 1:
for name, domain in presences: for name, domain in presences:
if domain == "(Not in Database)": if domain == Window.UNKNOWN_PRESENCE:
presences.remove((name, domain)) presences.remove((name, domain))
elif len(presences) == 0: elif len(presences) == 0:
presences = [(self.curr_art_path.split("/")[0], "(Not in Database)")] presences = [(self.curr_art_path.split("/")[0], Window.UNKNOWN_PRESENCE)]
self.curr_presences = presences self.curr_presences = presences
if self.curr_presences is not None: if self.curr_presences is not None:
@ -529,7 +532,7 @@ class Window(QtWidgets.QMainWindow):
self.ui.image_label.setMovie(self.__pixmap) self.ui.image_label.setMovie(self.__pixmap)
self.__pixmap.start() self.__pixmap.start()
self.__pixmap.frameChanged.connect(self.on_movie_frame_changed) self.__pixmap.frameChanged.connect(self.on_movie_frame_changed)
elif file_ending in ["webm"]: elif file_ending in ["webm", "mp4", "mov"]:
self.__showing_video = True self.__showing_video = True
self.__video = QVideoWidget() self.__video = QVideoWidget()
self.__player = QtMultimedia.QMediaPlayer(None, QtMultimedia.QMediaPlayer.VideoSurface) self.__player = QtMultimedia.QMediaPlayer(None, QtMultimedia.QMediaPlayer.VideoSurface)

Loading…
Cancel
Save