Add frontend project structure with React/TypeScript setup
This commit is contained in:
1 parent
c7abb73c66
commit
6914a6855c
58 files changed
+9056
-236
No files matched your search
@@ -0,0 +1,9 @@
|
||||
"""
|
||||
Database models for Newzy application.
|
||||
"""
|
||||
|
||||
from .article import Article
|
||||
from .author import Author
|
||||
from .category import Category
|
||||
|
||||
__all__ = ["Article", "Author", "Category"]
|
||||
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
Article model for Newzy application.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from db.session import Base
|
||||
|
||||
|
||||
class Article(Base):
|
||||
"""Represents a news article."""
|
||||
|
||||
__tablename__ = "articles"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
||||
title: Mapped[str] = mapped_column(String(200), unique=True, nullable=False)
|
||||
content: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
author_id: Mapped[int] = mapped_column(ForeignKey("authors.id"), nullable=False)
|
||||
category_id: Mapped[int] = mapped_column(ForeignKey("categories.id"), nullable=False)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
published: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
|
||||
# Relationships
|
||||
author: Mapped["Author"] = relationship("Author", back_populates="articles")
|
||||
category: Mapped["Category"] = relationship("Category", back_populates="articles")
|
||||
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
Author model for Newzy application.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import ForeignKey, Integer, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from db.session import Base
|
||||
|
||||
|
||||
class Author(Base):
|
||||
"""Represents an article author."""
|
||||
|
||||
__tablename__ = "authors"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
||||
name: Mapped[str] = mapped_column(String(100), unique=True, nullable=False)
|
||||
email: Mapped[str] = mapped_column(String(255), unique=True, nullable=False)
|
||||
bio: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Relationships
|
||||
articles: Mapped[list["Article"]] = relationship("Article", back_populates="author")
|
||||
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
Category model for Newzy application.
|
||||
"""
|
||||
|
||||
from sqlalchemy import ForeignKey, Integer, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from db.session import Base
|
||||
|
||||
|
||||
class Category(Base):
|
||||
"""Represents a content category."""
|
||||
|
||||
__tablename__ = "categories"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
||||
name: Mapped[str] = mapped_column(String(100), unique=True, nullable=False)
|
||||
slug: Mapped[str] = mapped_column(String(100), unique=True, nullable=False)
|
||||
|
||||
# Relationships
|
||||
articles: Mapped[list["Article"]] = relationship("Article", back_populates="category")
|
||||
Reference in new issue
Block a user