Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort attachments in API V2 for Outdoor Sites and Touristic Contents (refs #4071) #4072

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CHANGELOG
- Fix crash on migrate when db username or dbname contains dash
- Fix Intervention end date should only be mandatory in last step of Suricate Workflow (refs #3825)"
- Change label filter intervention contractors and filter null value on project contractors detail view (#3820)

- Sort attachements in API V2 for OutdoorSites and TouristicContent objects (fixes #4071)

**Documentation**

Expand Down
4 changes: 2 additions & 2 deletions geotrek/api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def get_description_teaser(self, obj):
return get_translation_or_dict('description_teaser', self, obj)

class TouristicContentSerializer(TouristicModelSerializer):
attachments = AttachmentSerializer(many=True)
attachments = AttachmentSerializer(many=True, source='sorted_attachments')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also add it on Infrastructure, SensitiveArea ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attribute sorted_attachments is available with the PicturesMixin.

The PicturesMixin is not associated with the following objects (therefore we cannot do the same modification) :

  • Signage
  • Infrastructure
  • SensitiveArea

departure_city = serializers.SerializerMethodField()
types = serializers.SerializerMethodField()
url = HyperlinkedIdentityField(view_name='apiv2:touristiccontent-detail')
Expand Down Expand Up @@ -1168,7 +1168,7 @@ class SiteSerializer(PDFSerializerMixin, DynamicFieldsMixin, PublishedRelatedObj
period = serializers.SerializerMethodField()
url = HyperlinkedIdentityField(view_name='apiv2:site-detail')
geometry = geo_serializers.GeometryField(read_only=True, source="geom_transformed", precision=7)
attachments = AttachmentSerializer(many=True)
attachments = AttachmentSerializer(many=True, source='sorted_attachments')
sector = serializers.SerializerMethodField()
courses = serializers.SerializerMethodField()
courses_uuids = serializers.SerializerMethodField()
Expand Down
Loading