Skip to content

Commit

Permalink
Handle is_pga to pdf-export url (#2379)
Browse files Browse the repository at this point in the history
  • Loading branch information
susilnem authored Jan 10, 2025
1 parent d918172 commit 78d4796
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,8 @@ class HistoricalDisasterSerializer(serializers.Serializer):

class ExportSerializer(serializers.ModelSerializer):
status_display = serializers.CharField(source="get_status_display", read_only=True)
# NOTE: is_pga is used to determine if the export contains PGA or not
is_pga = serializers.BooleanField(default=False, required=False, write_only=True)

class Meta:
model = Export
Expand Down Expand Up @@ -2402,6 +2404,11 @@ def create(self, validated_data):
validated_data["url"] = f"https://{settings.FRONTEND_URL}/countries/{country_id}/{export_type}/{export_id}/export/"
else:
validated_data["url"] = f"https://{settings.FRONTEND_URL}/{export_type}/{export_id}/export/"

# Adding is_pga to the url
is_pga = validated_data.pop("is_pga")
if is_pga:
validated_data["url"] += "?is_pga=true"
validated_data["requested_by"] = user
export = super().create(validated_data)
if export.url:
Expand Down

0 comments on commit 78d4796

Please sign in to comment.