added issue works on artist details
This commit is contained in:
@@ -4,10 +4,13 @@
|
||||
grid-gap: 20px;
|
||||
}
|
||||
section {
|
||||
margin-left: 10px;
|
||||
padding: 10px;
|
||||
margin-left: 10px;
|
||||
padding: 10px;
|
||||
background-color: darkgrey;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
article {
|
||||
margin-left: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,30 @@
|
||||
</div>
|
||||
<div>
|
||||
@if (artist()) {
|
||||
<h2>{{ artist().name }}</h2>
|
||||
<a href="{{ artist().weblink }}">{{ artist().name }}</a>
|
||||
@for (work of artist().works; track work.worktype.id) {
|
||||
<section>
|
||||
<app-comic-worktype [worktype]="work.worktype"/>
|
||||
@for (comic of work.comics; track comic.id) {
|
||||
<article>
|
||||
<app-comic-comic [comic]="comic"/>
|
||||
</article>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
<section>
|
||||
<h2>{{ artist().name }}</h2>
|
||||
<a href="{{ artist().weblink }}" style="background-color: green;">{{ artist().name }}</a>
|
||||
</section>
|
||||
@for (work of artist().comic_works; track work.worktype.id) {
|
||||
<section>
|
||||
<app-comic-worktype [worktype]="work.worktype"/>
|
||||
@for (comic of work.comics; track comic.id) {
|
||||
<article>
|
||||
<app-comic-comic [comic]="comic"/>
|
||||
</article>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
@for (work of artist().issue_works; track work.worktype.id) {
|
||||
<section>
|
||||
<app-comic-worktype [worktype]="work.worktype"/>
|
||||
@for (issue of work.issues; track issue.id) {
|
||||
<article>
|
||||
<app-comic-comic [comic]="issue.comic"/>
|
||||
</article>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
} @else {
|
||||
<h2>Artist Details</h2>
|
||||
}
|
||||
|
||||
@@ -16,6 +16,20 @@ export interface Comic {
|
||||
completed: boolean;
|
||||
}
|
||||
|
||||
export interface Volume {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Issue {
|
||||
id: string;
|
||||
issue_number: string;
|
||||
in_stock: boolean;
|
||||
is_read: boolean;
|
||||
comic: Comic;
|
||||
volume: Volume | undefined
|
||||
|
||||
}
|
||||
export interface ComicWork {
|
||||
worktype: string;
|
||||
|
||||
@@ -38,9 +52,14 @@ export interface ArtistWorktypeComics {
|
||||
comics: Comic[];
|
||||
}
|
||||
|
||||
export interface ArtistWorktypeIssues {
|
||||
worktype: Worktype;
|
||||
issues: Issue[];
|
||||
}
|
||||
export interface ArtistDetails {
|
||||
id: string;
|
||||
name: string;
|
||||
weblink: string;
|
||||
works: ArtistWorktypeComics[];
|
||||
comic_works: ArtistWorktypeComics[];
|
||||
issue_works: ArtistWorktypeIssues[];
|
||||
}
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
from typing import List
|
||||
from src.db.models.comic import Artist
|
||||
from src.schema.comics.artist_details import ArtistDetailResponse, ArtistWorktypeComicResponse
|
||||
from src.schema.comics.artist_details import ArtistDetailResponse, ArtistWorktypeComicResponse, ArtistWorktypeIssueResponse
|
||||
from src.schema.comics.comic import ComicResponse
|
||||
from src.schema.comics.worktype import WorktypeResponse
|
||||
|
||||
|
||||
def get_artist_details(artist: Artist) -> ArtistDetailResponse:
|
||||
works: List[ArtistWorktypeComicResponse] = []
|
||||
works_map = {}
|
||||
comic_works: List[ArtistWorktypeComicResponse] = []
|
||||
comic_works_map = {}
|
||||
for work in artist.comic_works:
|
||||
worktype_id = work.work_type.id
|
||||
if worktype_id in works_map:
|
||||
if worktype_id in comic_works_map:
|
||||
comic = ComicResponse(id=work.comic.id, title=work.comic.title, completed=work.comic.completed)
|
||||
works_map[worktype_id].comics.append(comic)
|
||||
comic_works_map[worktype_id].comics.append(comic)
|
||||
else:
|
||||
works_map[worktype_id] = ArtistWorktypeComicResponse(
|
||||
comic_works_map[worktype_id] = ArtistWorktypeComicResponse(
|
||||
worktype=WorktypeResponse(id=worktype_id, name=work.work_type.name),
|
||||
comics=[ComicResponse(id=work.comic.id, title=work.comic.title, completed=work.comic.completed)]
|
||||
)
|
||||
for value in works_map.values():
|
||||
works.append(value)
|
||||
for value in comic_works_map.values():
|
||||
comic_works.append(value)
|
||||
issue_works: List[ArtistWorktypeIssueResponse] = []
|
||||
response = ArtistDetailResponse(
|
||||
id=artist.id,
|
||||
name=artist.name,
|
||||
weblink=artist.weblink,
|
||||
works=works
|
||||
name=str(artist.name),
|
||||
weblink=str(artist.weblink),
|
||||
comic_works=comic_works,
|
||||
issue_works=issue_works,
|
||||
)
|
||||
return response
|
||||
|
||||
@@ -2,6 +2,7 @@ from typing import List
|
||||
from pydantic import BaseModel
|
||||
|
||||
from src.schema.comics.comic import ComicResponse
|
||||
from src.schema.comics.issue import IssueDetailsResponse
|
||||
from src.schema.comics.worktype import WorktypeResponse
|
||||
|
||||
|
||||
@@ -9,8 +10,13 @@ class ArtistWorktypeComicResponse(BaseModel):
|
||||
worktype: WorktypeResponse
|
||||
comics: List[ComicResponse]
|
||||
|
||||
class ArtistWorktypeIssueResponse(BaseModel):
|
||||
worktype: WorktypeResponse
|
||||
issues: List[IssueDetailsResponse]
|
||||
|
||||
class ArtistDetailResponse(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
weblink: str
|
||||
works: List[ArtistWorktypeComicResponse]
|
||||
comic_works: List[ArtistWorktypeComicResponse]
|
||||
issue_works: List[ArtistWorktypeIssueResponse]
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
from src.schema.comics.comic import ComicResponse
|
||||
from src.schema.comics.volume import VolumeResponse
|
||||
|
||||
|
||||
class IssueDetailsResponse(BaseModel):
|
||||
id: str
|
||||
issue_number: str
|
||||
in_stock: bool
|
||||
is_read: bool
|
||||
comic_id: str
|
||||
volume_id: str | None
|
||||
comic: ComicResponse
|
||||
volume: VolumeResponse | None
|
||||
|
||||
Reference in New Issue
Block a user