-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2306635
commit b938c90
Showing
24 changed files
with
292 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from server.seedwork.domain.entities import Entity | ||
|
||
from ..organizations.types import Siret | ||
|
||
|
||
class Catalog(Entity): | ||
organization_siret: Siret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import datetime as dt | ||
from typing import TYPE_CHECKING, List | ||
|
||
from sqlalchemy import CHAR, Column, DateTime, ForeignKey, func | ||
from sqlalchemy.orm import relationship | ||
|
||
from server.domain.organizations.types import Siret | ||
|
||
from ..database import Base | ||
|
||
if TYPE_CHECKING: | ||
from ..catalog_records.repositories import CatalogRecordModel | ||
from ..organizations.models import OrganizationModel | ||
|
||
|
||
class CatalogModel(Base): | ||
__tablename__ = "catalog" | ||
|
||
organization_siret: Siret = Column( | ||
CHAR(14), | ||
ForeignKey("organization.siret"), | ||
primary_key=True, | ||
) | ||
organization: "OrganizationModel" = relationship( | ||
"OrganizationModel", | ||
back_populates="catalog", | ||
) | ||
created_at: dt.datetime = Column( | ||
DateTime(timezone=True), | ||
server_default=func.clock_timestamp(), | ||
nullable=False, | ||
) | ||
|
||
catalog_records: List["CatalogRecordModel"] = relationship( | ||
"CatalogRecordModel", | ||
back_populates="catalog", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from server.seedwork.application.modules import Module | ||
|
||
from . import models # noqa # Trigger SQLAlchemy table discovery. | ||
|
||
|
||
class CatalogsModule(Module): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
from typing import TYPE_CHECKING, List | ||
|
||
from sqlalchemy import CHAR, Column, String | ||
from sqlalchemy.orm import relationship | ||
|
||
from server.domain.organizations.types import Siret | ||
|
||
from ..database import Base | ||
|
||
if TYPE_CHECKING: | ||
from ..auth.repositories import UserModel | ||
from ..catalogs.models import CatalogModel | ||
|
||
|
||
class OrganizationModel(Base): | ||
__tablename__ = "organization" | ||
|
||
siret: Siret = Column(CHAR(14), primary_key=True) | ||
name: str = Column(String(), nullable=False) | ||
|
||
catalog: "CatalogModel" = relationship( | ||
"CatalogModel", | ||
back_populates="organization", | ||
uselist=False, | ||
) | ||
|
||
users: List["UserModel"] = relationship( | ||
"UserModel", | ||
back_populates="organization", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""add-catalog | ||
Revision ID: 4e40358ad25c | ||
Revises: da164fd0fa6f | ||
Create Date: 2022-07-19 15:03:34.512545 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "4e40358ad25c" | ||
down_revision = "da164fd0fa6f" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
"catalog", | ||
sa.Column("organization_siret", sa.CHAR(length=14), nullable=False), | ||
sa.Column( | ||
"created_at", | ||
sa.DateTime(timezone=True), | ||
server_default=sa.text("clock_timestamp()"), | ||
nullable=False, | ||
), | ||
sa.ForeignKeyConstraint(["organization_siret"], ["organization.siret"]), | ||
sa.PrimaryKeyConstraint("organization_siret"), | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table("catalog") |
Oops, something went wrong.