Fixed alias editing bug & changed empty title handling

Fixed a bug where editing the alias or implication of a tag caused a crash.
Also changed titles that were left unedited from the file name to stay empty inside the database and not be filled with the filename
dev
Peery 4 years ago
parent b5e226bc3a
commit 2575f45421

@ -225,18 +225,21 @@ class ArtNetManager:
"""
for i in range(len(self.all_images)):
image_db_result = self.db_connection.get_art_by_path(self.all_images[i])
file_name = os.path.basename(self.all_images[i])
if image_db_result is None: # unknown image, skip
continue
hash_digest = self.get_md5_of_image(self.all_images[i])
authors = self.db_connection.get_authors_of_art(path=image_db_result["path"])
authors = self.db_connection.get_authors_of_art_by_ID(image_db_result["ID"])
tag_ids = self.db_connection.get_art_tags_by_ID(art_ID=image_db_result["ID"])
tags = []
for tag_id in tag_ids:
tags.append(self.db_connection.get_tag_by_ID(tag_id)[0][1].strip())
if image_db_result["title"] == file_name or len(image_db_result["title"]) == 0:
image_db_result["title"] = None
self.db_connection.save_image(ID=image_db_result["ID"], path=image_db_result["path"],
title=image_db_result["title"],
link=image_db_result["link"], authors=authors, md5_hash=hash_digest,

@ -565,22 +565,22 @@ class DBAdapter:
for alias in aliases:
if alias in old_aliases: # is this already set?
continue
self.add_alias_by_name(name, alias)
self.add_alias_by_ID(tag_id, alias)
for old_alias in old_aliases:
if old_alias not in aliases: # got to delete an alias?
self.remove_alias_by_name(name, old_alias)
self.remove_alias_by_ID(tag_id, old_alias)
if implications is not None:
old_implicants = self.get_tag_implications(name)
for implicant in implications:
if implicant in old_implicants: # is this already set?
continue
self.add_implication_by_name(name, implicant)
self.add_implication_by_ID(tag_id, implicant)
for old_implicant in old_implicants:
if old_implicant not in implications: # got to delete an implicant?
self.remove_implication_by_name(name, old_implicant)
self.remove_implication_by_ID(tag_id, old_implicant)
def add_alias_by_name(self, name: str, alias: str):
"""
@ -663,7 +663,7 @@ class DBAdapter:
"tag": tag,
"implicant": implicant
}
self.db_cursor.execute("DELETE FROM tag_implication WHERE root_tag = %(name)s " +
self.db_cursor.execute("DELETE FROM tag_implication WHERE root_tag = %(tag)s " +
"and implicate = %(implicant)s", d)
self.db.commit()
@ -842,7 +842,7 @@ class DBAdapter:
Search for the tag's implications
:param name:
:param output_ID: Don't resolve the tag ids into names in the resulting list
:return: List of tag names
:return: List of tag ids
"""
d = {"ID": self.get_tag_ID(name)}
if d["ID"] is None:

@ -129,9 +129,12 @@ class Window(QtWidgets.QMainWindow):
Save the changes to image data to the DB.
:return:
"""
new_title = self.curr_image_title
if new_title == self.curr_file_name or len(new_title) == 0:
new_title = None
image_data = {
"ID": self.curr_art_id,
"title": self.curr_image_title,
"title": new_title,
"authors": self.curr_presences,
"path": self.curr_art_path,
"tags": self.curr_tags,

Loading…
Cancel
Save