From e6c610bae78531136ffc73f345362c27088cd421 Mon Sep 17 00:00:00 2001 From: sniedzielski <52816247+sniedzielski@users.noreply.github.com> Date: Tue, 16 Apr 2024 17:34:25 +0200 Subject: [PATCH] CM-835: added possibility to default configure roles for staff assignment (#10) --- grievance_social_protection/apps.py | 6 +++++- grievance_social_protection/gql_queries.py | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/grievance_social_protection/apps.py b/grievance_social_protection/apps.py index 73e8b45..e478650 100644 --- a/grievance_social_protection/apps.py +++ b/grievance_social_protection/apps.py @@ -10,7 +10,6 @@ # CRON timedelta: {days},{hours} DEFAULT_TIME_RESOLUTION = '5,0' - DEFAULT_CFG = { "default_validations_disabled": False, "gql_query_tickets_perms": ["123000"], @@ -31,6 +30,9 @@ # CRON timedelta: {days},{hours} "resolution_times": DEFAULT_TIME_RESOLUTION, "default_resolution": {DEFAULT_STRING: DEFAULT_TIME_RESOLUTION}, + + "attending_staff_role_ids": [], + "default_attending_staff_role_ids": {DEFAULT_STRING: [1, 2]}, } @@ -54,6 +56,8 @@ class TicketConfig(AppConfig): grievance_anonymized_fields = {} resolution_times = {} default_resolution = {} + attending_staff_role_ids = [] + default_attending_staff_role_ids = {} def ready(self): from core.models import ModuleConfiguration diff --git a/grievance_social_protection/gql_queries.py b/grievance_social_protection/gql_queries.py index e4e6f50..be371ed 100644 --- a/grievance_social_protection/gql_queries.py +++ b/grievance_social_protection/gql_queries.py @@ -83,10 +83,16 @@ def resolve_client_mutation_id(self, info): # return queryset +class AttendingStaffRoleGQLType(ObjectType): + category = graphene.String() + role_ids = graphene.List(graphene.String) + + class GrievanceTypeConfigurationGQLType(ObjectType): grievance_types = graphene.List(graphene.String) grievance_flags = graphene.List(graphene.String) grievance_channels = graphene.List(graphene.String) + grievance_category_staff_roles = graphene.List(AttendingStaffRoleGQLType) def resolve_grievance_types(self, info): return TicketConfig.grievance_types @@ -96,3 +102,14 @@ def resolve_grievance_flags(self, info): def resolve_grievance_channels(self, info): return TicketConfig.grievance_channels + + def resolve_grievance_category_staff_roles(self, info): + category_staff_role_list = [] + for category_key, role_ids in TicketConfig.default_attending_staff_role_ids.items(): + category_staff_role = AttendingStaffRoleGQLType( + category=category_key, + role_ids=role_ids + ) + category_staff_role_list.append(category_staff_role) + + return category_staff_role_list