mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: init chapters, coursechapters. fix courses
This commit is contained in:
parent
eca819b896
commit
4fcc8aa77c
8 changed files with 151 additions and 36 deletions
|
|
@ -50,7 +50,7 @@ class ActivityCreate(ActivityBase):
|
|||
order: int
|
||||
org_id: int = Field(default=None, foreign_key="organization.id")
|
||||
course_id: int = Field(default=None, foreign_key="course.id")
|
||||
chapter_id : int
|
||||
chapter_id: int
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from enum import Enum
|
|||
class ChapterActivity(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
order: int
|
||||
chapter_id: int = Field(default=None, foreign_key="chapter.id")
|
||||
chapter_id: int = Field(default=None, foreign_key="chapter.id", )
|
||||
activity_id: int = Field(default=None, foreign_key="activity.id")
|
||||
course_id : int = Field(default=None, foreign_key="course.id")
|
||||
org_id : int = Field(default=None, foreign_key="organization.id")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from typing import Optional
|
||||
from typing import List, Optional
|
||||
from pydantic import BaseModel
|
||||
from sqlmodel import Field, SQLModel
|
||||
from src.db.activities import Activity, ActivityRead, ActivityUpdate
|
||||
|
||||
|
||||
class ChapterBase(SQLModel):
|
||||
|
|
@ -7,24 +9,55 @@ class ChapterBase(SQLModel):
|
|||
description: Optional[str] = ""
|
||||
thumbnail_image: Optional[str] = ""
|
||||
org_id: int = Field(default=None, foreign_key="organization.id")
|
||||
course_id: int = Field(default=None, foreign_key="course.id")
|
||||
creation_date: str
|
||||
update_date: str
|
||||
|
||||
|
||||
class Chapter(ChapterBase, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
chapter_uuid: str
|
||||
creation_date: str
|
||||
update_date: str
|
||||
chapter_uuid: str = ""
|
||||
creation_date: str = ""
|
||||
update_date: str = ""
|
||||
|
||||
|
||||
class ChapterCreate(ChapterBase):
|
||||
# referenced order here will be ignored and just used for validation
|
||||
# used order will be the next available.
|
||||
pass
|
||||
|
||||
|
||||
class ChapterUpdate(ChapterBase):
|
||||
chapter_id: int
|
||||
name: Optional[str]
|
||||
description: Optional[str]
|
||||
thumbnail_image: Optional[str]
|
||||
|
||||
|
||||
class ChapterRead(ChapterBase):
|
||||
id: int
|
||||
activities: List[ActivityRead]
|
||||
chapter_uuid: str
|
||||
creation_date: str
|
||||
update_date: str
|
||||
pass
|
||||
|
||||
|
||||
class ActivityOrder(BaseModel):
|
||||
activity_id: int
|
||||
|
||||
|
||||
class ChapterOrder(BaseModel):
|
||||
chapter_id: int
|
||||
activities_order_by_ids: List[ActivityOrder]
|
||||
|
||||
|
||||
class ChapterUpdateOrder(BaseModel):
|
||||
chapter_order_by_ids: List[ChapterOrder]
|
||||
|
||||
|
||||
class DepreceatedChaptersRead(BaseModel):
|
||||
chapter_order: list[str]
|
||||
chapters: List[ChapterRead]
|
||||
activities: List[ActivityRead]
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
from typing import Optional
|
||||
from typing import List, Optional
|
||||
from sqlmodel import Field, SQLModel
|
||||
|
||||
from src.db.chapters import ChapterRead
|
||||
|
||||
|
||||
class CourseBase(SQLModel):
|
||||
name: str
|
||||
|
|
@ -41,3 +43,13 @@ class CourseRead(CourseBase):
|
|||
creation_date: str
|
||||
update_date: str
|
||||
pass
|
||||
|
||||
|
||||
class FullCourseRead(CourseBase):
|
||||
id: int
|
||||
course_uuid: str
|
||||
creation_date: str
|
||||
update_date: str
|
||||
# Chapters, Activities
|
||||
chapters: List[ChapterRead]
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue