add IssueWork entity with Repository, Form and View
This commit is contained in:
@@ -20,6 +20,7 @@ from db.models.comic import (
|
||||
TradePaperback,
|
||||
Volume,
|
||||
ComicWork,
|
||||
IssueWork,
|
||||
Artist,
|
||||
Comic,
|
||||
Publisher,
|
||||
@@ -61,6 +62,7 @@ registry = {
|
||||
Issue.__tablename__: Issue,
|
||||
TradePaperback.__tablename__: TradePaperback,
|
||||
ComicWork.__tablename__: ComicWork,
|
||||
IssueWork.__tablename__: IssueWork,
|
||||
Article.__tablename__: Article,
|
||||
BookshelfPublisher.__tablename__: BookshelfPublisher,
|
||||
Book.__tablename__: Book,
|
||||
|
||||
@@ -195,6 +195,7 @@ class Issue(Base, BaseMixin):
|
||||
volume = relationship("Volume", back_populates="issues")
|
||||
story_arc_id = Column(String, ForeignKey("story_arc.id"), nullable=True)
|
||||
story_arc = relationship("StoryArc", back_populates="issues")
|
||||
issue_works = relationship("IssueWork")
|
||||
|
||||
def import_dict(self, import_data: Dict[AnyStr, Any]):
|
||||
self.id = import_data['id']
|
||||
@@ -236,6 +237,7 @@ class Artist(Base, BaseMixin):
|
||||
name = Column(String, nullable=False)
|
||||
weblink = Column(String, nullable=True)
|
||||
comic_works = relationship("ComicWork")
|
||||
issue_works = relationship("IssueWork")
|
||||
|
||||
def import_dict(self, import_data: Dict[AnyStr, Any]):
|
||||
self.id = import_data['id']
|
||||
@@ -262,6 +264,7 @@ class WorkType(Base, BaseMixin):
|
||||
__tablename__ = "worktype"
|
||||
name = Column(String, nullable=False, unique=True)
|
||||
comic_works = relationship("ComicWork")
|
||||
issue_works = relationship("IssueWork")
|
||||
|
||||
def __repr__(self):
|
||||
return f'Worktype({self.id} {self.version} {self.name} {len(self.comic_works)})'
|
||||
@@ -316,3 +319,35 @@ class ComicWork(Base, BaseMixin):
|
||||
'work_type_id': self.work_type_id
|
||||
}
|
||||
return item
|
||||
|
||||
|
||||
class IssueWork(Base, BaseMixin):
|
||||
__tablename__ = "issue_work"
|
||||
issue_id = Column(String, ForeignKey("issue.id"), nullable=False)
|
||||
issue = relationship("Issue", back_populates="issue_works")
|
||||
artist_id = Column(String, ForeignKey("artist.id"), nullable=False)
|
||||
artist = relationship("Artist", back_populates="issue_works")
|
||||
work_type_id = Column(String, ForeignKey("worktype.id"), nullable=False)
|
||||
work_type = relationship("WorkType", back_populates="issue_works")
|
||||
|
||||
def import_dict(self, import_data: Dict[AnyStr, Any]):
|
||||
self.id = import_data['id']
|
||||
self.created_date = import_data['created_date']
|
||||
self.last_modified_date = import_data['last_modified_date']
|
||||
self.version = import_data['version']
|
||||
self.issue_id = import_data['issue_id']
|
||||
self.artist_id = import_data['artist_id']
|
||||
self.work_type_id = import_data['work_type_id']
|
||||
|
||||
def export_dict(self) -> Dict[AnyStr, Any]:
|
||||
item: Dict[AnyStr, Any] = {
|
||||
'id': self.id,
|
||||
'created_date': str(self.created_date),
|
||||
'last_modified_date': str(self.last_modified_date),
|
||||
'version': self.version,
|
||||
'issue_id': self.issue_id,
|
||||
'artist_id': self.artist_id,
|
||||
'work_type_id': self.work_type_id
|
||||
}
|
||||
return item
|
||||
|
||||
|
||||
Reference in New Issue
Block a user