Skip to content

Commit

Permalink
Change name convention in for Summary Tab's element.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rup-Narayan-Rajbanshi committed Aug 3, 2023
1 parent 9384c76 commit 062beda
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 177 deletions.
12 changes: 6 additions & 6 deletions apps/assessment_registry/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@
AssessmentRegistrySummaryPillarTypeEnum = convert_enum_to_graphene_enum(
Summary.Pillar, name='AssessmentRegistrySummaryPillarTypeEnum'
)
AssessmentRegistrySummaryFocusSectorTypeEnum = convert_enum_to_graphene_enum(
SummaryFocus.Sector, name='AssessmentRegistrySummaryFocusSectorTypeEnum'
AssessmentRegistrySummaryFocusDimmensionTypeEnum = convert_enum_to_graphene_enum(
SummaryFocus.Dimmension, name='AssessmentRegistrySummaryFocusDimmensionTypeEnum'
)
AssessmentRegistrySummaryFocusSubSectorTypeEnum = convert_enum_to_graphene_enum(
SummaryIssue.FocusSubSector, name='AssessmentRegistrySummaryFocusSubSectorTypeEnum'
AssessmentRegistrySummarySubDimmensionTypeEnum = convert_enum_to_graphene_enum(
SummaryIssue.SubDimmension, name='AssessmentRegistrySummarySubDimmensionTypeEnum'
)
AssessmentRegistrySummarySubPillarTypeEnum = convert_enum_to_graphene_enum(
SummaryIssue.SubPillar, name='AssessmentRegistrySummarySubPillarTypeEnum'
Expand Down Expand Up @@ -134,7 +134,7 @@
(ScoreAnalyticalDensity.analysis_level_covered, AssessmentRegistryAnalysisLevelTypeEnum),
(ScoreAnalyticalDensity.figure_provided, AssessmentRegistryAnalysisFigureTypeEnum),
(SummaryFocusSubSectorIssue.focus, AssessmentRegistryFocusTypeEnum),
(SummaryIssue.sub_sector, AssessmentRegistrySummarySubPillarTypeEnum),
(SummaryIssue.focus_sub_sector, AssessmentRegistrySummaryFocusSubSectorTypeEnum),
(SummaryIssue.sub_pillar, AssessmentRegistrySummarySubPillarTypeEnum),
(SummaryIssue.sub_dimmension, AssessmentRegistrySummarySubDimmensionTypeEnum),
)
}
6 changes: 3 additions & 3 deletions apps/assessment_registry/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from lead.models import Lead

from .models import AssessmentRegistry, SummaryIssue
from .enums import AssessmentRegistrySummarySubPillarTypeEnum, AssessmentRegistrySummaryFocusSubSectorTypeEnum
from .enums import AssessmentRegistrySummarySubPillarTypeEnum, AssessmentRegistrySummarySubDimmensionTypeEnum


class AssessmentRegistryGQFilterSet(UserResourceGqlFilterSet):
Expand Down Expand Up @@ -50,8 +50,8 @@ def filter_assessment_registry(self, qs, name, value):


class IssueGQFilterSet(django_filters.FilterSet):
sub_sector = SimpleInputFilter(AssessmentRegistrySummarySubPillarTypeEnum)
focus_sub_sector = SimpleInputFilter(AssessmentRegistrySummaryFocusSubSectorTypeEnum)
sub_pillar = SimpleInputFilter(AssessmentRegistrySummarySubPillarTypeEnum)
sub_dimmension = SimpleInputFilter(AssessmentRegistrySummarySubDimmensionTypeEnum)

class Meta:
model = SummaryIssue
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.17 on 2023-08-03 04:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('assessment_registry', '0013_auto_20230803_0222'),
]

operations = [
migrations.AlterField(
model_name='scorerating',
name='score_type',
field=models.IntegerField(choices=[(0, 'Relevance'), (1, 'Comprehensiveness'), (2, 'Timeliness'), (3, 'Granularity'), (4, 'Comparability'), (5, 'Source reability'), (6, 'Methods'), (7, 'Triangulation'), (8, 'Plausibility'), (9, 'Inclusiveness'), (10, 'Assumptions'), (11, 'Corroboration'), (12, 'Structured Ananlytical Technique'), (13, 'Consensus'), (14, 'Reproducibility'), (15, 'Clearly Articulated Result'), (16, 'Level Of Confidence'), (17, 'Illustration'), (18, 'Sourced data and evidence'), (19, 'Clearly stated outliers')]),
),
]
23 changes: 23 additions & 0 deletions apps/assessment_registry/migrations/0015_auto_20230803_0608.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.17 on 2023-08-03 06:08

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('assessment_registry', '0014_alter_scorerating_score_type'),
]

