maleo-identity 0.0.55__py3-none-any.whl → 0.0.59__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.
- maleo_identity/client/controllers/http/organization.py +300 -63
- maleo_identity/client/controllers/http/user.py +253 -52
- maleo_identity/client/services/organization.py +184 -418
- maleo_identity/client/services/user.py +159 -345
- maleo_identity/constants/organization_role.py +4 -2
- maleo_identity/constants/user.py +3 -0
- maleo_identity/constants/user_organization.py +19 -4
- maleo_identity/constants/user_organization_role.py +8 -4
- maleo_identity/constants/user_system_role.py +1 -10
- maleo_identity/enums/organization.py +1 -1
- maleo_identity/enums/organization_role.py +2 -1
- maleo_identity/enums/user.py +2 -0
- maleo_identity/enums/user_organization.py +8 -2
- maleo_identity/enums/user_organization_role.py +8 -1
- maleo_identity/enums/user_system_role.py +0 -5
- maleo_identity/models/responses/user.py +13 -1
- maleo_identity/models/schemas/user.py +5 -1
- maleo_identity/models/tables/organization.py +21 -2
- maleo_identity/models/tables/organization_registration_code.py +14 -6
- maleo_identity/models/tables/organization_role.py +35 -4
- maleo_identity/models/tables/user.py +17 -3
- maleo_identity/models/tables/user_organization.py +52 -4
- maleo_identity/models/tables/user_organization_role.py +63 -4
- maleo_identity/models/tables/user_profile.py +11 -4
- maleo_identity/models/tables/user_system_role.py +12 -5
- maleo_identity/models/transfers/general/organization.py +4 -1
- maleo_identity/models/transfers/general/organization_role.py +5 -1
- maleo_identity/models/transfers/general/user.py +6 -1
- maleo_identity/models/transfers/general/user_organization.py +5 -1
- maleo_identity/models/transfers/general/user_organization_role.py +10 -10
- maleo_identity/models/transfers/general/user_system_role.py +6 -3
- maleo_identity/models/transfers/results/client/user.py +7 -1
- maleo_identity/models/transfers/results/general/user.py +7 -1
- maleo_identity/models/transfers/results/repository/user.py +7 -1
- maleo_identity/types/results/client/user.py +5 -0
- maleo_identity/types/results/general/user.py +5 -0
- maleo_identity/types/results/repository/user.py +5 -0
- {maleo_identity-0.0.55.dist-info → maleo_identity-0.0.59.dist-info}/METADATA +3 -3
- {maleo_identity-0.0.55.dist-info → maleo_identity-0.0.59.dist-info}/RECORD +41 -41
- {maleo_identity-0.0.55.dist-info → maleo_identity-0.0.59.dist-info}/WHEEL +0 -0
- {maleo_identity-0.0.55.dist-info → maleo_identity-0.0.59.dist-info}/top_level.txt +0 -0
|
@@ -8,7 +8,8 @@ class MaleoIdentityOrganizationRoleConstants:
|
|
|
8
8
|
List[MaleoIdentityOrganizationRoleEnums.ExpandableFields]
|
|
9
9
|
] = {
|
|
10
10
|
MaleoIdentityOrganizationRoleEnums.ExpandableFields.ORGANIZATION: [
|
|
11
|
-
MaleoIdentityOrganizationRoleEnums.ExpandableFields.ORGANIZATION_TYPE
|
|
11
|
+
MaleoIdentityOrganizationRoleEnums.ExpandableFields.ORGANIZATION_TYPE,
|
|
12
|
+
MaleoIdentityOrganizationRoleEnums.ExpandableFields.REGISTRATION_CODE
|
|
12
13
|
]
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -16,5 +17,6 @@ class MaleoIdentityOrganizationRoleConstants:
|
|
|
16
17
|
MaleoIdentityOrganizationRoleEnums.ExpandableFields,
|
|
17
18
|
MaleoIdentityOrganizationEnums.ExpandableFields
|
|
18
19
|
] = {
|
|
19
|
-
MaleoIdentityOrganizationRoleEnums.ExpandableFields.ORGANIZATION_TYPE: MaleoIdentityOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE
|
|
20
|
+
MaleoIdentityOrganizationRoleEnums.ExpandableFields.ORGANIZATION_TYPE: MaleoIdentityOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE,
|
|
21
|
+
MaleoIdentityOrganizationRoleEnums.ExpandableFields.REGISTRATION_CODE: MaleoIdentityOrganizationEnums.ExpandableFields.REGISTRATION_CODE
|
|
20
22
|
}
|
maleo_identity/constants/user.py
CHANGED
|
@@ -20,5 +20,8 @@ class MaleoIdentityUserConstants:
|
|
|
20
20
|
MaleoIdentityUserEnums.ExpandableFields.PROFILE: [
|
|
21
21
|
MaleoIdentityUserEnums.ExpandableFields.GENDER,
|
|
22
22
|
MaleoIdentityUserEnums.ExpandableFields.BLOOD_TYPE
|
|
23
|
+
],
|
|
24
|
+
MaleoIdentityUserEnums.ExpandableFields.SYSTEM_ROLES: [
|
|
25
|
+
MaleoIdentityUserEnums.ExpandableFields.SYSTEM_ROLE_DETAILS
|
|
23
26
|
]
|
|
24
27
|
}
|
|
@@ -9,10 +9,19 @@ class MaleoIdentityUserOrganizationConstants:
|
|
|
9
9
|
List[MaleoIdentityUserOrganizationEnums.ExpandableFields]
|
|
10
10
|
] = {
|
|
11
11
|
MaleoIdentityUserOrganizationEnums.ExpandableFields.USER: [
|
|
12
|
-
MaleoIdentityUserOrganizationEnums.ExpandableFields.USER_TYPE
|
|
12
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.USER_TYPE,
|
|
13
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.PROFILE
|
|
14
|
+
],
|
|
15
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.PROFILE: [
|
|
16
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.BLOOD_TYPE,
|
|
17
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.GENDER
|
|
18
|
+
],
|
|
19
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.SYSTEM_ROLES: [
|
|
20
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.SYSTEM_ROLE_DETAILS
|
|
13
21
|
],
|
|
14
22
|
MaleoIdentityUserOrganizationEnums.ExpandableFields.ORGANIZATION: [
|
|
15
|
-
MaleoIdentityUserOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE
|
|
23
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE,
|
|
24
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.REGISTRATION_CODE
|
|
16
25
|
]
|
|
17
26
|
}
|
|
18
27
|
|
|
@@ -20,12 +29,18 @@ class MaleoIdentityUserOrganizationConstants:
|
|
|
20
29
|
MaleoIdentityUserOrganizationEnums.ExpandableFields,
|
|
21
30
|
MaleoIdentityUserEnums.ExpandableFields
|
|
22
31
|
] = {
|
|
23
|
-
MaleoIdentityUserOrganizationEnums.ExpandableFields.USER_TYPE: MaleoIdentityUserEnums.ExpandableFields.USER_TYPE
|
|
32
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.USER_TYPE: MaleoIdentityUserEnums.ExpandableFields.USER_TYPE,
|
|
33
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.PROFILE: MaleoIdentityUserEnums.ExpandableFields.PROFILE,
|
|
34
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.BLOOD_TYPE: MaleoIdentityUserEnums.ExpandableFields.BLOOD_TYPE,
|
|
35
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.GENDER: MaleoIdentityUserEnums.ExpandableFields.GENDER,
|
|
36
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.SYSTEM_ROLES: MaleoIdentityUserEnums.ExpandableFields.SYSTEM_ROLES,
|
|
37
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.SYSTEM_ROLE_DETAILS: MaleoIdentityUserEnums.ExpandableFields.SYSTEM_ROLE_DETAILS
|
|
24
38
|
}
|
|
25
39
|
|
|
26
40
|
ORGANIZATION_EXPANDABLE_FIELDS_MAP:Dict[
|
|
27
41
|
MaleoIdentityUserOrganizationEnums.ExpandableFields,
|
|
28
42
|
MaleoIdentityOrganizationEnums.ExpandableFields
|
|
29
43
|
] = {
|
|
30
|
-
MaleoIdentityUserOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE: MaleoIdentityOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE
|
|
44
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE: MaleoIdentityOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE,
|
|
45
|
+
MaleoIdentityUserOrganizationEnums.ExpandableFields.REGISTRATION_CODE: MaleoIdentityOrganizationEnums.ExpandableFields.REGISTRATION_CODE
|
|
31
46
|
}
|
|
@@ -9,10 +9,12 @@ class MaleoIdentityUserOrganizationRoleConstants:
|
|
|
9
9
|
List[MaleoIdentityUserOrganizationRoleEnums.ExpandableFields]
|
|
10
10
|
] = {
|
|
11
11
|
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.USER: [
|
|
12
|
-
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.USER_TYPE
|
|
12
|
+
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.USER_TYPE,
|
|
13
|
+
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.PROFILE
|
|
13
14
|
],
|
|
14
15
|
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.ORGANIZATION: [
|
|
15
|
-
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.ORGANIZATION_TYPE
|
|
16
|
+
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.ORGANIZATION_TYPE,
|
|
17
|
+
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.REGISTRATION_CODE
|
|
16
18
|
]
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -20,12 +22,14 @@ class MaleoIdentityUserOrganizationRoleConstants:
|
|
|
20
22
|
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields,
|
|
21
23
|
MaleoIdentityUserEnums.ExpandableFields
|
|
22
24
|
] = {
|
|
23
|
-
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.USER_TYPE: MaleoIdentityUserEnums.ExpandableFields.USER_TYPE
|
|
25
|
+
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.USER_TYPE: MaleoIdentityUserEnums.ExpandableFields.USER_TYPE,
|
|
26
|
+
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.PROFILE: MaleoIdentityUserEnums.ExpandableFields.PROFILE
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
ORGANIZATION_EXPANDABLE_FIELDS_MAP:Dict[
|
|
27
30
|
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields,
|
|
28
31
|
MaleoIdentityOrganizationEnums.ExpandableFields
|
|
29
32
|
] = {
|
|
30
|
-
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.ORGANIZATION_TYPE: MaleoIdentityOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE
|
|
33
|
+
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.ORGANIZATION_TYPE: MaleoIdentityOrganizationEnums.ExpandableFields.ORGANIZATION_TYPE,
|
|
34
|
+
MaleoIdentityUserOrganizationRoleEnums.ExpandableFields.REGISTRATION_CODE: MaleoIdentityOrganizationEnums.ExpandableFields.REGISTRATION_CODE
|
|
31
35
|
}
|
|
@@ -6,13 +6,4 @@ class MaleoIdentityUserSystemRoleConstants:
|
|
|
6
6
|
EXPANDABLE_FIELDS_DEPENDENCIES_MAP:Dict[
|
|
7
7
|
MaleoIdentityUserSystemRoleEnums.ExpandableFields,
|
|
8
8
|
List[MaleoIdentityUserSystemRoleEnums.ExpandableFields]
|
|
9
|
-
] = {
|
|
10
|
-
MaleoIdentityUserSystemRoleEnums.ExpandableFields.USER: [
|
|
11
|
-
MaleoIdentityUserSystemRoleEnums.ExpandableFields.USER_TYPE,
|
|
12
|
-
MaleoIdentityUserSystemRoleEnums.ExpandableFields.PROFILE
|
|
13
|
-
],
|
|
14
|
-
MaleoIdentityUserSystemRoleEnums.ExpandableFields.PROFILE: [
|
|
15
|
-
MaleoIdentityUserSystemRoleEnums.ExpandableFields.GENDER,
|
|
16
|
-
MaleoIdentityUserSystemRoleEnums.ExpandableFields.BLOOD_TYPE
|
|
17
|
-
]
|
|
18
|
-
}
|
|
9
|
+
] = {}
|
|
@@ -3,4 +3,5 @@ from enum import StrEnum
|
|
|
3
3
|
class MaleoIdentityOrganizationRoleEnums:
|
|
4
4
|
class ExpandableFields(StrEnum):
|
|
5
5
|
ORGANIZATION = "organization"
|
|
6
|
-
ORGANIZATION_TYPE = "organization.organization_type"
|
|
6
|
+
ORGANIZATION_TYPE = "organization.organization_type"
|
|
7
|
+
REGISTRATION_CODE = "organization.registration_code"
|
maleo_identity/enums/user.py
CHANGED
|
@@ -9,6 +9,8 @@ class MaleoIdentityUserEnums:
|
|
|
9
9
|
|
|
10
10
|
class ExpandableFields(StrEnum):
|
|
11
11
|
USER_TYPE = "user_type"
|
|
12
|
+
SYSTEM_ROLES = "system_roles"
|
|
13
|
+
SYSTEM_ROLE_DETAILS = "system_roles.system_role_details"
|
|
12
14
|
PROFILE = "profile"
|
|
13
15
|
GENDER = "profile.gender"
|
|
14
16
|
BLOOD_TYPE = "profile.blood_type"
|
|
@@ -3,6 +3,12 @@ from enum import StrEnum
|
|
|
3
3
|
class MaleoIdentityUserOrganizationEnums:
|
|
4
4
|
class ExpandableFields(StrEnum):
|
|
5
5
|
USER = "user"
|
|
6
|
-
USER_TYPE = "
|
|
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"
|
|
7
12
|
ORGANIZATION = "organization"
|
|
8
|
-
ORGANIZATION_TYPE = "organization.organization_type"
|
|
13
|
+
ORGANIZATION_TYPE = "organization.organization_type"
|
|
14
|
+
REGISTRATION_CODE = "organization.registration_code"
|
|
@@ -4,5 +4,12 @@ class MaleoIdentityUserOrganizationRoleEnums:
|
|
|
4
4
|
class ExpandableFields(StrEnum):
|
|
5
5
|
USER = "user"
|
|
6
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"
|
|
7
12
|
ORGANIZATION = "organization"
|
|
8
|
-
ORGANIZATION_TYPE = "organization.organization_type"
|
|
13
|
+
ORGANIZATION_TYPE = "organization.organization_type"
|
|
14
|
+
REGISTRATION_CODE = "organization.registration_code"
|
|
15
|
+
USER_ORGANIZATION = "user_organization"
|
|
@@ -2,9 +2,4 @@ from enum import StrEnum
|
|
|
2
2
|
|
|
3
3
|
class MaleoIdentityUserSystemRoleEnums:
|
|
4
4
|
class ExpandableFields(StrEnum):
|
|
5
|
-
USER = "user"
|
|
6
|
-
USER_TYPE = "user.user_type"
|
|
7
|
-
PROFILE = "user.profile"
|
|
8
|
-
GENDER = "user.profile.gender"
|
|
9
|
-
BLOOD_TYPE = "user.profile.blood_type"
|
|
10
5
|
SYSTEM_ROLE = "system_role"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from pydantic import Field
|
|
2
|
+
from typing import Optional
|
|
2
3
|
from maleo_foundation.models.responses import BaseResponses
|
|
3
4
|
from maleo_identity.enums.user import MaleoIdentityUserEnums
|
|
5
|
+
from maleo_identity.models.schemas.user import MaleoIdentityUserSchemas
|
|
4
6
|
from maleo_identity.models.transfers.general.user import UserTransfers, PasswordTransfers
|
|
5
7
|
|
|
6
8
|
class MaleoIdentityUserResponses:
|
|
@@ -53,4 +55,14 @@ class MaleoIdentityUserResponses:
|
|
|
53
55
|
code:str = "IDT-USR-010"
|
|
54
56
|
message:str = "User's password found"
|
|
55
57
|
description:str = "Requested user's password found in database"
|
|
56
|
-
data:PasswordTransfers = Field(..., description="User's password")
|
|
58
|
+
data:PasswordTransfers = Field(..., description="User's password")
|
|
59
|
+
|
|
60
|
+
class RegisterFailed(BaseResponses.BadRequest):
|
|
61
|
+
code:str = "IDT-USR-011"
|
|
62
|
+
message:str = "Failed registering new user"
|
|
63
|
+
|
|
64
|
+
class RegisterSuccess(BaseResponses.SingleData):
|
|
65
|
+
code:str = "IDT-USR-012"
|
|
66
|
+
message:str = "Successfully registered new user"
|
|
67
|
+
data:UserTransfers = Field(..., description="User")
|
|
68
|
+
metadata:Optional[MaleoIdentityUserSchemas.RegisterResultMetadata] = Field(None, description="Optional metadata")
|
|
@@ -2,6 +2,7 @@ from pydantic import BaseModel, Field
|
|
|
2
2
|
from typing import List, Optional
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
from maleo_foundation.models.schemas.parameter import BaseParameterSchemas
|
|
5
|
+
from maleo_foundation.models.schemas.result import ResultMetadata
|
|
5
6
|
from maleo_foundation.types import BaseTypes
|
|
6
7
|
from maleo_identity.enums.user import MaleoIdentityUserEnums
|
|
7
8
|
|
|
@@ -37,4 +38,7 @@ class MaleoIdentityUserSchemas:
|
|
|
37
38
|
password_confirmation:str = Field(..., max_length=255, description="User's password confirmation")
|
|
38
39
|
|
|
39
40
|
class RegistrationCode(BaseModel):
|
|
40
|
-
registration_code:UUID = Field(..., description="Registration code")
|
|
41
|
+
registration_code:UUID = Field(..., description="Registration code")
|
|
42
|
+
|
|
43
|
+
class RegisterResultMetadata(ResultMetadata):
|
|
44
|
+
organization_key:BaseTypes.OptionalString = Field(None, description="Organization key")
|
|
@@ -4,9 +4,9 @@ from sqlalchemy.types import Integer, String, Enum, UUID
|
|
|
4
4
|
from uuid import uuid4
|
|
5
5
|
from maleo_metadata.enums.organization_type import MaleoMetadataOrganizationTypeEnums
|
|
6
6
|
from maleo_identity.db import MaleoIdentityMetadataManager
|
|
7
|
+
from maleo_foundation.models.table import DataTable
|
|
7
8
|
|
|
8
|
-
class
|
|
9
|
-
__tablename__ = "organizations"
|
|
9
|
+
class OrganizationsMixin:
|
|
10
10
|
organization_type = Column(
|
|
11
11
|
name="organization_type",
|
|
12
12
|
type_=Enum(MaleoMetadataOrganizationTypeEnums.OrganizationType, name="organization_type"),
|
|
@@ -17,6 +17,13 @@ class OrganizationsTable(MaleoIdentityMetadataManager.Base):
|
|
|
17
17
|
key = Column(name="key", type_=String(255), unique=True, nullable=False)
|
|
18
18
|
name = Column(name="name", type_=String(255), nullable=False)
|
|
19
19
|
secret = Column(name="secret", type_=UUID, default=uuid4, unique=True, nullable=False)
|
|
20
|
+
|
|
21
|
+
class OrganizationsTable(
|
|
22
|
+
OrganizationsMixin,
|
|
23
|
+
DataTable,
|
|
24
|
+
MaleoIdentityMetadataManager.Base
|
|
25
|
+
):
|
|
26
|
+
__tablename__ = "organizations"
|
|
20
27
|
parent = relationship(
|
|
21
28
|
"OrganizationsTable",
|
|
22
29
|
remote_side="OrganizationsTable.id",
|
|
@@ -36,4 +43,16 @@ class OrganizationsTable(MaleoIdentityMetadataManager.Base):
|
|
|
36
43
|
cascade="all",
|
|
37
44
|
lazy="select",
|
|
38
45
|
uselist=False
|
|
46
|
+
)
|
|
47
|
+
user_organization = relationship(
|
|
48
|
+
"UserOrganizationsTable",
|
|
49
|
+
back_populates="organization",
|
|
50
|
+
cascade="all, delete-orphan",
|
|
51
|
+
uselist=False
|
|
52
|
+
)
|
|
53
|
+
organization_roles = relationship(
|
|
54
|
+
"OrganizationRolesTable",
|
|
55
|
+
back_populates="organization",
|
|
56
|
+
cascade="all, delete-orphan",
|
|
57
|
+
uselist=False
|
|
39
58
|
)
|
|
@@ -3,9 +3,9 @@ from sqlalchemy.orm import relationship
|
|
|
3
3
|
from sqlalchemy.types import Integer, UUID
|
|
4
4
|
from uuid import uuid4
|
|
5
5
|
from maleo_identity.db import MaleoIdentityMetadataManager
|
|
6
|
+
from maleo_foundation.models.table import DataTable
|
|
6
7
|
|
|
7
|
-
class
|
|
8
|
-
__tablename__ = "organization_registration_codes"
|
|
8
|
+
class OrganizationRegistrationCodesMixin:
|
|
9
9
|
#* Foreign Key OrganizationsTable
|
|
10
10
|
organization_id = Column(
|
|
11
11
|
Integer,
|
|
@@ -17,13 +17,21 @@ class OrganizationRegistrationCodesTable(MaleoIdentityMetadataManager.Base):
|
|
|
17
17
|
unique=True,
|
|
18
18
|
nullable=False
|
|
19
19
|
)
|
|
20
|
+
code = Column(name="code", type_=UUID, default=uuid4, unique=True, nullable=False)
|
|
21
|
+
max_uses = Column(name="max_uses", type_=Integer, nullable=False, default=1)
|
|
22
|
+
current_uses = Column(name="current_uses", type_=Integer, nullable=False, default=0)
|
|
23
|
+
|
|
24
|
+
class OrganizationRegistrationCodesTable(
|
|
25
|
+
OrganizationRegistrationCodesMixin,
|
|
26
|
+
DataTable,
|
|
27
|
+
MaleoIdentityMetadataManager.Base
|
|
28
|
+
):
|
|
29
|
+
__tablename__ = "organization_registration_codes"
|
|
30
|
+
|
|
20
31
|
organization = relationship(
|
|
21
32
|
"OrganizationsTable",
|
|
22
33
|
back_populates="registration_code",
|
|
23
34
|
cascade="all",
|
|
24
35
|
lazy="select",
|
|
25
36
|
uselist=False
|
|
26
|
-
)
|
|
27
|
-
code = Column(name="code", type_=UUID, default=uuid4, unique=True, nullable=False)
|
|
28
|
-
max_uses = Column(name="max_uses", type_=Integer, nullable=False, default=1)
|
|
29
|
-
current_uses = Column(name="current_uses", type_=Integer, nullable=False, default=0)
|
|
37
|
+
)
|
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
from sqlalchemy import Column, ForeignKey
|
|
2
|
+
from sqlalchemy.orm import relationship
|
|
2
3
|
from sqlalchemy.types import Integer, String, Boolean
|
|
3
4
|
from maleo_identity.db import MaleoIdentityMetadataManager
|
|
5
|
+
from maleo_foundation.models.table import DataTable
|
|
4
6
|
|
|
5
|
-
class
|
|
6
|
-
__tablename__ = "organization_roles"
|
|
7
|
+
class OrganizationRolesMixin:
|
|
7
8
|
#* Foreign Key OrganizationsTable
|
|
8
|
-
organization_id = Column(
|
|
9
|
+
organization_id = Column(
|
|
10
|
+
Integer,
|
|
11
|
+
ForeignKey(
|
|
12
|
+
"organizations.id",
|
|
13
|
+
ondelete="CASCADE",
|
|
14
|
+
onupdate="CASCADE"
|
|
15
|
+
),
|
|
16
|
+
nullable=False
|
|
17
|
+
)
|
|
9
18
|
is_default = Column(name="is_default", type_=Boolean, nullable=False, default=False)
|
|
10
19
|
order = Column(name="order", type_=Integer)
|
|
11
20
|
key = Column(name="key", type_=String(50), nullable=False)
|
|
12
|
-
name = Column(name="name", type_=String(50), nullable=False)
|
|
21
|
+
name = Column(name="name", type_=String(50), nullable=False)
|
|
22
|
+
|
|
23
|
+
class OrganizationRolesTable(
|
|
24
|
+
OrganizationRolesMixin,
|
|
25
|
+
DataTable,
|
|
26
|
+
MaleoIdentityMetadataManager.Base
|
|
27
|
+
):
|
|
28
|
+
__tablename__ = "organization_roles"
|
|
29
|
+
|
|
30
|
+
organization = relationship(
|
|
31
|
+
"OrganizationsTable",
|
|
32
|
+
back_populates="organization_roles",
|
|
33
|
+
cascade="all",
|
|
34
|
+
lazy="select",
|
|
35
|
+
uselist=False
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
user_organization_roles = relationship(
|
|
39
|
+
"UserOrganizationRolesTable",
|
|
40
|
+
back_populates="organization_role",
|
|
41
|
+
cascade="all, delete-orphan",
|
|
42
|
+
lazy="select"
|
|
43
|
+
)
|
|
@@ -3,9 +3,9 @@ from sqlalchemy.orm import relationship
|
|
|
3
3
|
from sqlalchemy.types import String, Enum
|
|
4
4
|
from maleo_metadata.enums.user_type import MaleoMetadataUserTypeEnums
|
|
5
5
|
from maleo_identity.db import MaleoIdentityMetadataManager
|
|
6
|
+
from maleo_foundation.models.table import DataTable
|
|
6
7
|
|
|
7
|
-
class
|
|
8
|
-
__tablename__ = "users"
|
|
8
|
+
class UsersMixin:
|
|
9
9
|
user_type = Column(
|
|
10
10
|
name="user_type",
|
|
11
11
|
type_=Enum(MaleoMetadataUserTypeEnums.UserType, name="user_type"),
|
|
@@ -16,6 +16,14 @@ class UsersTable(MaleoIdentityMetadataManager.Base):
|
|
|
16
16
|
email = Column(name="email", type_=String(255), unique=True, nullable=False)
|
|
17
17
|
phone = Column(name="phone", type_=String(15), nullable=False)
|
|
18
18
|
password = Column(name="password", type_=String(255), nullable=False)
|
|
19
|
+
|
|
20
|
+
class UsersTable(
|
|
21
|
+
UsersMixin,
|
|
22
|
+
DataTable,
|
|
23
|
+
MaleoIdentityMetadataManager.Base
|
|
24
|
+
):
|
|
25
|
+
__tablename__ = "users"
|
|
26
|
+
|
|
19
27
|
profile = relationship(
|
|
20
28
|
"UserProfilesTable",
|
|
21
29
|
back_populates="user",
|
|
@@ -24,6 +32,12 @@ class UsersTable(MaleoIdentityMetadataManager.Base):
|
|
|
24
32
|
)
|
|
25
33
|
system_roles = relationship(
|
|
26
34
|
"UserSystemRolesTable",
|
|
27
|
-
back_populates="
|
|
35
|
+
back_populates="user",
|
|
28
36
|
cascade="all, delete-orphan"
|
|
37
|
+
)
|
|
38
|
+
user_organization = relationship(
|
|
39
|
+
"UserOrganizationsTable",
|
|
40
|
+
back_populates="user",
|
|
41
|
+
cascade="all, delete-orphan",
|
|
42
|
+
uselist=False
|
|
29
43
|
)
|
|
@@ -1,10 +1,58 @@
|
|
|
1
1
|
from sqlalchemy import Column, ForeignKey
|
|
2
|
+
from sqlalchemy.orm import relationship
|
|
2
3
|
from sqlalchemy.types import Integer
|
|
3
4
|
from maleo_identity.db import MaleoIdentityMetadataManager
|
|
5
|
+
from maleo_foundation.models.table import DataTable
|
|
4
6
|
|
|
5
|
-
class
|
|
6
|
-
__tablename__ = "user_organizations"
|
|
7
|
+
class UserOrganizationsMixin:
|
|
7
8
|
#* Foreign Key UsersTable
|
|
8
|
-
user_id = Column(
|
|
9
|
+
user_id = Column(
|
|
10
|
+
Integer,
|
|
11
|
+
ForeignKey(
|
|
12
|
+
"users.id",
|
|
13
|
+
ondelete="CASCADE",
|
|
14
|
+
onupdate="CASCADE"
|
|
15
|
+
),
|
|
16
|
+
nullable=False
|
|
17
|
+
)
|
|
18
|
+
|
|
9
19
|
#* Foreign Key OrganizationsTable
|
|
10
|
-
organization_id = Column(
|
|
20
|
+
organization_id = Column(
|
|
21
|
+
Integer,
|
|
22
|
+
ForeignKey(
|
|
23
|
+
"organizations.id",
|
|
24
|
+
ondelete="CASCADE",
|
|
25
|
+
onupdate="CASCADE"
|
|
26
|
+
),
|
|
27
|
+
nullable=False
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
class UserOrganizationsTable(
|
|
31
|
+
UserOrganizationsMixin,
|
|
32
|
+
DataTable,
|
|
33
|
+
MaleoIdentityMetadataManager.Base
|
|
34
|
+
):
|
|
35
|
+
__tablename__ = "user_organizations"
|
|
36
|
+
|
|
37
|
+
user = relationship(
|
|
38
|
+
"UsersTable",
|
|
39
|
+
back_populates="user_organization",
|
|
40
|
+
cascade="all",
|
|
41
|
+
lazy="select",
|
|
42
|
+
uselist=False
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
organization = relationship(
|
|
46
|
+
"OrganizationsTable",
|
|
47
|
+
back_populates="user_organization",
|
|
48
|
+
cascade="all",
|
|
49
|
+
lazy="select",
|
|
50
|
+
uselist=False
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
user_organization_roles = relationship(
|
|
54
|
+
"UserOrganizationRolesTable",
|
|
55
|
+
back_populates="user_organization",
|
|
56
|
+
cascade="all, delete-orphan",
|
|
57
|
+
lazy="select"
|
|
58
|
+
)
|
|
@@ -1,10 +1,69 @@
|
|
|
1
1
|
from sqlalchemy import Column, ForeignKey
|
|
2
|
+
from sqlalchemy.orm import relationship
|
|
2
3
|
from sqlalchemy.types import Integer
|
|
3
4
|
from maleo_identity.db import MaleoIdentityMetadataManager
|
|
5
|
+
from maleo_foundation.models.table import DataTable
|
|
4
6
|
|
|
5
|
-
class
|
|
6
|
-
__tablename__ = "user_organization_roles"
|
|
7
|
+
class UserOrganizationRolesMixin:
|
|
7
8
|
#* Foreign Key UserOrganizationsTable
|
|
8
|
-
user_organization_id = Column(
|
|
9
|
+
user_organization_id = Column(
|
|
10
|
+
Integer,
|
|
11
|
+
ForeignKey(
|
|
12
|
+
"user_organizations.id",
|
|
13
|
+
ondelete="CASCADE",
|
|
14
|
+
onupdate="CASCADE"
|
|
15
|
+
),
|
|
16
|
+
nullable=False
|
|
17
|
+
)
|
|
18
|
+
|
|
9
19
|
#* Foreign Key OrganizationRolesTable
|
|
10
|
-
organization_role_id = Column(
|
|
20
|
+
organization_role_id = Column(
|
|
21
|
+
Integer,
|
|
22
|
+
ForeignKey(
|
|
23
|
+
"organization_roles.id",
|
|
24
|
+
ondelete="CASCADE",
|
|
25
|
+
onupdate="CASCADE"
|
|
26
|
+
),
|
|
27
|
+
nullable=False
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
class UserOrganizationRolesTable(
|
|
31
|
+
UserOrganizationRolesMixin,
|
|
32
|
+
DataTable,
|
|
33
|
+
MaleoIdentityMetadataManager.Base
|
|
34
|
+
):
|
|
35
|
+
__tablename__ = "user_organization_roles"
|
|
36
|
+
|
|
37
|
+
user_organization = relationship(
|
|
38
|
+
"UserOrganizationsTable",
|
|
39
|
+
back_populates="user_organization_roles",
|
|
40
|
+
cascade="all",
|
|
41
|
+
lazy="select",
|
|
42
|
+
uselist=False
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
user = relationship(
|
|
46
|
+
"UsersTable",
|
|
47
|
+
secondary="user_organizations",
|
|
48
|
+
primaryjoin="UserOrganizationRolesTable.user_organization_id == UserOrganizationsTable.id",
|
|
49
|
+
secondaryjoin="UserOrganizationsTable.user_id == UsersTable.id",
|
|
50
|
+
uselist=False,
|
|
51
|
+
viewonly=True
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
organization = relationship(
|
|
55
|
+
"OrganizationsTable",
|
|
56
|
+
secondary="user_organizations",
|
|
57
|
+
primaryjoin="UserOrganizationRolesTable.user_organization_id == UserOrganizationsTable.id",
|
|
58
|
+
secondaryjoin="UserOrganizationsTable.organization_id == OrganizationsTable.id",
|
|
59
|
+
uselist=False,
|
|
60
|
+
viewonly=True
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
organization_role = relationship(
|
|
64
|
+
"OrganizationRolesTable",
|
|
65
|
+
back_populates="user_organization_roles",
|
|
66
|
+
cascade="all",
|
|
67
|
+
lazy="select",
|
|
68
|
+
uselist=False
|
|
69
|
+
)
|
|
@@ -4,12 +4,11 @@ from sqlalchemy.types import String, Enum, Integer, Date, Text
|
|
|
4
4
|
from maleo_metadata.enums.blood_type import MaleoMetadataBloodTypeEnums
|
|
5
5
|
from maleo_metadata.enums.gender import MaleoMetadataGenderEnums
|
|
6
6
|
from maleo_identity.db import MaleoIdentityMetadataManager
|
|
7
|
+
from maleo_foundation.models.table import DataTable
|
|
7
8
|
|
|
8
|
-
class
|
|
9
|
-
__tablename__ = "user_profiles"
|
|
9
|
+
class UserProfilesMixin:
|
|
10
10
|
#* Foreign Key and Relationship to UsersTable
|
|
11
11
|
user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE", onupdate="CASCADE"), nullable=False)
|
|
12
|
-
user = relationship("UsersTable", back_populates="profile")
|
|
13
12
|
id_card = Column(name="id_card", type_=String(16))
|
|
14
13
|
leading_title = Column(name="leading_title", type_=String(25))
|
|
15
14
|
first_name = Column(name="first_name", type_=String(50), nullable=False)
|
|
@@ -21,4 +20,12 @@ class UserProfilesTable(MaleoIdentityMetadataManager.Base):
|
|
|
21
20
|
birth_date = Column(name="birth_date", type_=Date)
|
|
22
21
|
gender = Column(name="gender", type_=Enum(MaleoMetadataGenderEnums.Gender, name="gender"))
|
|
23
22
|
blood_type = Column(name="blood_type", type_=Enum(MaleoMetadataBloodTypeEnums.BloodType, name="blood_type"))
|
|
24
|
-
avatar_name = Column(name="avatar_name", type_=Text, nullable=False)
|
|
23
|
+
avatar_name = Column(name="avatar_name", type_=Text, nullable=False)
|
|
24
|
+
|
|
25
|
+
class UserProfilesTable(
|
|
26
|
+
UserProfilesMixin,
|
|
27
|
+
DataTable,
|
|
28
|
+
MaleoIdentityMetadataManager.Base
|
|
29
|
+
):
|
|
30
|
+
__tablename__ = "user_profiles"
|
|
31
|
+
user = relationship("UsersTable", back_populates="profile")
|
|
@@ -3,15 +3,22 @@ from sqlalchemy.orm import relationship
|
|
|
3
3
|
from sqlalchemy.types import Enum, Integer
|
|
4
4
|
from maleo_metadata.enums.system_role import MaleoMetadataSystemRoleEnums
|
|
5
5
|
from maleo_identity.db import MaleoIdentityMetadataManager
|
|
6
|
+
from maleo_foundation.models.table import DataTable
|
|
6
7
|
|
|
7
|
-
class
|
|
8
|
-
__tablename__ = "user_system_roles"
|
|
9
|
-
#* Foreign Key and Relationship to UsersTable
|
|
8
|
+
class UserSystemRolesMixin:
|
|
10
9
|
user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE", onupdate="CASCADE"), nullable=False)
|
|
11
|
-
user_details = relationship("UsersTable", back_populates="system_roles")
|
|
12
10
|
system_role = Column(
|
|
13
11
|
name="system_role",
|
|
14
12
|
type_=Enum(MaleoMetadataSystemRoleEnums.SystemRole, name="system_role"),
|
|
15
13
|
default=MaleoMetadataSystemRoleEnums.SystemRole.USER,
|
|
16
14
|
nullable=False
|
|
17
|
-
)
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
class UserSystemRolesTable(
|
|
18
|
+
UserSystemRolesMixin,
|
|
19
|
+
DataTable,
|
|
20
|
+
MaleoIdentityMetadataManager.Base
|
|
21
|
+
):
|
|
22
|
+
__tablename__ = "user_system_roles"
|
|
23
|
+
#* Foreign Key and Relationship to UsersTable
|
|
24
|
+
user = relationship("UsersTable", back_populates="system_roles")
|
|
@@ -18,8 +18,11 @@ class OrganizationTransfers(
|
|
|
18
18
|
):
|
|
19
19
|
pass
|
|
20
20
|
|
|
21
|
+
class ExpandedOrganization(BaseModel):
|
|
22
|
+
organization:OrganizationTransfers = Field(..., description="Organization's details")
|
|
23
|
+
|
|
21
24
|
class OptionalExpandedOrganization(BaseModel):
|
|
22
|
-
|
|
25
|
+
organization:Optional[OrganizationTransfers] = Field(None, description="Organization's details")
|
|
23
26
|
|
|
24
27
|
class StructuredOrganizationTransfers(OrganizationTransfers):
|
|
25
28
|
children:List["StructuredOrganizationTransfers"] = Field(..., description="Organization children")
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
1
2
|
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
|
2
3
|
from maleo_identity.models.schemas.general import MaleoIdentityGeneralSchemas
|
|
3
4
|
from maleo_identity.models.schemas.organization_role import MaleoIdentityOrganizationRoleSchemas
|
|
@@ -13,4 +14,7 @@ class OrganizationRoleTransfers(
|
|
|
13
14
|
BaseGeneralSchemas.Status,
|
|
14
15
|
BaseGeneralSchemas.Timestamps,
|
|
15
16
|
BaseGeneralSchemas.Identifiers
|
|
16
|
-
): pass
|
|
17
|
+
): pass
|
|
18
|
+
|
|
19
|
+
class ExpandedOrganizationRole(BaseModel):
|
|
20
|
+
organization_role:OrganizationRoleTransfers = Field(..., description="Organization role")
|
|
@@ -4,9 +4,11 @@ from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
|
|
4
4
|
from maleo_metadata.models.expanded_schemas.user_type import MaleoMetadataUserTypeExpandedSchemas
|
|
5
5
|
from maleo_identity.models.schemas.user import MaleoIdentityUserSchemas
|
|
6
6
|
from maleo_identity.models.transfers.general.user_profile import OptionalExpandedUserProfile
|
|
7
|
+
from .user_system_role import ListOfExpandedUserSystemRole
|
|
7
8
|
|
|
8
9
|
class UserTransfers(
|
|
9
10
|
OptionalExpandedUserProfile,
|
|
11
|
+
ListOfExpandedUserSystemRole,
|
|
10
12
|
MaleoIdentityUserSchemas.Phone,
|
|
11
13
|
MaleoIdentityUserSchemas.Email,
|
|
12
14
|
MaleoIdentityUserSchemas.Username,
|
|
@@ -17,7 +19,10 @@ class UserTransfers(
|
|
|
17
19
|
BaseGeneralSchemas.Identifiers
|
|
18
20
|
): pass
|
|
19
21
|
|
|
22
|
+
class ExpandedUser(BaseModel):
|
|
23
|
+
user:UserTransfers = Field(..., description="User's details")
|
|
24
|
+
|
|
20
25
|
class OptionalExpandedUser(BaseModel):
|
|
21
|
-
|
|
26
|
+
user:Optional[UserTransfers] = Field(None, description="User's details")
|
|
22
27
|
|
|
23
28
|
class PasswordTransfers(MaleoIdentityUserSchemas.Password): pass
|