rococo 0.1.44__tar.gz → 0.1.45__tar.gz
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.
- {rococo-0.1.44 → rococo-0.1.45}/PKG-INFO +1 -1
- rococo-0.1.45/rococo/models/organization.py +22 -0
- rococo-0.1.45/rococo/models/person_organization_role.py +31 -0
- rococo-0.1.45/rococo/repositories/__init__.py +7 -0
- rococo-0.1.45/rococo/repositories/organization_repository.py +18 -0
- rococo-0.1.45/rococo/repositories/person_organization_role_repository.py +35 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo.egg-info/PKG-INFO +1 -1
- {rococo-0.1.44 → rococo-0.1.45}/rococo.egg-info/SOURCES.txt +2 -0
- {rococo-0.1.44 → rococo-0.1.45}/setup.py +1 -1
- rococo-0.1.44/rococo/models/organization.py +0 -14
- rococo-0.1.44/rococo/models/person_organization_role.py +0 -18
- rococo-0.1.44/rococo/repositories/__init__.py +0 -5
- {rococo-0.1.44 → rococo-0.1.45}/LICENSE +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/README.md +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/__init__.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/config/__init__.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/config/config.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/data/__init__.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/data/base.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/data/surrealdb.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/emailing/__init__.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/emailing/base.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/emailing/config.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/emailing/enums.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/emailing/factory.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/emailing/mailjet.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/emailing/ses.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/messaging/__init__.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/messaging/base.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/messaging/rabbitmq.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/messaging/sqs.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/models/__init__.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/models/email.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/models/login_method.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/models/otp_method.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/models/person.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/models/versioned_model.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/repositories/base_repository.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo/repositories/surreal_db_repository.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo.egg-info/dependency_links.txt +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo.egg-info/requires.txt +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/rococo.egg-info/top_level.txt +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/setup.cfg +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/tests/__init__.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/tests/base_repository_test.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/tests/config_test.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/tests/model_test.py +0 -0
- {rococo-0.1.44 → rococo-0.1.45}/tests/surreal_db_repository_test.py +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Organization model
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from . import VersionedModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class Organization(VersionedModel):
|
|
12
|
+
"""An organization model."""
|
|
13
|
+
|
|
14
|
+
name: str = None
|
|
15
|
+
code: str = None
|
|
16
|
+
description: str = None
|
|
17
|
+
# members (with accompanied roles, including `owner`) are maintained through `PersonOrganizationRole`
|
|
18
|
+
|
|
19
|
+
# TODO: to see do we want redundancy, to have a relationship from an `Organization` to its `owner`
|
|
20
|
+
# despite that `roles` in Organization (including the `owner`) are defined through `PersonOrganizationRole`
|
|
21
|
+
|
|
22
|
+
# we could support relationships and hierarchy among organizations
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""
|
|
2
|
+
PersonOrganizationRole model
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
|
|
7
|
+
from . import VersionedModel
|
|
8
|
+
|
|
9
|
+
# from enum import Enum
|
|
10
|
+
|
|
11
|
+
# class PersonOrganizationRoleEnum(Enum):
|
|
12
|
+
# OWNER = "OWNER"
|
|
13
|
+
# MANAGER = "MANAGER"
|
|
14
|
+
# MEMBER = "MEMBER"
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class PersonOrganizationRole(VersionedModel):
|
|
18
|
+
"""A person organization role model."""
|
|
19
|
+
|
|
20
|
+
person: str = field(metadata={
|
|
21
|
+
'relationship': {'model': 'Person', 'type': 'direct'},
|
|
22
|
+
'field_type': 'record_id'
|
|
23
|
+
})
|
|
24
|
+
organization: str = field(metadata={
|
|
25
|
+
'relationship': {'model': 'Organization', 'type': 'direct'},
|
|
26
|
+
'field_type': 'record_id'
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
# TODO: We would benefit from strictly typed Enum for role, but flexibility would lower
|
|
30
|
+
# role: PersonOrganizationRoleEnum = PersonOrganizationRoleEnum.MEMBER
|
|
31
|
+
role: str
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""
|
|
2
|
+
base repository for rococo
|
|
3
|
+
"""
|
|
4
|
+
from .base_repository import BaseRepository
|
|
5
|
+
from .surreal_db_repository import SurrealDbRepository
|
|
6
|
+
from .organization_repository import OrganizationRepository
|
|
7
|
+
from .person_organization_role_repository import PersonOrganizationRoleRepository
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from rococo.models import Organization
|
|
2
|
+
from rococo.repositories import SurrealDbRepository
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class OrganizationRepository(SurrealDbRepository):
|
|
6
|
+
def __init__(self, adapter, message_adapter, message_queue_name):
|
|
7
|
+
super().__init__(adapter, Organization, message_adapter, message_queue_name)
|
|
8
|
+
|
|
9
|
+
def find_by_name(self, name: str):
|
|
10
|
+
conditions = {"name": name}
|
|
11
|
+
return self.get_one(conditions)
|
|
12
|
+
|
|
13
|
+
def update_organization_name(self, organization_id: str, new_name: str):
|
|
14
|
+
instance = self.get_one({"entity_id": organization_id})
|
|
15
|
+
if instance:
|
|
16
|
+
instance.name = new_name
|
|
17
|
+
return self.save(instance)
|
|
18
|
+
return None
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import copy
|
|
2
|
+
from typing import List, Union
|
|
3
|
+
from .surreal_db_repository import SurrealDbRepository
|
|
4
|
+
from rococo.models import PersonOrganizationRole
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class PersonOrganizationRoleRepository(SurrealDbRepository):
|
|
8
|
+
def __init__(self, adapter, message_adapter, message_queue_name):
|
|
9
|
+
super().__init__(adapter, PersonOrganizationRole, message_adapter, message_queue_name)
|
|
10
|
+
|
|
11
|
+
def find_organizations_by_member(self, member_id: str, get_member: bool = False) -> List[PersonOrganizationRole]:
|
|
12
|
+
"""finds all the organizations that a Person identified by member_id is a member of
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
member_id (str): `person.entity_id`
|
|
16
|
+
get_member (bool, optional): should a member (Person) be fetched too?. Defaults to False.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
List[PersonOrganizationRole]: found PersonOrganizationRole
|
|
20
|
+
"""
|
|
21
|
+
conditions = {"person.entity_id": member_id}
|
|
22
|
+
fetch_related: List[str] = ["organization", "person"] if get_member else ["organization"]
|
|
23
|
+
return self.get_many(conditions, fetch_related=fetch_related)
|
|
24
|
+
|
|
25
|
+
def find_by_owner(self, owner_id: str, get_owner: bool = False) -> List[PersonOrganizationRole]:
|
|
26
|
+
# TODO
|
|
27
|
+
conditions = {"person.entity_id": owner_id}
|
|
28
|
+
fetch_related: List[str] = ["organization", "person"] if get_owner else ["organization"]
|
|
29
|
+
return self.get_many(conditions, fetch_related=fetch_related)
|
|
30
|
+
|
|
31
|
+
# in the case we chose to have `role` as a `PersonOrganizationRoleEnum` instead of `str`
|
|
32
|
+
# def save(self, instance: PersonOrganizationRole, send_message: bool = False) -> PersonOrganizationRole:
|
|
33
|
+
# instance_copy = copy.copy(instance)
|
|
34
|
+
# instance_copy.role = instance.role.value
|
|
35
|
+
# super().save(instance=instance_copy, send_message=send_message)
|
|
@@ -33,6 +33,8 @@ rococo/models/person_organization_role.py
|
|
|
33
33
|
rococo/models/versioned_model.py
|
|
34
34
|
rococo/repositories/__init__.py
|
|
35
35
|
rococo/repositories/base_repository.py
|
|
36
|
+
rococo/repositories/organization_repository.py
|
|
37
|
+
rococo/repositories/person_organization_role_repository.py
|
|
36
38
|
rococo/repositories/surreal_db_repository.py
|
|
37
39
|
tests/__init__.py
|
|
38
40
|
tests/base_repository_test.py
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
PersonOrganizationRole model
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from dataclasses import dataclass, field
|
|
6
|
-
|
|
7
|
-
from . import VersionedModel
|
|
8
|
-
|
|
9
|
-
@dataclass
|
|
10
|
-
class PersonOrganizationRole(VersionedModel):
|
|
11
|
-
"""A person organization role model."""
|
|
12
|
-
|
|
13
|
-
person: str = field(metadata={
|
|
14
|
-
'relationship': {'model': 'Person', 'type': 'direct'},
|
|
15
|
-
'field_type': 'record_id'
|
|
16
|
-
})
|
|
17
|
-
organization_id: str
|
|
18
|
-
role: str
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|