make details for Comic, Artist and Issue clickable, add CustomField to select Comic and Issue

This commit is contained in:
Thomas Peetz
2025-06-05 17:58:27 +02:00
parent ea9f596abe
commit b4a0c2d7a5
11 changed files with 160 additions and 28 deletions
+19 -7
View File
@@ -1,6 +1,6 @@
import uuid
from datetime import datetime
from typing import Dict, List, Optional
from typing import Dict, List, Optional, Any
from natsort import natsorted
from sqlalchemy import Column, ForeignKey, Integer, String, Boolean, func
from sqlalchemy.orm import relationship, Mapped, mapped_column
@@ -48,10 +48,10 @@ class Comic(Base, BaseMixin):
def __str__(self):
return f'{self.title}({self.id})'
def get_artists(self) -> Dict[str, List[str]]:
works: Dict[str, List[str]] = {}
def get_artists(self) -> Dict[Any, List[Any]]:
works: Dict[Any, List[Any]] = {}
for work in self.comic_works:
work_type = work.work_type.name
work_type = work.work_type
artist = work.artist
if work_type in works:
works[work_type].append(artist)
@@ -107,6 +107,18 @@ class Issue(Base, BaseMixin):
story_arc = relationship("StoryArc", back_populates="issues")
issue_works = relationship("IssueWork")
def get_artists(self) -> Dict[Any, List[Any]]:
works: Dict[Any, List[Any]] = {}
for work in self.issue_works:
work_type = work.work_type
artist = work.artist
if work_type in works:
works[work_type].append(artist)
else:
works[work_type] = [artist]
return works
class Artist(Base, BaseMixin):
__tablename__ = "artist"
name = Column(String, nullable=False)
@@ -114,10 +126,10 @@ class Artist(Base, BaseMixin):
comic_works = relationship("ComicWork")
issue_works = relationship("IssueWork")
def get_comics(self) -> Dict[str, List[str]]:
works: Dict[str, List[str]] = {}
def get_comics(self) -> Dict[Any, List[Comic]]:
works: Dict[Any, List[Comic]] = {}
for work in self.comic_works:
work_type = work.work_type.name
work_type = work.work_type
comic = work.comic
if work_type in works:
works[work_type].append(comic)