generated from MinBZK/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
8015d9a
commit eba1ff8
Showing
8 changed files
with
102 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
from .algorithm import Algorithm | ||
from .authorization import Authorization | ||
from .organization import Organization | ||
from .role import Role | ||
from .rule import Rule | ||
from .task import Task | ||
from .user import User | ||
|
||
__all__ = ["Algorithm", "Organization", "Task", "User"] | ||
__all__ = ["Algorithm", "Authorization", "Organization", "Role", "Rule", "Task", "User"] |
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,16 @@ | ||
from sqlalchemy import ForeignKey | ||
from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
|
||
from amt.models.base import Base | ||
|
||
|
||
class Authorization(Base): | ||
__tablename__ = "authorization" | ||
|
||
id: Mapped[int] = mapped_column(primary_key=True) | ||
user_id: Mapped[int] = mapped_column(ForeignKey("user.id")) | ||
user: Mapped["User"] = relationship(back_populates="authorizations") # pyright: ignore [reportUndefinedVariable, reportUnknownVariableType] #noqa | ||
role_id: Mapped[int] = mapped_column(ForeignKey("role.id")) | ||
role: Mapped["Role"] = relationship(back_populates="authorizations") # pyright: ignore [reportUndefinedVariable, reportUnknownVariableType] #noqa | ||
type: Mapped[str] | ||
type_id: Mapped[int] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from sqlalchemy import String | ||
from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
|
||
from amt.models import Authorization | ||
from amt.models.base import Base | ||
from amt.models.rule import Rule | ||
|
||
|
||
class Role(Base): | ||
__tablename__ = "role" | ||
|
||
id: Mapped[int] = mapped_column(primary_key=True) | ||
name: Mapped[str] = mapped_column(String, nullable=False) | ||
rules: Mapped[list["Rule"]] = relationship(back_populates="role") | ||
authorizations: Mapped[list["Authorization"]] = relationship(back_populates="role") |
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,15 @@ | ||
from sqlalchemy import ForeignKey, String | ||
from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
from sqlalchemy.types import JSON | ||
|
||
from amt.models.base import Base | ||
|
||
|
||
class Rule(Base): | ||
__tablename__ = "rule" | ||
|
||
id: Mapped[int] = mapped_column(primary_key=True) | ||
resource: Mapped[str] = mapped_column(String, nullable=False) | ||
verbs: Mapped[list[str]] = mapped_column(JSON, default=list) | ||
role_id: Mapped[int] = mapped_column(ForeignKey("role.id")) | ||
role: Mapped["Role"] = relationship(back_populates="rule") # pyright: ignore[reportUnknownVariableType, reportUndefinedVariable] #noqa |
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