Esempio n. 1
0
class User(UserBase, table=True):
    __tablename__ = "user"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    hashed_password: Optional[str] = Field(
        sa_column=Column(Text, nullable=False))
    is_active: Optional[bool] = Field(default=False)
    newsletter: Optional[bool] = Field(default=False)
    occupation: Optional[str] = Field(sa_column=Column(Text, nullable=True))
    domain: Optional[str] = Field(sa_column=Column(Text, nullable=True))
    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")))
    organization_id: int = Field(sa_column=Column(
        Integer,
        ForeignKey("customer.organization.id", ondelete="CASCADE"),
        nullable=False))
    active_study_area_id: int = Field(sa_column=Column(
        Integer, ForeignKey("basic.study_area.id"), nullable=False))
    language_preference: str = Field(sa_column=Column(Text, nullable=False))

    organization: "Organization" = Relationship(back_populates="users")
    roles: List["Role"] = Relationship(back_populates="users",
                                       link_model=UserRole)
    scenarios: List["Scenario"] = Relationship(back_populates="user")
    study_areas: List["StudyArea"] = Relationship(back_populates="users",
                                                  link_model=UserStudyArea)
    data_uploads: List["DataUpload"] = Relationship(back_populates="user")
    isochrone_calculations: List["IsochroneCalculation"] = Relationship(
        back_populates="user")
    user_customizations: List["UserCustomization"] = Relationship(
        back_populates="users")
    opportunity_user_configs: List["OpportunityUserConfig"] = Relationship(
        back_populates="user")
Esempio n. 2
0
class UserBase(BaseORMSchema):
    username: str = Field(nullable=False)
    gravatar: str = Field(
        "",
        nullable=False,
        sa_column_kwargs={"server_default": ""},
    )
Esempio n. 3
0
class DomainBase(URLORMSchema):
    name: NoneEmptyLongStr = Field(
        index=True,
        nullable=False,
        description="displayed name of the domain",
    )
    gravatar: LongStr = Field(
        "",
        nullable=False,
        sa_column_kwargs={"server_default": ""},
        description="gravatar url of the domain",
    )
    bulletin: LongText = Field(
        "",
        nullable=False,
        sa_column_kwargs={"server_default": ""},
        description="bulletin of the domain",
    )
    hidden: bool = Field(
        True,
        nullable=False,
        sa_column_kwargs={"server_default": "true"},
        description="is the domain hidden",
    )
    group: LongStr = Field(
        "",
        nullable=False,
        sa_column_kwargs={"server_default": ""},
        description="group name of the domain",
    )
Esempio n. 4
0
class BaseModel(SQLModel, table=False):

    id: str = Field(default_factory=uuid, primary_key=True)
    created_at: Optional[datetime] = Field(
        sa_column=Column(DateTime, default=now, nullable=False))
    updated_at: Optional[datetime] = Field(
        sa_column=Column(DateTime, default=now, onupdate=now))
Esempio n. 5
0
class Member(SQLModel):
    id: Optional[int] = Field(description="ID of member", )
    player_req: Optional[int] = Field(
        None,
        gt=0,
        alias="playerReq",
        description="Required number of players for member to play",
    )
    party_id: int = Field(
        gt=0,
        alias="partyId",
        description="ID of party",
    )
    player_id: int = Field(
        gt=0,
        alias="playerId",
        description="ID of player",
    )
    role_id: Optional[int] = Field(
        None,
        gt=0,
        alias="roleId",
        description="ID of role",
    )

    party: "Party"
    player: "Player"
    role: Optional["Role"] = None

    class Config:
        orm_mode = True
        allow_population_by_field_name = True