operations = [
migrations.RenameField(
model_name='summaryissue',
old_name='focus_sub_sector',
new_name='sub_dimmension',
),
migrations.RenameField(
model_name='summaryissue',
old_name='sub_sector',
new_name='sub_pillar',
),
]
8 changes: 4 additions & 4 deletions apps/assessment_registry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ class SummarySubPillarIssue(UserResource):


class SummaryFocus(UserResource):
class Sector(models.IntegerChoices):
class Dimmension(models.IntegerChoices):
IMPACT = 0, 'Impact'
HUMANITARIAN_CONDITIONS = 1, 'Humanitarian Conditions'
PRIORITIES_AND_PREFERENCES = 2, 'Priorities & Preferences'
Expand Down Expand Up @@ -594,7 +594,7 @@ class SubPillar(models.IntegerChoices):
RELIEF_TO_POPULATION = 20, 'Relief To Population'
PHYSICAL_AND_SECURITY = 21, 'Physical & Security'

class FocusSubSector(models.IntegerChoices):
class SubDimmension(models.IntegerChoices):
DRIVERS = 0, 'Drivers'
IMPACT_ON_PEOPLE = 1, 'Impact on People'
IMPACT_ON_SYSTEM = 2, 'Impact On System, Network And Services'
Expand All @@ -611,8 +611,8 @@ class FocusSubSector(models.IntegerChoices):
PEOPLE_AT_RISKS = 13, 'People At Risks'
FOCAL_ISSUES = 14, 'Focal Issues'

sub_sector = models.IntegerField(choices=SubPillar.choices, blank=True, null=True)
focus_sub_sector = models.IntegerField(choices=FocusSubSector.choices, blank=True, null=True)
sub_pillar = models.IntegerField(choices=SubPillar.choices, blank=True, null=True)
sub_dimmension = models.IntegerField(choices=SubDimmension.choices, blank=True, null=True)
parent = models.ForeignKey(
'SummaryIssue',
on_delete=models.CASCADE,
Expand Down
119 changes: 57 additions & 62 deletions apps/assessment_registry/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
AssessmentRegistryCNAQuestionSubSectorTypeEnum,
AssessmentRegistrySummaryPillarTypeEnum,
AssessmentRegistrySummarySubPillarTypeEnum,
AssessmentRegistrySummaryFocusSectorTypeEnum,
AssessmentRegistrySummaryFocusSubSectorTypeEnum,
AssessmentRegistrySummaryFocusDimmensionTypeEnum,
AssessmentRegistrySummarySubDimmensionTypeEnum,
)


Expand All @@ -79,13 +79,13 @@ class SummarySubSectorType(graphene.ObjectType):


class SummaryOptionType(graphene.ObjectType):
sector = graphene.Field(AssessmentRegistrySummaryPillarTypeEnum, required=True)
sub_sector = graphene.List(graphene.NonNull(AssessmentRegistrySummarySubPillarTypeEnum), required=True)
pillar = graphene.Field(AssessmentRegistrySummaryPillarTypeEnum, required=True)
sub_pillar = graphene.List(graphene.NonNull(AssessmentRegistrySummarySubPillarTypeEnum), required=True)


class SummaryFocusOptionType(graphene.ObjectType):
sector = graphene.Field(AssessmentRegistrySummaryFocusSectorTypeEnum, required=False)
sub_sector = graphene.List(graphene.NonNull(AssessmentRegistrySummaryFocusSubSectorTypeEnum), required=False)
dimmension = graphene.Field(AssessmentRegistrySummaryFocusDimmensionTypeEnum, required=False)
sub_dimmension = graphene.List(graphene.NonNull(AssessmentRegistrySummarySubDimmensionTypeEnum), required=False)


