maleo-identity 0.0.76__py3-none-any.whl → 0.0.78__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/__init__.py +0 -0
- maleo/identity/client/__init__.py +0 -0
- maleo/identity/client/manager.py +157 -0
- maleo/identity/client/services/__init__.py +0 -0
- maleo/identity/client/services/organization.py +1944 -0
- maleo/identity/client/services/organization_registration_code.py +470 -0
- maleo/identity/client/services/organization_role.py +276 -0
- maleo/identity/client/services/user.py +1559 -0
- maleo/identity/client/services/user_organization.py +276 -0
- maleo/identity/client/services/user_organization_role.py +278 -0
- maleo/identity/client/services/user_profile.py +276 -0
- maleo/identity/client/services/user_system_role.py +276 -0
- maleo/identity/constants/__init__.py +0 -0
- maleo/identity/constants/organization.py +18 -0
- maleo/identity/constants/organization_registration_code.py +25 -0
- maleo/identity/constants/organization_role.py +35 -0
- maleo/identity/constants/user.py +24 -0
- maleo/identity/constants/user_organization.py +58 -0
- maleo/identity/constants/user_organization_role.py +47 -0
- maleo/identity/constants/user_profile.py +26 -0
- maleo/identity/constants/user_system_role.py +16 -0
- maleo/identity/db.py +4 -0
- maleo/identity/dtos/__init__.py +0 -0
- maleo/identity/dtos/organization_registration_code.py +12 -0
- maleo/identity/enums/__init__.py +0 -0
- maleo/identity/enums/general.py +5 -0
- maleo/identity/enums/organization.py +12 -0
- maleo/identity/enums/organization_registration_code.py +8 -0
- maleo/identity/enums/organization_role.py +7 -0
- maleo/identity/enums/user.py +17 -0
- maleo/identity/enums/user_organization.py +14 -0
- maleo/identity/enums/user_organization_role.py +15 -0
- maleo/identity/enums/user_profile.py +17 -0
- maleo/identity/enums/user_system_role.py +5 -0
- maleo/identity/mixins/__init__.py +0 -0
- maleo/identity/mixins/organization.py +15 -0
- maleo/identity/mixins/organization_registration_code.py +14 -0
- maleo/identity/mixins/organization_role.py +15 -0
- maleo/identity/mixins/user.py +47 -0
- maleo/identity/mixins/user_organization.py +6 -0
- maleo/identity/mixins/user_organization_role.py +6 -0
- maleo/identity/mixins/user_profile.py +81 -0
- maleo/identity/mixins/user_system_role.py +6 -0
- maleo/identity/models/__init__.py +0 -0
- maleo/identity/models/organization.py +62 -0
- maleo/identity/models/organization_registration_code.py +33 -0
- maleo/identity/models/organization_role.py +37 -0
- maleo/identity/models/user.py +39 -0
- maleo/identity/models/user_organization.py +48 -0
- maleo/identity/models/user_organization_role.py +61 -0
- maleo/identity/models/user_profile.py +33 -0
- maleo/identity/models/user_system_role.py +26 -0
- maleo/identity/schemas/__init__.py +0 -0
- maleo/identity/schemas/data/__init__.py +0 -0
- maleo/identity/schemas/data/organization.py +36 -0
- maleo/identity/schemas/data/organization_registration_code.py +33 -0
- maleo/identity/schemas/data/organization_role.py +32 -0
- maleo/identity/schemas/data/user.py +33 -0
- maleo/identity/schemas/data/user_organization.py +23 -0
- maleo/identity/schemas/data/user_organization_role.py +13 -0
- maleo/identity/schemas/data/user_profile.py +59 -0
- maleo/identity/schemas/data/user_system_role.py +25 -0
- maleo/identity/schemas/metadata/__init__.py +0 -0
- maleo/identity/schemas/metadata/user.py +6 -0
- maleo/identity/schemas/parameter/__init__.py +0 -0
- maleo/identity/schemas/parameter/client/__init__.py +0 -0
- maleo/identity/schemas/parameter/client/organization.py +74 -0
- maleo/identity/schemas/parameter/client/organization_registration_code.py +24 -0
- maleo/identity/schemas/parameter/client/organization_role.py +42 -0
- maleo/identity/schemas/parameter/client/user.py +44 -0
- maleo/identity/schemas/parameter/client/user_organization.py +62 -0
- maleo/identity/schemas/parameter/client/user_organization_role.py +49 -0
- maleo/identity/schemas/parameter/client/user_profile.py +28 -0
- maleo/identity/schemas/parameter/client/user_system_role.py +43 -0
- maleo/identity/schemas/parameter/general/__init__.py +0 -0
- maleo/identity/schemas/parameter/general/organization.py +43 -0
- maleo/identity/schemas/parameter/general/organization_registration_code.py +30 -0
- maleo/identity/schemas/parameter/general/organization_role.py +14 -0
- maleo/identity/schemas/parameter/general/user.py +101 -0
- maleo/identity/schemas/parameter/general/user_organization.py +18 -0
- maleo/identity/schemas/parameter/general/user_organization_role.py +15 -0
- maleo/identity/schemas/parameter/general/user_profile.py +82 -0
- maleo/identity/schemas/parameter/general/user_system_role.py +30 -0
- maleo/identity/schemas/parameter/service/__init__.py +0 -0
- maleo/identity/schemas/parameter/service/organization.py +60 -0
- maleo/identity/schemas/parameter/service/organization_registration_code.py +24 -0
- maleo/identity/schemas/parameter/service/organization_role.py +35 -0
- maleo/identity/schemas/parameter/service/user.py +47 -0
- maleo/identity/schemas/parameter/service/user_organization_role.py +36 -0
- maleo/identity/schemas/parameter/service/user_profile.py +28 -0
- maleo/identity/schemas/parameter/service/user_system_role.py +31 -0
- maleo/identity/types/__init__.py +5 -0
- maleo/identity/types/base/__init__.py +0 -0
- maleo/identity/types/base/organization.py +5 -0
- maleo/identity/types/base/organization_registration_code.py +4 -0
- maleo/identity/types/base/user.py +5 -0
- maleo/identity/types/base/user_profile.py +4 -0
- {maleo_identity-0.0.76.dist-info → maleo_identity-0.0.78.dist-info}/METADATA +3 -3
- maleo_identity-0.0.78.dist-info/RECORD +101 -0
- maleo_identity-0.0.78.dist-info/top_level.txt +1 -0
- maleo_identity-0.0.76.dist-info/RECORD +0 -4
- maleo_identity-0.0.76.dist-info/top_level.txt +0 -1
- {maleo_identity-0.0.76.dist-info → maleo_identity-0.0.78.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from typing import Dict, List
|
|
2
|
+
from maleo.soma.schemas.resource import Resource, ResourceIdentifier
|
|
3
|
+
from maleo.identity.enums.user import ExpandableField as UserExpandableField
|
|
4
|
+
from maleo.identity.enums.organization import (
|
|
5
|
+
ExpandableField as OrganizationExpandableField,
|
|
6
|
+
)
|
|
7
|
+
from maleo.identity.enums.user_organization import (
|
|
8
|
+
ExpandableField as UserOrganizationExpandableField,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
EXPANDABLE_FIELDS_DEPENDENCIES_MAP: Dict[
|
|
12
|
+
UserOrganizationExpandableField, List[UserOrganizationExpandableField]
|
|
13
|
+
] = {
|
|
14
|
+
UserOrganizationExpandableField.USER: [
|
|
15
|
+
UserOrganizationExpandableField.USER_TYPE,
|
|
16
|
+
UserOrganizationExpandableField.PROFILE,
|
|
17
|
+
],
|
|
18
|
+
UserOrganizationExpandableField.PROFILE: [
|
|
19
|
+
UserOrganizationExpandableField.BLOOD_TYPE,
|
|
20
|
+
UserOrganizationExpandableField.GENDER,
|
|
21
|
+
],
|
|
22
|
+
UserOrganizationExpandableField.SYSTEM_ROLES: [
|
|
23
|
+
UserOrganizationExpandableField.SYSTEM_ROLE_DETAILS
|
|
24
|
+
],
|
|
25
|
+
UserOrganizationExpandableField.ORGANIZATION: [
|
|
26
|
+
UserOrganizationExpandableField.ORGANIZATION_TYPE,
|
|
27
|
+
UserOrganizationExpandableField.REGISTRATION_CODE,
|
|
28
|
+
],
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
USER_EXPANDABLE_FIELDS_MAP: Dict[
|
|
32
|
+
UserOrganizationExpandableField, UserExpandableField
|
|
33
|
+
] = {
|
|
34
|
+
UserOrganizationExpandableField.USER_TYPE: UserExpandableField.USER_TYPE,
|
|
35
|
+
UserOrganizationExpandableField.PROFILE: UserExpandableField.PROFILE,
|
|
36
|
+
UserOrganizationExpandableField.BLOOD_TYPE: UserExpandableField.BLOOD_TYPE,
|
|
37
|
+
UserOrganizationExpandableField.GENDER: UserExpandableField.GENDER,
|
|
38
|
+
UserOrganizationExpandableField.SYSTEM_ROLES: UserExpandableField.SYSTEM_ROLES,
|
|
39
|
+
UserOrganizationExpandableField.SYSTEM_ROLE_DETAILS: UserExpandableField.SYSTEM_ROLE_DETAILS,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ORGANIZATION_EXPANDABLE_FIELDS_MAP: Dict[
|
|
43
|
+
UserOrganizationExpandableField, OrganizationExpandableField
|
|
44
|
+
] = {
|
|
45
|
+
UserOrganizationExpandableField.ORGANIZATION_TYPE: OrganizationExpandableField.ORGANIZATION_TYPE,
|
|
46
|
+
UserOrganizationExpandableField.REGISTRATION_CODE: OrganizationExpandableField.REGISTRATION_CODE,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
RESOURCE = Resource(
|
|
50
|
+
identifiers=[
|
|
51
|
+
ResourceIdentifier(
|
|
52
|
+
key="user_organizations",
|
|
53
|
+
name="UserOrganizations",
|
|
54
|
+
url_slug="user-organizations",
|
|
55
|
+
)
|
|
56
|
+
],
|
|
57
|
+
details=None,
|
|
58
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from typing import Dict, List
|
|
2
|
+
from maleo.soma.schemas.resource import Resource, ResourceIdentifier
|
|
3
|
+
from maleo.identity.enums.user import ExpandableField as UserExpandableField
|
|
4
|
+
from maleo.identity.enums.organization import (
|
|
5
|
+
ExpandableField as OrganizationExpandableField,
|
|
6
|
+
)
|
|
7
|
+
from maleo.identity.enums.user_organization_role import (
|
|
8
|
+
ExpandableField as UserOrganizationRoleExpandableField,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
EXPANDABLE_FIELDS_DEPENDENCIES_MAP: Dict[
|
|
12
|
+
UserOrganizationRoleExpandableField, List[UserOrganizationRoleExpandableField]
|
|
13
|
+
] = {
|
|
14
|
+
UserOrganizationRoleExpandableField.USER: [
|
|
15
|
+
UserOrganizationRoleExpandableField.USER_TYPE,
|
|
16
|
+
UserOrganizationRoleExpandableField.PROFILE,
|
|
17
|
+
],
|
|
18
|
+
UserOrganizationRoleExpandableField.ORGANIZATION: [
|
|
19
|
+
UserOrganizationRoleExpandableField.ORGANIZATION_TYPE,
|
|
20
|
+
UserOrganizationRoleExpandableField.REGISTRATION_CODE,
|
|
21
|
+
],
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
USER_EXPANDABLE_FIELDS_MAP: Dict[
|
|
25
|
+
UserOrganizationRoleExpandableField, UserExpandableField
|
|
26
|
+
] = {
|
|
27
|
+
UserOrganizationRoleExpandableField.USER_TYPE: UserExpandableField.USER_TYPE,
|
|
28
|
+
UserOrganizationRoleExpandableField.PROFILE: UserExpandableField.PROFILE,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ORGANIZATION_EXPANDABLE_FIELDS_MAP: Dict[
|
|
32
|
+
UserOrganizationRoleExpandableField, OrganizationExpandableField
|
|
33
|
+
] = {
|
|
34
|
+
UserOrganizationRoleExpandableField.ORGANIZATION_TYPE: OrganizationExpandableField.ORGANIZATION_TYPE,
|
|
35
|
+
UserOrganizationRoleExpandableField.REGISTRATION_CODE: OrganizationExpandableField.REGISTRATION_CODE,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
RESOURCE = Resource(
|
|
39
|
+
identifiers=[
|
|
40
|
+
ResourceIdentifier(
|
|
41
|
+
key="user_organization_roles",
|
|
42
|
+
name="UserOrganizationRoles",
|
|
43
|
+
url_slug="user-organization-roles",
|
|
44
|
+
)
|
|
45
|
+
],
|
|
46
|
+
details=None,
|
|
47
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import Callable, Dict
|
|
2
|
+
from maleo.soma.schemas.resource import Resource, ResourceIdentifier
|
|
3
|
+
from maleo.identity.enums.user_profile import IdentifierType, ValidImageMimeType
|
|
4
|
+
from maleo.identity.types.base.user_profile import IdentifierValueType
|
|
5
|
+
|
|
6
|
+
IDENTIFIER_TYPE_VALUE_TYPE_MAP: Dict[
|
|
7
|
+
IdentifierType, Callable[..., IdentifierValueType]
|
|
8
|
+
] = {
|
|
9
|
+
IdentifierType.USER_ID: int,
|
|
10
|
+
IdentifierType.ID_CARD: str,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
MIME_TYPE_EXTENSION_MAP: Dict[ValidImageMimeType, str] = {
|
|
14
|
+
ValidImageMimeType.JPEG: ".jpeg",
|
|
15
|
+
ValidImageMimeType.JPG: ".jpg",
|
|
16
|
+
ValidImageMimeType.PNG: ".png",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
RESOURCE = Resource(
|
|
20
|
+
identifiers=[
|
|
21
|
+
ResourceIdentifier(
|
|
22
|
+
key="user_profiles", name="UserProfiles", url_slug="user-profiles"
|
|
23
|
+
)
|
|
24
|
+
],
|
|
25
|
+
details=None,
|
|
26
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from typing import Dict, List
|
|
2
|
+
from maleo.soma.schemas.resource import Resource, ResourceIdentifier
|
|
3
|
+
from maleo.identity.enums.user_system_role import ExpandableField
|
|
4
|
+
|
|
5
|
+
EXPANDABLE_FIELDS_DEPENDENCIES_MAP: Dict[ExpandableField, List[ExpandableField]] = {}
|
|
6
|
+
|
|
7
|
+
RESOURCE = Resource(
|
|
8
|
+
identifiers=[
|
|
9
|
+
ResourceIdentifier(
|
|
10
|
+
key="user_system_roles",
|
|
11
|
+
name="UserSystemRoles",
|
|
12
|
+
url_slug="user-system-roles",
|
|
13
|
+
)
|
|
14
|
+
],
|
|
15
|
+
details=None,
|
|
16
|
+
)
|
maleo/identity/db.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from maleo.soma.mixins.data import DataIdentifier, DataTimestamp, DataStatus
|
|
2
|
+
from maleo.identity.mixins.organization_registration_code import (
|
|
3
|
+
Code,
|
|
4
|
+
MaxUses,
|
|
5
|
+
CurrentUses,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class OrganizationRegistrationCodeDTO(
|
|
10
|
+
CurrentUses, MaxUses, Code, DataStatus, DataTimestamp, DataIdentifier
|
|
11
|
+
):
|
|
12
|
+
pass
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class IdentifierType(StrEnum):
|
|
5
|
+
ID = "id"
|
|
6
|
+
UUID = "uuid"
|
|
7
|
+
USERNAME = "username"
|
|
8
|
+
EMAIL = "email"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ExpandableField(StrEnum):
|
|
12
|
+
USER_TYPE = "user_type"
|
|
13
|
+
SYSTEM_ROLES = "system_roles"
|
|
14
|
+
SYSTEM_ROLE_DETAILS = "system_roles.system_role_details"
|
|
15
|
+
PROFILE = "profile"
|
|
16
|
+
GENDER = "profile.gender"
|
|
17
|
+
BLOOD_TYPE = "profile.blood_type"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ExpandableField(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"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ExpandableField(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"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class IdentifierType(StrEnum):
|
|
5
|
+
USER_ID = "user_id"
|
|
6
|
+
ID_CARD = "id_card"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ValidImageMimeType(StrEnum):
|
|
10
|
+
JPEG = "image/jpeg"
|
|
11
|
+
JPG = "image/jpg"
|
|
12
|
+
PNG = "image/png"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ExpandableField(StrEnum):
|
|
16
|
+
GENDER = "gender"
|
|
17
|
+
BLOOD_TYPE = "blood_type"
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from maleo.soma.mixins.parameter import Expand as BaseExpand
|
|
3
|
+
from maleo.identity.enums.organization import ExpandableField
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Expand(BaseExpand[ExpandableField]):
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Key(BaseModel):
|
|
11
|
+
key: str = Field(..., max_length=255, description="Organization's key")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Name(BaseModel):
|
|
15
|
+
name: str = Field(..., max_length=255, description="Organization's name")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Code(BaseModel):
|
|
6
|
+
code: UUID = Field(..., description="Registration code")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MaxUses(BaseModel):
|
|
10
|
+
max_uses: int = Field(1, ge=1, description="Max code uses")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CurrentUses(BaseModel):
|
|
14
|
+
current_uses: int = Field(0, ge=0, description="Current code uses")
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from maleo.soma.mixins.parameter import Expand as BaseExpand
|
|
3
|
+
from maleo.identity.enums.organization_role import ExpandableField
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Expand(BaseExpand[ExpandableField]):
|
|
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")
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
from maleo.soma.mixins.parameter import Expand as BaseExpand
|
|
4
|
+
from maleo.soma.types.base import OptionalListOfStrings
|
|
5
|
+
from maleo.identity.enums.user import ExpandableField
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Expand(BaseExpand[ExpandableField]):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Username(BaseModel):
|
|
13
|
+
username: str = Field(..., max_length=50, description="User's username")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class OptionalListOfUsernames(BaseModel):
|
|
17
|
+
usernames: OptionalListOfStrings = Field(None, description="Specific usernames")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Email(BaseModel):
|
|
21
|
+
email: str = Field(..., max_length=255, description="User's email")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class OptionalListOfEmails(BaseModel):
|
|
25
|
+
emails: OptionalListOfStrings = Field(None, description="Specific emails")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Phone(BaseModel):
|
|
29
|
+
phone: str = Field(..., min_length=4, max_length=15, description="User's phone")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class OptionalListOfPhones(BaseModel):
|
|
33
|
+
phones: OptionalListOfStrings = Field(None, description="Specific phones")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Password(BaseModel):
|
|
37
|
+
password: str = Field(..., max_length=255, description="User's password")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class PasswordConfirmation(BaseModel):
|
|
41
|
+
password_confirmation: str = Field(
|
|
42
|
+
..., max_length=255, description="User's password confirmation"
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class RegistrationCode(BaseModel):
|
|
47
|
+
registration_code: UUID = Field(..., description="Registration code")
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from maleo.soma.mixins.parameter import Expand as BaseExpand
|
|
4
|
+
from maleo.soma.types.base import OptionalDate, OptionalString
|
|
5
|
+
from maleo.identity.enums.user_profile import ExpandableField
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Expand(BaseExpand[ExpandableField]):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class IdCard(BaseModel):
|
|
13
|
+
id_card: str = Field(..., max_length=16, description="User's ID Card")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class OptionalIdCard(BaseModel):
|
|
17
|
+
id_card: OptionalString = Field(
|
|
18
|
+
None, max_length=16, description="Optional User's ID Card"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class LeadingTitle(BaseModel):
|
|
23
|
+
leading_title: OptionalString = Field(
|
|
24
|
+
None, max_length=25, description="User's leading title"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class FirstName(BaseModel):
|
|
29
|
+
first_name: str = Field(..., max_length=50, description="User's first name")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MiddleName(BaseModel):
|
|
33
|
+
middle_name: OptionalString = Field(
|
|
34
|
+
None, max_length=50, description="User's middle name"
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class LastName(BaseModel):
|
|
39
|
+
last_name: str = Field(..., max_length=50, description="User's last name")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class EndingTitle(BaseModel):
|
|
43
|
+
ending_title: OptionalString = Field(
|
|
44
|
+
None, max_length=25, description="User's ending title"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class FullName(BaseModel):
|
|
49
|
+
full_name: str = Field(..., max_length=200, description="User's full name")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class BirthPlace(BaseModel):
|
|
53
|
+
birth_place: OptionalString = Field(
|
|
54
|
+
None, max_length=50, description="User's birth place"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class BirthDate(BaseModel):
|
|
59
|
+
birth_date: OptionalDate = Field(None, description="User's birth date")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class AvatarName(BaseModel):
|
|
63
|
+
avatar_name: str = Field(..., description="User's avatar's name")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class OptionalAvatarUrl(BaseModel):
|
|
67
|
+
avatar_url: OptionalString = Field(None, description="Avatar's URL")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class OptionalAvatar(BaseModel):
|
|
71
|
+
avatar: Optional[bytes] = Field(None, description="Optional Avatar")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class OptionalAvatarName(BaseModel):
|
|
75
|
+
avatar_name: OptionalString = Field(None, description="Optional avatar's name")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class OptionalAvatarContentType(BaseModel):
|
|
79
|
+
content_type: OptionalString = Field(
|
|
80
|
+
None, description="Optional avatar's content type"
|
|
81
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
)
|