Esempio n. 6
0
class IsochroneCalculation(SQLModel, table=True):
    __tablename__ = "isochrone_calculation"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    calculation_type: str = Field(sa_column=Column(Text, nullable=False))
    starting_point: str = Field(sa_column=Column(Text, nullable=False))
    routing_profile: str = Field(sa_column=Column(Text, nullable=False))
    speed: float = Field(sa_column=Column(Float(53), nullable=False))
    modus: str = Field(sa_column=Column(Text, nullable=False))
    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")))
    parent_id: Optional[int] = Field(sa_column=Column(
        Integer,
        ForeignKey("customer.isochrone_calculation.id", ondelete="CASCADE")))
    scenario_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE")))
    user_id: int = Field(
        sa_column=Column(Integer,
                         ForeignKey("customer.user.id", ondelete="CASCADE"),
                         nullable=False))

    scenario: Optional["Scenario"] = Relationship(
        back_populates="isochrone_calculations")
    user: "******" = Relationship(back_populates="isochrone_calculations")
    isochrone_features: "IsochroneFeature" = Relationship(
        back_populates="isochrone_calculation")
Esempio n. 7
0
class Server(SQLModel, table=True):
    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, unique=True),
        description="ID of server",
        gt=0,
        le=INTEGER_SIZE,
    )
    name: str = Field(
        sa_column=Column(String(255), nullable=False),
        description="Name of server from Discord",
    )
    icon: Optional[str] = Field(
        sa_column=Column(String(64)), description="Icon of server from Discord"
    )
    discord_id: str = Field(
        sa_column=Column(String(64), nullable=False, unique=True),
        alias="discordId",
        description="Discord ID of server",
    )
    channels: List["Channel"] = Relationship(
        sa_relationship=relationship(
            "Channel", back_populates="server", cascade="all, delete-orphan"
        )
    )
    players: List["Player"] = Relationship(
        sa_relationship=relationship(
            "Player", secondary=player_server_association, back_populates="servers"
        )
    )

    class Config:
        orm_mode = True
        allow_population_by_field_name = True
Esempio n. 8
0
class Video(VideoBase, table=True):
    user_id: uuid.UUID = Field(foreign_key='user.id', nullable=False, description='User primary key')
    user: User = Relationship(back_populates='videos')
    thumbnail_uri: Optional[str] = Field(default=None, nullable=True)

    tags: List[Tag] = Relationship(back_populates='videos', link_model=VideoTagLink)
    likes: List[User] = Relationship(back_populates='liked_videos', link_model=VideoLikeLink)
Esempio n. 9
0
class Ecoindex(SQLModel):
    grade: Optional[str] = Field(
        default=None,
        title="Ecoindex grade",
        description=
        "Is the corresponding ecoindex grade of the page (from A to G)",
    )
    score: Optional[float] = Field(
        default=None,
        title="Ecoindex score",
        description=
        "Is the corresponding ecoindex score of the page (0 to 100)",
        ge=0,
        le=100,
    )
    ges: Optional[float] = Field(
        default=None,
        title="Ecoindex GES equivalent",
        description=
        "Is the equivalent of greenhouse gases emission (in `gCO2e`) of the page",
        ge=0,
    )
    water: Optional[float] = Field(
        default=None,
        title="Ecoindex Water equivalent",
        description="Is the equivalent water consumption (in `cl`) of the page",
        ge=0,
    )
Esempio n. 10
0
class ProblemConfigBase(BaseORMSchema):
    commit_message: str = Field(
        "", nullable=False, sa_column_kwargs={"server_default": ""}
    )
    data_version: int = Field(
        2, nullable=False, sa_column_kwargs={"server_default": "2"}
    )
Esempio n. 11
0
class ProblemConfig(ProblemConfigBase, IDMixin):
    languages: List[str] = Field(
        [],
        sa_column=Column(JSON, nullable=False, server_default="[]"),
    )
    commit_id: str = Field("", nullable=False, sa_column_kwargs={"server_default": ""})
    committer_id: Optional[UUID] = None
Esempio n. 12
0
class Channel(SQLModel, table=True):
    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, unique=True),
        description="ID of channel",
        gt=0,
        le=INTEGER_SIZE,
    )
    name: str = Field(
        sa_column=Column(String(255), nullable=False),
        description="Name of channel from Discord",
    )
    discord_id: str = Field(
        sa_column=Column(String(64), nullable=False, unique=True),
        alias="discordId",
        description="Discord ID of channel",
    )
    server_id: int = Field(
        sa_column=Column(Integer, ForeignKey("server.id"), nullable=False),
        alias="serverId",
        description="ID of server associated with",
        gt=0,
        le=INTEGER_SIZE,
    )
    server: "Server" = Relationship()

    class Config:
        orm_mode = True
        allow_population_by_field_name = True
Esempio n. 13
0
class Role(SQLModel, table=True):
    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, unique=True),
        description="ID of role",
        gt=0,
        le=INTEGER_SIZE,
    )
    party_id: Optional[int] = Field(
        sa_column=Column(Integer, ForeignKey("party.id")),
        gt=0,
        le=INTEGER_SIZE,
        alias="partyId",
        description="ID of party",
    )
    name: Optional[str] = Field(sa_column=Column(String(64)),
                                description="Name of role")
    max_players: Optional[int] = Field(
        sa_column=Column(Integer),
        gt=0,
        le=INTEGER_SIZE,
        alias="maxPlayers",
        description="Maximum number of players of role",
    )

    party: Optional["Party"] = Relationship(
        sa_relationship=relationship("Party", back_populates="roles"))

    class Config:
        orm_mode = True
        allow_population_by_field_name = True
Esempio n. 14
0
class MemberUpdate(SQLModel):
    player_req: Optional[int] = Field(
        None,
        gt=0,
        le=INTEGER_SIZE,
        alias="playerReq",
        description="Required number of players for member to play",
    )
    party_id: Optional[int] = Field(None,
                                    gt=0,
                                    le=INTEGER_SIZE,
                                    alias="partyId",
                                    description="ID of party")
    player_id: Optional[int] = Field(None,
                                     gt=0,
                                     le=INTEGER_SIZE,
                                     alias="playerId",
                                     description="ID of player")
    role_id: Optional[int] = Field(None,
                                   gt=0,
                                   le=INTEGER_SIZE,
                                   alias="roleId",
                                   description="ID of role")

    class Config:
        orm_mode = True
        allow_population_by_field_name = True
Esempio n. 15
0
class ResourceTopicLink(SQLModel, table=True):
    resource_id: Optional[int] = Field(
        default=None, foreign_key="resource.id", primary_key=True
    )
    topic_id: Optional[int] = Field(
        default=None, foreign_key="topic.id", primary_key=True
    )
Esempio n. 16
0
class Hero(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    secret_name: str
    age: Optional[int] = None

    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
    team: Optional[Team] = Relationship(back_populates="heroes")
Esempio n. 17
0
class ServerCreate(SQLModel):
    name: str = Field(description="Name of server from Discord")
    icon: Optional[str] = Field(None, description="Icon of server from Discord")
    discord_id: str = Field(alias="discordId", description="Discord ID of server")

    class Config:
        orm_mode = True
        allow_population_by_field_name = True
Esempio n. 18
0
class Block(SQLModel, table=True):
    id: int = Field(primary_key=True)
    chain_id: int
    height: int
    timestamp: datetime = Field(sa_column=Column(DateTime(timezone=True)))
    snapshot: Optional[datetime] = Field(sa_column=Column(DateTime(timezone=True)))

    snapshots: List["Snapshot"] = Relationship(back_populates="block")
Esempio n. 19
0
class AccountBase(SQLModel, registry=user_registry):
    title: str
    description: str = None
    balance: float = 0
    currency: str = Field(max_length=5)
    account_group: uuid.UUID = Field(foreign_key="account_group.id")
    cc_settlement_date: datetime.date = None
    cc_payment_date: datetime.date = None
Esempio n. 20
0
class Snapshot(SQLModel, table=True):
    id: int = Field(primary_key=True)
    product: str
    name: str
    assets: float

    block_id: int = Field(foreign_key="block.id")
    block: Block = Relationship(back_populates="snapshots")
Esempio n. 21
0
class StyleLibrary(SQLModel, table=True):
    __tablename__ = "style_library"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True))
    name: str = Field(sa_column=Column(Text(), nullable=False, index=True))
    style: dict = Field(sa_column=Column(JSONB))
    translation: dict = Field(sa_column=Column(JSONB))
    layer_libraries: "LayerLibrary" = Relationship(back_populates="style_library")
