Coverage for apis_core/entities/views.py: 63%
19 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-07-06 07:19 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-07-06 07:19 +0000
1from django.http import HttpResponse
2from django.shortcuts import redirect
3from django.views.generic.base import View
4from django.views.generic.detail import SingleObjectMixin
6from apis_core.entities.models import EntityID
7from apis_core.generic.views import List
10class CanonicalEntity(View, SingleObjectMixin):
11 model = EntityID
12 accepted_media_types = ["text/html", "application/json"]
14 def get(self, request, *args, **kwargs):
15 match request.get_preferred_type(self.accepted_media_types):
16 case "text/html":
17 return redirect(self.get_object().content_object.get_absolute_url())
18 case "application/json":
19 return redirect(
20 self.get_object().content_object.get_api_detail_endpoint()
21 )
22 case _:
23 return HttpResponse(
24 status_code=406,
25 headers={"Accept": ",".join(self.accepted_media_types)},
26 )
29class E53_PlaceMap(List):
30 template_name_suffix = "_map"