class ScoreOptionsType(graphene.ObjectType):
Expand Down Expand Up @@ -122,36 +122,36 @@ def resolve_cna_questions(root, info, **kwargs):
def resolve_summary_options(root, info, **kwargs):
return [
SummaryOptionType(
sector=enum,
sub_sector=[
pillar=enum,
sub_pillar=[
enum for enum, _ in SummaryIssue.SubPillar.choices if 0 <= enum <= 5
]
) for enum, _ in Summary.Pillar.choices if enum == 0
] + [
SummaryOptionType(
sector=enum,
sub_sector=[
pillar=enum,
sub_pillar=[
enum for enum, _ in SummaryIssue.SubPillar.choices if 6 <= enum <= 9
]
) for enum, _ in Summary.Pillar.choices if enum == 1
] + [
SummaryOptionType(
sector=enum,
sub_sector=[
pillar=enum,
sub_pillar=[
enum for enum, _ in SummaryIssue.SubPillar.choices if 10 <= enum <= 14
]
) for enum, _ in Summary.Pillar.choices if enum == 2
] + [
SummaryOptionType(
sector=enum,
sub_sector=[
pillar=enum,
sub_pillar=[
enum for enum, _ in SummaryIssue.SubPillar.choices if 15 <= enum <= 18
]
) for enum, _ in Summary.Pillar.choices if enum == 3
] + [
SummaryOptionType(
sector=enum,
sub_sector=[
pillar=enum,
sub_pillar=[
enum for enum, _ in SummaryIssue.SubPillar.choices if 19 <= enum <= 21
]
) for enum, _ in Summary.Pillar.choices if enum == 4
Expand All @@ -161,32 +161,32 @@ def resolve_summary_options(root, info, **kwargs):
def resolve_summary_focus_options(root, info, **kwargs):
return [
SummaryFocusOptionType(
sector=enum,
sub_sector=[
enum for enum, _ in SummaryIssue.SubPillar.choices if 0 <= enum <= 2
dimmension=enum,
sub_dimmension=[
enum for enum, _ in SummaryIssue.SubDimmension.choices if 0 <= enum <= 2
]
) for enum, _ in Summary.Pillar.choices if enum == 0
) for enum, _ in SummaryFocus.Dimmension.choices if enum == 0
] + [
SummaryFocusOptionType(
sector=enum,
sub_sector=[
enum for enum, _ in SummaryIssue.SubPillar.choices if 3 <= enum <= 5
dimmension=enum,
sub_dimmension=[
enum for enum, _ in SummaryIssue.SubDimmension.choices if 3 <= enum <= 5
]
) for enum, _ in Summary.Pillar.choices if enum == 1
) for enum, _ in SummaryFocus.Dimmension.choices if enum == 1
] + [
SummaryFocusOptionType(
sector=enum,
sub_sector=[
enum for enum, _ in SummaryIssue.SubPillar.choices if 6 <= enum <= 9
dimmension=enum,
sub_dimmension=[
enum for enum, _ in SummaryIssue.SubDimmension.choices if 6 <= enum <= 9
]
) for enum, _ in Summary.Pillar.choices if enum == 2
) for enum, _ in SummaryFocus.Dimmension.choices if enum == 2
] + [
SummaryFocusOptionType(
sector=enum,
sub_sector=[
enum for enum, _ in SummaryIssue.SubPillar.choices if 10 <= enum <= 14
dimmension=enum,
sub_dimmension=[
enum for enum, _ in SummaryIssue.SubDimmension.choices if 10 <= enum <= 14
]
) for enum, _ in Summary.Pillar.choices if enum == 3
) for enum, _ in SummaryFocus.Dimmension.choices if enum == 3
]


Expand All @@ -208,12 +208,8 @@ class Meta:

sector = graphene.Field(AssessmentRegistrySectorTypeEnum, required=True)
sector_display = EnumDescription(source='get_sector_display', required=True)

analysis_level_covered = graphene.Field(AssessmentRegistryAnalysisLevelTypeEnum, required=True)
analysis_level_covered_display = EnumDescription(source='get_analysis_level_covered_display', required=True)

figure_provided = graphene.Field(AssessmentRegistryAnalysisFigureTypeEnum, required=True)
figure_provided_display = EnumDescription(source='get_figure_provided_display', required=True)
analysis_level_covered = graphene.List(graphene.NonNull(AssessmentRegistryAnalysisLevelTypeEnum), required=True)
figure_provided = graphene.List(graphene.NonNull(AssessmentRegistryAnalysisFigureTypeEnum), required=True)


def get_assessment_registry_qs(info):
Expand Down Expand Up @@ -256,7 +252,7 @@ def resolve_external_link(root, info, **kwargs):
return render_string_for_graphql(root.external_link)


class CNAType(DjangoObjectType, UserResourceMixin):
class CNAType(DjangoObjectType, UserResourceMixin, ClientIdMixin):
question = graphene.Field(QuestionType, required=True)

class Meta:
Expand All @@ -265,10 +261,10 @@ class Meta:


class IssueType(DjangoObjectType, UserResourceMixin):
sub_sector = graphene.Field(AssessmentRegistrySummarySubPillarTypeEnum, required=False)
sub_sector_display = graphene.String(required=False)
focus_sub_sector = graphene.Field(AssessmentRegistrySummaryFocusSubSectorTypeEnum, required=False)
focus_sub_sector_display = graphene.String(required=False)
sub_pillar = graphene.Field(AssessmentRegistrySummarySubPillarTypeEnum, required=False)
sub_pillar_display = graphene.String(required=False)
sub_dimmension = graphene.Field(AssessmentRegistrySummarySubDimmensionTypeEnum, required=False)
sub_dimmension_display = graphene.String(required=False)

class Meta:
model = SummaryIssue
Expand All @@ -277,15 +273,15 @@ class Meta:
]

@staticmethod
def resolve_sub_sector_display(root, info, **kwargs):
if root.sub_sector is not None:
return root.get_sub_sector_display()
def resolve_sub_pillar_display(root, info, **kwargs):
if root.sub_pillar is not None:
return root.get_sub_pillar_display()
return None

@staticmethod
def resolve_focus_sub_sector_display(root, info, **kwargs):
if root.focus_sub_sector is not None:
return root.get_focus_sub_sector_display()
def resolve_sub_dimmension_display(root, info, **kwargs):
if root.sub_dimmension is not None:
return root.get_sub_dimmension_display()
return None


Expand All @@ -295,7 +291,7 @@ class Meta:
filterset_class = IssueGQFilterSet


class SummaryType(DjangoObjectType, UserResourceMixin):
class SummaryMetaType(DjangoObjectType, UserResourceMixin):
class Meta:
model = Summary
fields = [
Expand All @@ -318,12 +314,12 @@ def resolve_issue(root, info, **kwargs):
return root.summary_issue


class SummaryFocusType(DjangoObjectType, UserResourceMixin):
class SummaryFocusMetaType(DjangoObjectType, UserResourceMixin):
class Meta:
model = SummaryFocus


class SummaryFocusSubSectorIssueType(DjangoObjectType, UserResourceMixin):
class SummaryFocusSubDimmensionIssueType(DjangoObjectType, UserResourceMixin):
focus = graphene.Field(AssessmentRegistryFocusTypeEnum, required=False)
focus_display = graphene.String(required=False)

Expand Down Expand Up @@ -366,20 +362,19 @@ class Meta:
language = graphene.List(graphene.NonNull(AssessmentRegistryLanguageTypeEnum), required=True)
focuses = graphene.List(graphene.NonNull(AssessmentRegistryFocusTypeEnum), required=True)
sectors = graphene.List(graphene.NonNull(AssessmentRegistrySectorTypeEnum), required=True)
protection_info_mgmts = graphene.List(graphene.NonNull(AssessmentRegistryProtectionInfoTypeEnum), required=True)
protection_info_mgmts = graphene.List(graphene.NonNull(AssessmentRegistryProtectionInfoTypeEnum), required=False)
affected_groups = graphene.List(graphene.NonNull(AssessmentRegistryAffectedGroupTypeEnum), required=True)
methodology_attributes = graphene.List(graphene.NonNull(MethodologyAttributeType), required=False)
additional_documents = graphene.List(graphene.NonNull(AdditionalDocumentType), required=False)
score_ratings = graphene.List(graphene.NonNull(ScoreRatingType), required=True)
score_analytical_density = graphene.List(graphene.NonNull(ScoreAnalyticalDensityType), required=True)
lead = graphene.NonNull(LeadDetailType)
locations = graphene.List(graphene.NonNull(ProjectGeoAreaType))
summary = graphene.List(graphene.NonNull(SummaryType), required=False)
cna = graphene.List(graphene.NonNull(CNAType), required=False)
summary_meta = graphene.Field(SummaryType, required=False)
summary_subsector_issue = graphene.List(graphene.NonNull(SummarySubPillarIssueType), required=False)
summary_focus_meta = graphene.List(graphene.NonNull(SummaryFocusType), required=False)
summary_focus_subsector_issue = graphene.List(graphene.NonNull(SummaryFocusSubSectorIssueType), required=False)
summary_pillar_meta = graphene.Field(SummaryMetaType, required=False)
summary_sub_pillar_issue = graphene.List(graphene.NonNull(SummarySubPillarIssueType), required=False)
summary_dimmension_meta = graphene.List(graphene.NonNull(SummaryFocusMetaType), required=False)
summary_sub_dimmension_issue = graphene.List(graphene.NonNull(SummaryFocusSubDimmensionIssueType), required=False)
lead = graphene.NonNull(LeadDetailType)

@staticmethod
Expand Down Expand Up @@ -411,19 +406,19 @@ def resolve_cna(root, info, **kwargs):
return Answer.objects.filter(assessment_registry=root)

@staticmethod
def resolve_summary_meta(root, info, **kwargs):
def resolve_summary_pillar_meta(root, info, **kwargs):
return Summary.objects.get(assessment_registry=root)

@staticmethod
def resolve_summary_subsector_issue(root, info, **kwargs):
def resolve_summary_sub_pillar_issue(root, info, **kwargs):
return SummarySubPillarIssue.objects.filter(assessment_registry=root)

@staticmethod
def resolve_summary_focus_meta(root, info, **kwargs):
def resolve_summary_dimmension_meta(root, info, **kwargs):
return SummaryFocus.objects.filter(assessment_registry=root)

@staticmethod
def resolve_summary_focus_subsector_issue(root, info, **kwargs):
def resolve_summary_sub_dimmension_issue(root, info, **kwargs):
return SummaryFocusSubSectorIssue.objects.filter(assessment_registry=root)


Expand Down
Loading

0 comments on commit 062beda

Please sign in to comment.