Esempio n. 22
0
class ServerShort(SQLModel):
    id: int = Field(description="ID of server", gt=0, le=INTEGER_SIZE)
    name: str = Field(description="Name of server from Discord")
    icon: Optional[str] = Field(None, description="Icon of server from Discord")
    discord_id: str = Field(alias="discordId", description="Discord ID of server")

    class Config:
        orm_mode = True
        allow_population_by_field_name = True
Esempio n. 23
0
class Role(SQLModel, table=True):
    __tablename__ = "role"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True))
    name: str = Field(sa_column=Column(Text, nullable=False))

    customizations: List["Customization"] = Relationship(back_populates="role")
    users: List["User"] = Relationship(back_populates="roles", link_model=UserRole)
Esempio n. 24
0
class Resource(ResourceBase, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    votes: Optional[int] = Field(default=0)
    broken: Optional[int] = Field(default=0)

    user: User = Relationship(back_populates="resources")
    topics: List[Topic] = Relationship(
        back_populates="resources", link_model=ResourceTopicLink
    )
Esempio n. 25
0
class ProblemSet(ProblemSetBase, DomainMixin, IDMixin):
    num_submit: int = Field(0,
                            nullable=False,
                            sa_column_kwargs={"server_default": "0"})
    num_accept: int = Field(0,
                            nullable=False,
                            sa_column_kwargs={"server_default": "0"})

    owner_id: Optional[UUID] = None
Esempio n. 26
0
class PlayerCreate(SQLModel):
    discord_id: str = Field(alias="discordId", description="ID on discord")
    name: str = Field(description="Discord username of player")
    discriminator: str = Field(description="Discord user discriminator")
    icon: Optional[str] = Field(None, description="Discord icon hash")

    class Config:
        orm_mode = True
        allow_population_by_field_name = True
Esempio n. 27
0
class Population(PopulationBase, table=True):
    __tablename__ = "population"
    __table_args__ = {"schema": "basic"}

    demography: Optional[dict] = Field(sa_column=Column(JSONB))
    building_id: Optional[int] = Field(sa_column=Column(
        Integer,
        ForeignKey("basic.building.id", ondelete="CASCADE"),
        index=True), )
    building: Optional["Building"] = Relationship(back_populates="populations")
Esempio n. 28
0
class CourseBase(SQLModel):
    name: str
    code: str
    description: Optional[str]
    primary_resource: Optional[str]
    status: str
    due: datetime.date
    cover: Dict = Field(sa_column=Column(JSON), default={"color": "#222222"})
    syllabus: List[Dict] = Field(sa_column=Column(JSON))
    user_id: Optional[int] = Field(default=None, foreign_key="user.id")
Esempio n. 29
0
class PlayerShort(SQLModel):
    id: int = Field(description="ID of player", gt=0, le=INTEGER_SIZE)
    discord_id: str = Field(alias="discordId", description="ID on discord")
    name: str = Field(description="Discord username of player")
    discriminator: str = Field(description="Discord user discriminator")
    icon: Optional[str] = Field(None, description="Discord icon hash")

    class Config:
        orm_mode = True
        allow_population_by_field_name = True
Esempio n. 30
0
class UserRole(SQLModel, table=True):
    __tablename__ = "user_role"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    user_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("customer.user.id"), nullable=False, index=True))
    role_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("customer.role.id"), nullable=False, index=True))