forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_affiliations.py
More file actions
40 lines (32 loc) · 1.1 KB
/
user_affiliations.py
File metadata and controls
40 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import graphene
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyObjectType
from graphene_sqlalchemy.types import ORMField
from enums.roles import RoleEnums
from models import User_affiliations as UserAff
class UserAffClass(SQLAlchemyObjectType):
class Meta:
model = UserAff
interfaces = (relay.Node,)
exclude_fields = (
"id",
"user_id",
"organization_id",
"permission",
"user",
"user_organization",
)
user_id = graphene.Int(description="User's ID")
user = ORMField(model_attr="user")
permission = RoleEnums(description="User's level of access to a given organization")
organization = ORMField(
model_attr="user_organization",
description="The organization this affiliation belongs to",
)
def resolve_user_id(self: UserAff, info, **kwargs):
return self.user_id
def resolve_permission(self: UserAff, info, **kwargs):
return self.permission
class UserAffConnection(relay.Connection):
class Meta:
node = UserAffClass