Skip to content

Commit

Permalink
Merge pull request #2225 from IFRCGo/feature/opslearning-atype-for-pu…
Browse files Browse the repository at this point in the history
…blic

Add appealtype to ops-learning public results
  • Loading branch information
szabozoltan69 authored Jul 22, 2024
2 parents 7a3261d + eab96f3 commit 3967220
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions per/drf_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ def get_renderer_context(self):
"id",
"appeal_code.code",
"appeal_code.name",
"appeal_code.atype",
"learning",
"finding",
"sector",
Expand All @@ -780,6 +781,7 @@ def get_renderer_context(self):
"id",
"appeal_code",
"appeal_name",
"appeal_type",
"learning",
"finding",
"sector",
Expand Down
24 changes: 22 additions & 2 deletions per/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,18 @@ def get_region_name(obj):

class Meta:
model = Appeal
fields = ("code", "name", "country", "region", "country_name", "region_name", "dtype", "start_date", "num_beneficiaries")
fields = (
"code",
"name",
"atype",
"country",
"region",
"country_name",
"region_name",
"dtype",
"start_date",
"num_beneficiaries",
)


class FullAppealSerializer(serializers.ModelSerializer):
Expand All @@ -913,6 +924,13 @@ class Meta:
fields = "__all__"


class MicroAppealSerializer(serializers.ModelSerializer):

class Meta:
model = Appeal
fields = ("code", "name", "atype")


class OpsLearningCSVSerializer(serializers.ModelSerializer):
# Also the anonyme requests use this, but from
# get_queryset() only validated records come here in that case.
Expand Down Expand Up @@ -1002,9 +1020,11 @@ class Meta:


class PublicOpsLearningSerializer(serializers.ModelSerializer):
# We do not extract appeal details here.
# We do not extract appeal details here, except appeal type, which is important.
# Only the validated items are shown, arriving from get_queryset().

appeal_code = MicroAppealSerializer(allow_null=True, read_only=True)

class Meta:
model = OpsLearning
read_only_fields = ("created_at", "modified_at")
Expand Down

0 comments on commit 3967220

Please sign in to comment.