maleo-identity 0.0.91__py3-none-any.whl → 0.0.93__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of maleo-identity might be problematic. Click here for more details.

Files changed (109) hide show
  1. maleo/identity/constants/organization.py +15 -8
  2. maleo/identity/constants/organization_registration_code.py +10 -7
  3. maleo/identity/constants/user.py +11 -13
  4. maleo/identity/constants/user_profile.py +9 -12
  5. maleo/identity/enums/organization.py +4 -4
  6. maleo/identity/enums/organization_registration_code.py +5 -0
  7. maleo/identity/enums/user.py +4 -8
  8. maleo/identity/enums/user_profile.py +4 -10
  9. maleo/identity/mixins/organization.py +10 -8
  10. maleo/identity/mixins/organization_registration_code.py +8 -11
  11. maleo/identity/mixins/user.py +17 -31
  12. maleo/identity/mixins/user_profile.py +37 -67
  13. maleo/identity/models.py +317 -0
  14. maleo/identity/schemas/common.py +257 -0
  15. maleo/identity/schemas/organization.py +162 -0
  16. maleo/identity/schemas/organization_registration_code.py +162 -0
  17. maleo/identity/schemas/user.py +181 -0
  18. maleo/identity/schemas/user_profile.py +212 -0
  19. maleo/identity/types/{base/organization_registration_code.py → user_profile.py} +2 -1
  20. maleo_identity-0.0.93.dist-info/METADATA +118 -0
  21. maleo_identity-0.0.93.dist-info/RECORD +33 -0
  22. maleo_identity-0.0.93.dist-info/licenses/LICENSE +57 -0
  23. maleo/identity/client/__init__.py +0 -0
  24. maleo/identity/client/manager.py +0 -157
  25. maleo/identity/client/services/__init__.py +0 -0
  26. maleo/identity/client/services/organization.py +0 -1944
  27. maleo/identity/client/services/organization_registration_code.py +0 -470
  28. maleo/identity/client/services/organization_role.py +0 -276
  29. maleo/identity/client/services/user.py +0 -1559
  30. maleo/identity/client/services/user_organization.py +0 -276
  31. maleo/identity/client/services/user_organization_role.py +0 -278
  32. maleo/identity/client/services/user_profile.py +0 -276
  33. maleo/identity/client/services/user_system_role.py +0 -276
  34. maleo/identity/constants/organization_role.py +0 -35
  35. maleo/identity/constants/user_organization.py +0 -58
  36. maleo/identity/constants/user_organization_role.py +0 -47
  37. maleo/identity/constants/user_system_role.py +0 -16
  38. maleo/identity/db.py +0 -4
  39. maleo/identity/dtos/__init__.py +0 -0
  40. maleo/identity/dtos/configuration.py +0 -15
  41. maleo/identity/dtos/data/__init__.py +0 -0
  42. maleo/identity/dtos/data/organization_registration_code.py +0 -15
  43. maleo/identity/dtos/data/user_profile.py +0 -33
  44. maleo/identity/dtos/data/user_system_role.py +0 -9
  45. maleo/identity/dtos/settings.py +0 -17
  46. maleo/identity/enums/general.py +0 -5
  47. maleo/identity/enums/organization_role.py +0 -7
  48. maleo/identity/enums/user_organization.py +0 -14
  49. maleo/identity/enums/user_organization_role.py +0 -15
  50. maleo/identity/enums/user_system_role.py +0 -5
  51. maleo/identity/mixins/organization_role.py +0 -15
  52. maleo/identity/mixins/user_organization.py +0 -6
  53. maleo/identity/mixins/user_organization_role.py +0 -6
  54. maleo/identity/mixins/user_system_role.py +0 -6
  55. maleo/identity/models/__init__.py +0 -0
  56. maleo/identity/models/organization.py +0 -62
  57. maleo/identity/models/organization_registration_code.py +0 -33
  58. maleo/identity/models/organization_role.py +0 -37
  59. maleo/identity/models/user.py +0 -39
  60. maleo/identity/models/user_organization.py +0 -48
  61. maleo/identity/models/user_organization_role.py +0 -61
  62. maleo/identity/models/user_profile.py +0 -33
  63. maleo/identity/models/user_system_role.py +0 -26
  64. maleo/identity/schemas/data/__init__.py +0 -0
  65. maleo/identity/schemas/data/organization.py +0 -36
  66. maleo/identity/schemas/data/organization_registration_code.py +0 -27
  67. maleo/identity/schemas/data/organization_role.py +0 -32
  68. maleo/identity/schemas/data/user.py +0 -33
  69. maleo/identity/schemas/data/user_organization.py +0 -23
  70. maleo/identity/schemas/data/user_organization_role.py +0 -13
  71. maleo/identity/schemas/data/user_profile.py +0 -59
  72. maleo/identity/schemas/data/user_system_role.py +0 -25
  73. maleo/identity/schemas/metadata/__init__.py +0 -0
  74. maleo/identity/schemas/metadata/user.py +0 -6
  75. maleo/identity/schemas/parameter/__init__.py +0 -0
  76. maleo/identity/schemas/parameter/client/__init__.py +0 -0
  77. maleo/identity/schemas/parameter/client/organization.py +0 -74
  78. maleo/identity/schemas/parameter/client/organization_registration_code.py +0 -24
  79. maleo/identity/schemas/parameter/client/organization_role.py +0 -42
  80. maleo/identity/schemas/parameter/client/user.py +0 -44
  81. maleo/identity/schemas/parameter/client/user_organization.py +0 -62
  82. maleo/identity/schemas/parameter/client/user_organization_role.py +0 -49
  83. maleo/identity/schemas/parameter/client/user_profile.py +0 -28
  84. maleo/identity/schemas/parameter/client/user_system_role.py +0 -43
  85. maleo/identity/schemas/parameter/general/__init__.py +0 -0
  86. maleo/identity/schemas/parameter/general/organization.py +0 -92
  87. maleo/identity/schemas/parameter/general/organization_registration_code.py +0 -86
  88. maleo/identity/schemas/parameter/general/organization_role.py +0 -14
  89. maleo/identity/schemas/parameter/general/user.py +0 -150
  90. maleo/identity/schemas/parameter/general/user_organization.py +0 -18
  91. maleo/identity/schemas/parameter/general/user_organization_role.py +0 -15
  92. maleo/identity/schemas/parameter/general/user_profile.py +0 -119
  93. maleo/identity/schemas/parameter/general/user_system_role.py +0 -30
  94. maleo/identity/schemas/parameter/service/__init__.py +0 -0
  95. maleo/identity/schemas/parameter/service/organization.py +0 -60
  96. maleo/identity/schemas/parameter/service/organization_registration_code.py +0 -24
  97. maleo/identity/schemas/parameter/service/organization_role.py +0 -35
  98. maleo/identity/schemas/parameter/service/user.py +0 -47
  99. maleo/identity/schemas/parameter/service/user_organization_role.py +0 -36
  100. maleo/identity/schemas/parameter/service/user_profile.py +0 -28
  101. maleo/identity/schemas/parameter/service/user_system_role.py +0 -31
  102. maleo/identity/types/base/__init__.py +0 -0
  103. maleo_identity-0.0.91.dist-info/METADATA +0 -39
  104. maleo_identity-0.0.91.dist-info/RECORD +0 -106
  105. /maleo/identity/types/{base/organization.py → organization.py} +0 -0
  106. /maleo/identity/types/{base/user.py → organization_registration_code.py} +0 -0
  107. /maleo/identity/types/{base/user_profile.py → user.py} +0 -0
  108. {maleo_identity-0.0.91.dist-info → maleo_identity-0.0.93.dist-info}/WHEEL +0 -0
  109. {maleo_identity-0.0.91.dist-info → maleo_identity-0.0.93.dist-info}/top_level.txt +0 -0
