diff --git a/apps/questionnaire/models.py b/apps/questionnaire/models.py index 72f3434..212c2ad 100644 --- a/apps/questionnaire/models.py +++ b/apps/questionnaire/models.py @@ -160,10 +160,10 @@ class Category2(models.IntegerChoices): # -- AT_RISK PEOPLE_AT_RISK = 2201, 'People At risk' # -- PRIORITIES - PRIOTIY_ISSUES_POP = 2301, 'Priotiy Issues (Pop)' - PRIOTIY_ISSUES_HUM = 2302, 'Priotiy Issues (Hum)' - PRIOTIY_INTERVENTIONS_POP = 2303, 'Priotiy Interventions (Pop)' - PRIOTIY_INTERVENTIONS_HUM = 2304, 'Priotiy Interventions (Hum)' + PRIORITY_ISSUES_POP = 2301, 'Priotiy Issues (Pop)' + PRIORITY_ISSUES_HUM = 2302, 'Priotiy Issues (Hum)' + PRIORITY_INTERVENTIONS_POP = 2303, 'Priotiy Interventions (Pop)' + PRIORITY_INTERVENTIONS_HUM = 2304, 'Priotiy Interventions (Hum)' # -- CAPACITIES_RESPONSE GOVERNMENT_LOCAL_AUTHORITIES = 2401, 'Government Local Authorities' INTERNATIONAL_ORGANISATIONS = 2402, 'International Organisations' @@ -289,10 +289,10 @@ class Category4(models.IntegerChoices): Category2.PEOPLE_AT_RISK, }, Category1.PRIORITIES: { - Category2.PRIOTIY_ISSUES_POP, - Category2.PRIOTIY_ISSUES_HUM, - Category2.PRIOTIY_INTERVENTIONS_POP, - Category2.PRIOTIY_INTERVENTIONS_HUM, + Category2.PRIORITY_ISSUES_POP, + Category2.PRIORITY_ISSUES_HUM, + Category2.PRIORITY_INTERVENTIONS_POP, + Category2.PRIORITY_INTERVENTIONS_HUM, }, Category1.CAPACITIES_RESPONSE: { Category2.GOVERNMENT_LOCAL_AUTHORITIES, diff --git a/schema.graphql b/schema.graphql index 29425df..fa6b7cb 100644 --- a/schema.graphql +++ b/schema.graphql @@ -8,9 +8,6 @@ input DjangoModelFilterInput { pk: ID! } -"""Provide label for enum values""" -scalar EnumDescription - input IDFilterLookup { exact: ID iExact: ID @@ -411,10 +408,10 @@ enum QuestionLeafGroupCategory2TypeEnum { COPING_MECHANISMS PHYSICAL_AND_MENTAL_WELLBEING PEOPLE_AT_RISK - PRIOTIY_ISSUES_POP - PRIOTIY_ISSUES_HUM - PRIOTIY_INTERVENTIONS_POP - PRIOTIY_INTERVENTIONS_HUM + PRIORITY_ISSUES_POP + PRIORITY_ISSUES_HUM + PRIORITY_INTERVENTIONS_POP + PRIORITY_INTERVENTIONS_HUM GOVERNMENT_LOCAL_AUTHORITIES INTERNATIONAL_ORGANISATIONS NATION_AND_LOCAL_ORGANISATIONS @@ -484,18 +481,18 @@ type QuestionLeafGroupType { isHidden: Boolean! relevant: String! category1: QuestionLeafGroupCategory1TypeEnum! - category1Display: EnumDescription! + category1Display: String! category2: QuestionLeafGroupCategory2TypeEnum! - category2Display: EnumDescription! + category2Display: String! category3: QuestionLeafGroupCategory3TypeEnum - category3Display: EnumDescription + category3Display: String category4: QuestionLeafGroupCategory4TypeEnum - category4Display: EnumDescription + category4Display: String createdBy: UserType! modifiedBy: UserType! questionnaireId: ID! type: QuestionLeafGroupTypeEnum! - typeDisplay: EnumDescription! + typeDisplay: String! } type QuestionLeafGroupTypeBulkBasicMutationResponseType { @@ -553,7 +550,7 @@ type QuestionType { modifiedBy: UserType! questionnaireId: ID! type: QuestionTypeEnum! - typeDisplay: EnumDescription! + typeDisplay: String! } type QuestionTypeCountList { @@ -705,7 +702,7 @@ type UserMeType { displayName: String! email: String! emailOptOuts: [OptEmailNotificationTypeEnum!]! - emailOptOutsDisplay: [EnumDescription!]! + emailOptOutsDisplay: [String!]! } type UserMeTypeMutationResponseType { diff --git a/utils/strawberry/enums.py b/utils/strawberry/enums.py index 15bb696..c398b0d 100644 --- a/utils/strawberry/enums.py +++ b/utils/strawberry/enums.py @@ -75,15 +75,7 @@ def _get_serializer_name(_field): raise Exception(f'{serializer_name=} should have a value') -EnumDescription = strawberry.scalar( - typing.NewType("EnumDescription", str), - description="Provide label for enum values", - serialize=lambda v: v, - parse_value=lambda v: v, -) - - -def enum_display_field(field: models.query_utils.DeferredAttribute) -> typing.Callable[..., EnumDescription]: +def enum_display_field(field: models.query_utils.DeferredAttribute) -> typing.Callable[..., str]: _field = field.field if is_array := isinstance(_field, ArrayField): @@ -108,18 +100,18 @@ def _get_value(root) -> None | str | list[str]: ) @strawberry.field - def array_field_(root) -> list[EnumDescription]: + def array_field_(root) -> list[str]: return _get_value(root) if is_array: return array_field_ @strawberry.field - def field_(root) -> EnumDescription: + def field_(root) -> str: return _get_value(root) @strawberry.field - def nullable_field_(root) -> typing.Optional[EnumDescription]: + def nullable_field_(root) -> typing.Optional[str]: return _get_value(root) if _field.null: