Switch all datetimes to dates except added
This commit is contained in:
@@ -393,7 +393,7 @@ class BookRequestSchema(BaseModel):
|
|||||||
genres: list[str] = []
|
genres: list[str] = []
|
||||||
publisher: str = ""
|
publisher: str = ""
|
||||||
owner_id: Optional[int] = None
|
owner_id: Optional[int] = None
|
||||||
bought: datetime = Field(default_factory=datetime.now)
|
bought: date = Field(default_factory=datetime.today)
|
||||||
location: str = "billy salon"
|
location: str = "billy salon"
|
||||||
loaned_to: str = ""
|
loaned_to: str = ""
|
||||||
loaned_from: str = ""
|
loaned_from: str = ""
|
||||||
@@ -475,8 +475,8 @@ def readings_new(id: int) -> str:
|
|||||||
|
|
||||||
|
|
||||||
class ReadingRequestSchema(BaseModel):
|
class ReadingRequestSchema(BaseModel):
|
||||||
start_date: datetime = Field(default_factory=datetime.now)
|
start_date: date = Field(default_factory=datetime.today)
|
||||||
end_date: Optional[datetime] = None
|
end_date: Optional[date] = None
|
||||||
finished: bool = False
|
finished: bool = False
|
||||||
dropped: bool = False
|
dropped: bool = False
|
||||||
rating: Optional[int] = None
|
rating: Optional[int] = None
|
||||||
@@ -521,7 +521,7 @@ def reading(book_id: int, reading_id: int) -> str:
|
|||||||
if reading_req.end_date is None and (
|
if reading_req.end_date is None and (
|
||||||
reading_req.finished or reading_req.dropped
|
reading_req.finished or reading_req.dropped
|
||||||
):
|
):
|
||||||
reading_req.end_date = datetime.now()
|
reading_req.end_date = datetime.today()
|
||||||
for key, value in reading_req.model_dump().items():
|
for key, value in reading_req.model_dump().items():
|
||||||
setattr(reading, key, value)
|
setattr(reading, key, value)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Book(db.Model): # type: ignore[name-defined]
|
|||||||
genres: Mapped[list[str]] = mapped_column(JSON, default=list)
|
genres: Mapped[list[str]] = mapped_column(JSON, default=list)
|
||||||
publisher: Mapped[str] = mapped_column(default="")
|
publisher: Mapped[str] = mapped_column(default="")
|
||||||
owner_id: Mapped[Optional[int]] = mapped_column(ForeignKey("user.id"))
|
owner_id: Mapped[Optional[int]] = mapped_column(ForeignKey("user.id"))
|
||||||
bought: Mapped[datetime] = mapped_column(default=datetime.now)
|
bought: Mapped[date] = mapped_column(default=datetime.today)
|
||||||
location: Mapped[str] = mapped_column(default="billy salon")
|
location: Mapped[str] = mapped_column(default="billy salon")
|
||||||
loaned_to: Mapped[str] = mapped_column(default="")
|
loaned_to: Mapped[str] = mapped_column(default="")
|
||||||
loaned_from: Mapped[str] = mapped_column(default="")
|
loaned_from: Mapped[str] = mapped_column(default="")
|
||||||
@@ -44,7 +44,7 @@ class Book(db.Model): # type: ignore[name-defined]
|
|||||||
|
|
||||||
class Reading(db.Model): # type: ignore[name-defined]
|
class Reading(db.Model): # type: ignore[name-defined]
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
start_date: Mapped[date] = mapped_column(default=datetime.now)
|
start_date: Mapped[date] = mapped_column(default=datetime.today)
|
||||||
end_date: Mapped[Optional[date]] = mapped_column(default=None)
|
end_date: Mapped[Optional[date]] = mapped_column(default=None)
|
||||||
finished: Mapped[bool] = mapped_column(default=False)
|
finished: Mapped[bool] = mapped_column(default=False)
|
||||||
dropped: Mapped[bool] = mapped_column(default=False)
|
dropped: Mapped[bool] = mapped_column(default=False)
|
||||||
@@ -58,7 +58,7 @@ class Reading(db.Model): # type: ignore[name-defined]
|
|||||||
|
|
||||||
class Wishlist(db.Model): # type: ignore[name-defined]
|
class Wishlist(db.Model): # type: ignore[name-defined]
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
wishlisted: Mapped[date] = mapped_column(default=datetime.now)
|
wishlisted: Mapped[date] = mapped_column(default=datetime.today)
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("user.id"))
|
user_id: Mapped[int] = mapped_column(ForeignKey("user.id"))
|
||||||
book_id: Mapped[int] = mapped_column(ForeignKey("book.id"))
|
book_id: Mapped[int] = mapped_column(ForeignKey("book.id"))
|
||||||
user: Mapped["User"] = relationship(back_populates="wishes")
|
user: Mapped["User"] = relationship(back_populates="wishes")
|
||||||
|
|||||||
Reference in New Issue
Block a user