diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f9e67123b..6bec7314bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ UNRELEASED ---------- +* [ [#1718](https://github.com/digitalfabrik/integreat-cms/issues/1718) ] Enable submitting feedback about fallback translations of events and pois + 2022.10.2 --------- diff --git a/integreat_cms/api/v3/feedback/event_feedback.py b/integreat_cms/api/v3/feedback/event_feedback.py index e577267198..c03e1dc73e 100644 --- a/integreat_cms/api/v3/feedback/event_feedback.py +++ b/integreat_cms/api/v3/feedback/event_feedback.py @@ -81,10 +81,22 @@ def event_feedback_internal(data, region, language, comment, rating, is_technica events, ) return JsonResponse({"error": "Internal Server Error"}, status=500) - if len(events) == 0: - raise Http404("No matching event found for slug.") - event = events[0] - event_translation = event.get_translation(language.slug) + + event = None + if len(events) == 1: + event = events[0] + elif region.fallback_translations_enabled: + event = region.events.filter( + translations__slug=data.get("slug"), + translations__language=region.default_language, + ).first() + + if not event: + raise Http404("No matching location found for slug.") + + event_translation = event.get_translation(language.slug) or event.get_translation( + region.default_language.slug + ) EventFeedback.objects.create( event_translation=event_translation, diff --git a/integreat_cms/api/v3/feedback/poi_feedback.py b/integreat_cms/api/v3/feedback/poi_feedback.py index 5cb8f576d3..36c12cff06 100644 --- a/integreat_cms/api/v3/feedback/poi_feedback.py +++ b/integreat_cms/api/v3/feedback/poi_feedback.py @@ -51,10 +51,22 @@ def poi_feedback(data, region, language, comment, rating, is_technical): pois, ) return JsonResponse({"error": "Internal Server Error"}, status=500) - if len(pois) == 0: + + poi = None + if len(pois) == 1: + poi = pois[0] + elif region.fallback_translations_enabled: + poi = region.pois.filter( + translations__slug=data.get("slug"), + translations__language=region.default_language, + ).first() + + if not poi: raise Http404("No matching location found for slug.") - poi = pois[0] - poi_translation = poi.get_translation(language.slug) + + poi_translation = poi.get_translation(language.slug) or poi.get_translation( + region.default_language.slug + ) POIFeedback.objects.create( poi_translation=poi_translation,