add display for WorkType

This commit is contained in:
Thomas Peetz
2025-05-09 01:17:35 +02:00
parent d60e606663
commit 06a48a03ac
14 changed files with 230 additions and 13 deletions
+11
View File
@@ -110,6 +110,17 @@ class WorkType(Base, BaseMixin):
name = Column(String, nullable=False, unique=True)
comic_works = relationship("ComicWork")
def get_artists(self) -> Dict[str, List[str]]:
works: Dict[str, List[str]] = {}
for work in self.comic_works:
comic = work.comic.title
artist = work.artist
if comic in works:
works[comic].append(artist)
else:
works[comic] = [artist]
return works
def __repr__(self):
return f'Worktype({self.id} {self.version} {self.name} {len(self.comic_works)})'