@@ -1,16 +0,0 @@
1
- from typing import Dict, List
2
- from maleo.soma.schemas.resource import Resource, ResourceIdentifier
3
- from maleo.identity.enums.user_system_role import IncludableField
4
-
5
- EXPANDABLE_FIELDS_DEPENDENCIES_MAP: Dict[IncludableField, List[IncludableField]] = {}
6
-
7
- RESOURCE = Resource(
8
- identifiers=[
9
- ResourceIdentifier(
10
- key="user_system_roles",
11
- name="User System Roles",
12
- url_slug="user-system-roles",
13
- )
14
- ],
15
- details=None,
16
- )
maleo/identity/db.py DELETED
@@ -1,4 +0,0 @@
1
- from maleo.soma.managers.db import create_base
2
-
3
-
4
- MaleoIdentityBase = create_base()
File without changes
@@ -1,15 +0,0 @@
1
- from maleo.soma.dtos.configurations import ConfigurationDTO as BaseConfigurationDTO
2
- from maleo.soma.dtos.configurations.client.maleo import (
3
- MaleoMetadataClientConfigurationMixin,
4
- )
5
- from maleo.soma.dtos.configurations.pubsub.publisher import TopicsConfigurationDTO
6
-
7
-
8
- class MaleoClientsConfiguration(MaleoMetadataClientConfigurationMixin):
9
- pass
10
-
11
-
12
- class ConfigurationDTO(
13
- BaseConfigurationDTO[MaleoClientsConfiguration, TopicsConfigurationDTO, None]
14
- ):
15
- pass
File without changes
@@ -1,15 +0,0 @@
1
- from maleo.soma.mixins.general import OrganizationId
2
- from maleo.identity.mixins.organization_registration_code import (
3
- Code,
4
- MaxUses,
5
- CurrentUses,
6
- )
7
-
8
-
9
- class OrganizationRegistrationCodeDTO(
10
- CurrentUses,
11
- MaxUses,
12
- Code,
13
- OrganizationId,
14
- ):
15
- pass
@@ -1,33 +0,0 @@
1
- from maleo.soma.mixins.general import UserId
2
- from maleo.metadata.schemas.data.gender import OptionalSimpleGenderMixin
3
- from maleo.metadata.schemas.data.blood_type import OptionalSimpleBloodTypeMixin
4
- from maleo.identity.mixins.user_profile import (
5
- IdCard,
6
- LeadingTitle,
7
- FirstName,
8
- MiddleName,
9
- LastName,
10
- EndingTitle,
11
- FullName,
12
- BirthPlace,
13
- BirthDate,
14
- AvatarName,
15
- )
16
-
17
-
18
- class UserProfileDTO(
19
- AvatarName,
20
- OptionalSimpleBloodTypeMixin,
21
- OptionalSimpleGenderMixin,
22
- BirthDate,
23
- BirthPlace,
24
- FullName,
25
- EndingTitle,
26
- LastName,
27
- MiddleName,
28
- FirstName,
29
- LeadingTitle,
30
- IdCard,
31
- UserId,
32
- ):
33
- pass
@@ -1,9 +0,0 @@
1
- from maleo.soma.mixins.general import UserId
2
- from maleo.metadata.schemas.data.system_role import SimpleSystemRoleMixin
3
-
4
-
5
- class UserSystemRoleDTO(
6
- SimpleSystemRoleMixin,
7
- UserId,
8
- ):
9
- pass
@@ -1,17 +0,0 @@
1
- from pydantic import model_validator
2
- from typing import Self
3
- from maleo.soma.dtos.settings import Settings as BaseSettings
4
- from maleo.soma.enums.service import ServiceKey, ServiceName
5
-
6
-
7
- class Settings(BaseSettings):
8
- @model_validator(mode="after")
9
- def validate_service_key_name(self) -> Self:
10
- assert (
11
- self.SERVICE_KEY is ServiceKey.IDENTITY
12
- ), f"'SERVICE_KEY' must be '{ServiceKey.IDENTITY}'"
13
- assert (
14
- self.SERVICE_NAME is ServiceName.IDENTITY
15
- ), f"'SERVICE_NAME' must be '{ServiceName.IDENTITY}'"
16
-
17
- return self
@@ -1,5 +0,0 @@
1
- from enum import StrEnum
2
-
3
-
4
- class ClientControllerType(StrEnum):
5
- HTTP = "http"
@@ -1,7 +0,0 @@
1
- from enum import StrEnum
2
-
3
-
4
- class IncludableField(StrEnum):
5
- ORGANIZATION = "organization"
6
- ORGANIZATION_TYPE = "organization.organization_type"
7
- REGISTRATION_CODE = "organization.registration_code"
@@ -1,14 +0,0 @@
1
- from enum import StrEnum
2
-
3
-
4
- class IncludableField(StrEnum):
5
- USER = "user"
6
- USER_TYPE = "user_type"
7
- SYSTEM_ROLES = "system_roles"
8
- SYSTEM_ROLE_DETAILS = "system_roles.system_role_details"
9
- PROFILE = "profile"
10
- GENDER = "profile.gender"
11
- BLOOD_TYPE = "profile.blood_type"
12
- ORGANIZATION = "organization"
13
- ORGANIZATION_TYPE = "organization.organization_type"
14
- REGISTRATION_CODE = "organization.registration_code"
@@ -1,15 +0,0 @@
1
- from enum import StrEnum
2
-
3
-
4
- class IncludableField(StrEnum):
5
- USER = "user"
6
- USER_TYPE = "user.user_type"
7
- SYSTEM_ROLES = "system_roles"
8
- SYSTEM_ROLE_DETAILS = "system_roles.system_role_details"
9
- PROFILE = "user.profile"
10
- GENDER = "profile.gender"
11
- BLOOD_TYPE = "profile.blood_type"
12
- ORGANIZATION = "organization"
13
- ORGANIZATION_TYPE = "organization.organization_type"
14
- REGISTRATION_CODE = "organization.registration_code"
15
- USER_ORGANIZATION = "user_organization"
@@ -1,5 +0,0 @@
1
- from enum import StrEnum
2
-
3
-
4
- class IncludableField(StrEnum):
5
- SYSTEM_ROLE = "system_role"
@@ -1,15 +0,0 @@
1
- from pydantic import BaseModel, Field
2
- from maleo.soma.mixins.parameter import Include as BaseInclude
3
- from maleo.identity.enums.organization_role import IncludableField
4
-
5
-
6
- class Include(BaseInclude[IncludableField]):
7
- pass
8
-
9
-
10
- class Key(BaseModel):
11
- key: str = Field(..., max_length=50, description="Organization role's key")
12
-
13
-
14
- class Name(BaseModel):
15
- name: str = Field(..., max_length=50, description="Organization role's name")
@@ -1,6 +0,0 @@
1
- from maleo.soma.mixins.parameter import Include as BaseInclude
2
- from maleo.identity.enums.user_organization import IncludableField
3
-
4
-
5
- class Include(BaseInclude[IncludableField]):
6
- pass
@@ -1,6 +0,0 @@
1
- from maleo.soma.mixins.parameter import Include as BaseInclude
2
- from maleo.identity.enums.user_organization_role import IncludableField
3
-
4
-
5
- class Include(BaseInclude[IncludableField]):
6
- pass
@@ -1,6 +0,0 @@
1
- from maleo.soma.mixins.parameter import Include as BaseInclude
2
- from maleo.identity.enums.user_system_role import IncludableField
3
-
4
-
5
- class Include(BaseInclude[IncludableField]):
6
- pass
File without changes
@@ -1,62 +0,0 @@
1
- from sqlalchemy import Column, ForeignKey
2
- from sqlalchemy.orm import relationship
3
- from sqlalchemy.types import Integer, String, Enum, UUID
4
- from uuid import uuid4
5
- from maleo.soma.models.table import DataTable
6
- from maleo.metadata.enums.organization_type import OrganizationType
7
- from maleo.identity.db import MaleoIdentityBase
8
-
9
-
10
- class OrganizationsMixin:
11
- organization_type = Column(
12
- name="organization_type",
13
- type_=Enum(OrganizationType, name="organization_type"),
14
- default=OrganizationType.REGULAR,
15
- nullable=False,
16
- )
17
- parent_id = Column(
18
- "parent_id",
19
- Integer,
20
- ForeignKey("organizations.id", ondelete="SET NULL", onupdate="CASCADE"),
21
- )
22
- key = Column(name="key", type_=String(255), unique=True, nullable=False)
23
- name = Column(name="name", type_=String(255), nullable=False)
24
- secret = Column(
25
- name="secret", type_=UUID, default=uuid4, unique=True, nullable=False
26
- )
27
-
28
-
29
- class OrganizationsTable(OrganizationsMixin, DataTable, MaleoIdentityBase):
30
- __tablename__ = "organizations"
31
- parent = relationship(
32
- "OrganizationsTable",
33
- remote_side="OrganizationsTable.id",
34
- # back_populates="children"
35
- )
36
- # children = relationship(
37
- # "OrganizationsTable",
38
- # back_populates="parent",
39
- # cascade="all",
40
- # lazy="select",
41
- # foreign_keys="[OrganizationsTable.parent_id]",
42
- # order_by="OrganizationsTable.id"
43
- # )
44
- registration_code = relationship(
45
- "OrganizationRegistrationCodesTable",
46
- back_populates="organization",
47
- cascade="all",
48
- lazy="select",
49
- uselist=False,
50
- )
51
- user_organization = relationship(
52
- "UserOrganizationsTable",
53
- back_populates="organization",
54
- cascade="all, delete-orphan",
55
- uselist=False,
56
- )
57
- organization_roles = relationship(
58
- "OrganizationRolesTable",
59
- back_populates="organization",
60
- cascade="all, delete-orphan",
61
- uselist=False,
62
- )
@@ -1,33 +0,0 @@
1
- from sqlalchemy import Column, ForeignKey
2
- from sqlalchemy.orm import relationship
3
- from sqlalchemy.types import Integer, UUID
4
- from uuid import uuid4
5
- from maleo.soma.models.table import DataTable
6
- from maleo.identity.db import MaleoIdentityBase
7
-
8
-
9
- class OrganizationRegistrationCodesMixin:
10
- # Foreign Key OrganizationsTable
11
- organization_id = Column(
12
- Integer,
13
- ForeignKey("organizations.id", ondelete="CASCADE", onupdate="CASCADE"),
14
- unique=True,
15
- nullable=False,
16
- )
17
- code = Column(name="code", type_=UUID, default=uuid4, unique=True, nullable=False)
18
- max_uses = Column(name="max_uses", type_=Integer, nullable=False, default=1)
19
- current_uses = Column(name="current_uses", type_=Integer, nullable=False, default=0)
20
-
21
-
22
- class OrganizationRegistrationCodesTable(
23
- OrganizationRegistrationCodesMixin, DataTable, MaleoIdentityBase
24
- ):
25
- __tablename__ = "organization_registration_codes"
26
-
27
- organization = relationship(
28
- "OrganizationsTable",
29
- back_populates="registration_code",
30
- cascade="all",
31
- lazy="select",
32
- uselist=False,
33
- )
@@ -1,37 +0,0 @@
1
- from sqlalchemy import Column, ForeignKey
2
- from sqlalchemy.orm import relationship
3
- from sqlalchemy.types import Integer, String, Boolean
4
- from maleo.soma.models.table import DataTable
5
- from maleo.identity.db import MaleoIdentityBase
6
-
7
-
8
- class OrganizationRolesMixin:
9
- # Foreign Key OrganizationsTable
10
- organization_id = Column(
11
- Integer,
12
- ForeignKey("organizations.id", ondelete="CASCADE", onupdate="CASCADE"),
13
- nullable=False,
14
- )
15
- is_default = Column(name="is_default", type_=Boolean, nullable=False, default=False)
16
- order = Column(name="order", type_=Integer)
17
- key = Column(name="key", type_=String(50), nullable=False)
18
- name = Column(name="name", type_=String(50), nullable=False)
19
-
20
-
21
- class OrganizationRolesTable(OrganizationRolesMixin, DataTable, MaleoIdentityBase):
22
- __tablename__ = "organization_roles"
23
-
24
- organization = relationship(
25
- "OrganizationsTable",
26
- back_populates="organization_roles",
27
- cascade="all",
28
- lazy="select",
29
- uselist=False,
30
- )
31
-
32
- user_organization_roles = relationship(
33
- "UserOrganizationRolesTable",
34
- back_populates="organization_role",
35
- cascade="all, delete-orphan",
36
- lazy="select",
37
- )
@@ -1,39 +0,0 @@
1
- from sqlalchemy import Column
2
- from sqlalchemy.orm import relationship
3
- from sqlalchemy.types import String, Enum
4
- from maleo.soma.models.table import DataTable
5
- from maleo.metadata.enums.user_type import UserType
6
- from maleo.identity.db import MaleoIdentityBase
7
-
8
-
9
- class UsersMixin:
10
- user_type = Column(
11
- name="user_type",
12
- type_=Enum(UserType, name="user_type"),
13
- default=UserType.REGULAR,
14
- nullable=False,
15
- )
16
- username = Column(name="username", type_=String(50), unique=True, nullable=False)
17
- email = Column(name="email", type_=String(255), unique=True, nullable=False)
18
- phone = Column(name="phone", type_=String(15), nullable=False)
19
- password = Column(name="password", type_=String(255), nullable=False)
20
-
21
-
22
- class UsersTable(UsersMixin, DataTable, MaleoIdentityBase):
23
- __tablename__ = "users"
24
-
25
- profile = relationship(
26
- "UserProfilesTable",
27
- back_populates="user",
28
- uselist=False,
29
- cascade="all, delete-orphan",
30
- )
31
- system_roles = relationship(
32
- "UserSystemRolesTable", back_populates="user", cascade="all, delete-orphan"
33
- )
34
- user_organization = relationship(
35
- "UserOrganizationsTable",
36
- back_populates="user",
37
- cascade="all, delete-orphan",
38
- uselist=False,
39
- )
@@ -1,48 +0,0 @@
1
- from sqlalchemy import Column, ForeignKey
2
- from sqlalchemy.orm import relationship
3
- from sqlalchemy.types import Integer
4
- from maleo.identity.db import MaleoIdentityBase
5
- from maleo.soma.models.table import DataTable
6
-
7
-
8
- class UserOrganizationsMixin:
9
- # Foreign Key UsersTable
10
- user_id = Column(
11
- Integer,
12
- ForeignKey("users.id", ondelete="CASCADE", onupdate="CASCADE"),
13
- nullable=False,
14
- )
15
-
16
- # Foreign Key OrganizationsTable
17
- organization_id = Column(
18
- Integer,
19
- ForeignKey("organizations.id", ondelete="CASCADE", onupdate="CASCADE"),
20
- nullable=False,
21
- )
22
-
23
-
24
- class UserOrganizationsTable(UserOrganizationsMixin, DataTable, MaleoIdentityBase):
25
- __tablename__ = "user_organizations"
26
-
27
- user = relationship(
28
- "UsersTable",
29
- back_populates="user_organization",
30
- cascade="all",
31
- lazy="select",
32
- uselist=False,
33
- )
34
-
35
- organization = relationship(
36
- "OrganizationsTable",
37
- back_populates="user_organization",
38
- cascade="all",
39
- lazy="select",
40
- uselist=False,
41
- )
42
-
43
- user_organization_roles = relationship(
44
- "UserOrganizationRolesTable",
45
- back_populates="user_organization",
46
- cascade="all, delete-orphan",
47
- lazy="select",
48
- )
@@ -1,61 +0,0 @@
1
- from sqlalchemy import Column, ForeignKey
2
- from sqlalchemy.orm import relationship
3
- from sqlalchemy.types import Integer
4
- from maleo.soma.models.table import DataTable
5
- from maleo.identity.db import MaleoIdentityBase
6
-
7
-
8
- class UserOrganizationRolesMixin:
9
- # Foreign Key UserOrganizationsTable
10
- user_organization_id = Column(
11
- Integer,
12
- ForeignKey("user_organizations.id", ondelete="CASCADE", onupdate="CASCADE"),
13
- nullable=False,
14
- )
15
-
16
- # Foreign Key OrganizationRolesTable
17
- organization_role_id = Column(
18
- Integer,
19
- ForeignKey("organization_roles.id", ondelete="CASCADE", onupdate="CASCADE"),
20
- nullable=False,
21
- )
22
-
23
-
24
- class UserOrganizationRolesTable(
25
- UserOrganizationRolesMixin, DataTable, MaleoIdentityBase
26
- ):
27
- __tablename__ = "user_organization_roles"
28
-
29
- user_organization = relationship(
30
- "UserOrganizationsTable",
31
- back_populates="user_organization_roles",
32
- cascade="all",
33
- lazy="select",
34
- uselist=False,
35
- )
36
-
37
- user = relationship(
38
- "UsersTable",
39
- secondary="user_organizations",
40
- primaryjoin="UserOrganizationRolesTable.user_organization_id == UserOrganizationsTable.id",
41
- secondaryjoin="UserOrganizationsTable.user_id == UsersTable.id",
42
- uselist=False,
43
- viewonly=True,
44
- )
45
-
46
- organization = relationship(
47
- "OrganizationsTable",
48
- secondary="user_organizations",
49
- primaryjoin="UserOrganizationRolesTable.user_organization_id == UserOrganizationsTable.id",
50
- secondaryjoin="UserOrganizationsTable.organization_id == OrganizationsTable.id",
51
- uselist=False,
52
- viewonly=True,
53
- )
54
-
55
- organization_role = relationship(
56
- "OrganizationRolesTable",
57
- back_populates="user_organization_roles",
58
- cascade="all",
59
- lazy="select",
60
- uselist=False,
61
- )
@@ -1,33 +0,0 @@
1
- from sqlalchemy import Column, ForeignKey
2
- from sqlalchemy.orm import relationship
3
- from sqlalchemy.types import String, Enum, Integer, Date, Text
4
- from maleo.soma.models.table import DataTable
5
- from maleo.metadata.enums.blood_type import BloodType
6
- from maleo.metadata.enums.gender import Gender
7
- from maleo.identity.db import MaleoIdentityBase
8
-
9
-
10
- class UserProfilesMixin:
11
- # Foreign Key and Relationship to UsersTable
12
- user_id = Column(
13
- Integer,
14
- ForeignKey("users.id", ondelete="CASCADE", onupdate="CASCADE"),
15
- nullable=False,
16
- )
17
- id_card = Column(name="id_card", type_=String(16))
18
- leading_title = Column(name="leading_title", type_=String(25))
19
- first_name = Column(name="first_name", type_=String(50), nullable=False)
20
- middle_name = Column(name="middle_name", type_=String(50))
21
- last_name = Column(name="last_name", type_=String(50), nullable=False)
22
- ending_title = Column(name="ending_title", type_=String(25))
23
- full_name = Column(name="full_name", type_=String(200), nullable=False)
24
- birth_place = Column(name="birth_place", type_=String(50))
25
- birth_date = Column(name="birth_date", type_=Date)
26
- gender = Column(name="gender", type_=Enum(Gender, name="gender"))
27
- blood_type = Column(name="blood_type", type_=Enum(BloodType, name="blood_type"))
28
- avatar_name = Column(name="avatar_name", type_=Text, nullable=False)
29
-
30
-
31
- class UserProfilesTable(UserProfilesMixin, DataTable, MaleoIdentityBase):
32
- __tablename__ = "user_profiles"
33
- user = relationship("UsersTable", back_populates="profile")
@@ -1,26 +0,0 @@
1
- from sqlalchemy import Column, ForeignKey
2
- from sqlalchemy.orm import relationship
3
- from sqlalchemy.types import Enum, Integer
4
- from maleo.soma.models.table import DataTable
5
- from maleo.metadata.enums.system_role import SystemRole
6
- from maleo.identity.db import MaleoIdentityBase
7
-
8
-
9
- class UserSystemRolesMixin:
10
- user_id = Column(
11
- Integer,
12
- ForeignKey("users.id", ondelete="CASCADE", onupdate="CASCADE"),
13
- nullable=False,
14
- )
15
- system_role = Column(
16
- name="system_role",
17
- type_=Enum(SystemRole, name="system_role"),
18
- default=SystemRole.USER,
19
- nullable=False,
20
- )
21
-
22
-
23
- class UserSystemRolesTable(UserSystemRolesMixin, DataTable, MaleoIdentityBase):
24
- __tablename__ = "user_system_roles"
25
- # Foreign Key and Relationship to UsersTable
26
- user = relationship("UsersTable", back_populates="system_roles")
File without changes
@@ -1,36 +0,0 @@
1
- from pydantic import BaseModel, Field
2
- from typing import Optional
3
- from maleo.soma.mixins.data import DataIdentifier, DataTimestamp, DataStatus
4
- from maleo.soma.mixins.general import OptionalParentId
5
- from maleo.metadata.schemas.data.organization_type import (
6
- SimpleOrganizationTypeMixin,
7
- OptionalExpandedOrganizationTypeMixin,
8
- )
9
- from maleo.identity.mixins.organization import Key, Name
10
- from .organization_registration_code import (
11
- OptionalOrganizationRegistrationCodeDataMixin,
12
- )
13
-
14
-
15
- class OrganizationDataSchema(
16
- OptionalOrganizationRegistrationCodeDataMixin,
17
- Name,
18
- Key,
19
- OptionalParentId,
20
- OptionalExpandedOrganizationTypeMixin,
21
- SimpleOrganizationTypeMixin,
22
- DataStatus,
23
- DataTimestamp,
24
- DataIdentifier,
25
- ):
26
- pass
27
-
28
-
29
- class OrganizationDataMixin(BaseModel):
30
- organization: OrganizationDataSchema = Field(..., description="Organization.")
31
-
32
-
33
- class OptionalOrganizationDataMixin(BaseModel):
34
- organization: Optional[OrganizationDataSchema] = Field(
35
- None, description="Organization. (Optional)"
36
- )
@@ -1,27 +0,0 @@
1
- from pydantic import BaseModel, Field
2
- from typing import Optional
3
- from maleo.soma.mixins.data import DataIdentifier, DataTimestamp, DataStatus
4
- from maleo.identity.dtos.data.organization_registration_code import (
5
- OrganizationRegistrationCodeDTO,
6
- )
7
-
8
-
9
- class OrganizationRegistrationCodeDataSchema(
10
- OrganizationRegistrationCodeDTO,
11
- DataStatus,
12
- DataTimestamp,
13
- DataIdentifier,
14
- ):
15
- pass
16
-
17
-
18
- class OrganizationRegistrationCodeDataMixin(BaseModel):
19
- registration_code: OrganizationRegistrationCodeDataSchema = Field(
20
- ..., description="Organization's Registration Code."
21
- )
22
-
23
-
24
- class OptionalOrganizationRegistrationCodeDataMixin(BaseModel):
25
- registration_code: Optional[OrganizationRegistrationCodeDataSchema] = Field(
26
- None, description="Organization's Registration Code. (Optional)"
27
- )
@@ -1,32 +0,0 @@
1
- from pydantic import BaseModel, Field
2
- from typing import Optional
3
- from maleo.soma.mixins.data import DataIdentifier, DataTimestamp, DataStatus
4
- from maleo.soma.mixins.general import IsDefault, Order, OrganizationId
5
- from maleo.identity.mixins.organization_role import Key, Name
6
- from .organization import OptionalOrganizationDataMixin
7
-
8
-
9
- class OrganizationRoleDataSchema(
10
- Name,
11
- Key,
12
- Order,
13
- IsDefault,
14
- OptionalOrganizationDataMixin,
15
- OrganizationId,
16
- DataStatus,
17
- DataTimestamp,
18
- DataIdentifier,
19
- ):
20
- pass
21
-
22
-
23
- class OrganizationRoleDataMixin(BaseModel):
24
- organization_role: OrganizationRoleDataSchema = Field(
25
- ..., description="Organization role."
26
- )
27
-
28
-
29
- class OptionalOrganizationRoleDataMixin(BaseModel):
30
- organization_role: Optional[OrganizationRoleDataSchema] = Field(
31
- None, description="Organization role. (Optional)"
32
- )