diff --git a/apis_core/apis_entities/templates/apis_entities/detail_views/detail_generic.html b/apis_core/apis_entities/templates/apis_entities/detail_views/detail_generic.html index 121686a83..b8a6e7c18 100644 --- a/apis_core/apis_entities/templates/apis_entities/detail_views/detail_generic.html +++ b/apis_core/apis_entities/templates/apis_entities/detail_views/detail_generic.html @@ -70,6 +70,9 @@

content_copy {% endif %} + | + history + {% endif %} {% endblock object-actions %} diff --git a/apis_core/core/templates/reversion/version_list.html b/apis_core/core/templates/reversion/version_list.html new file mode 100644 index 000000000..0d9bbee9f --- /dev/null +++ b/apis_core/core/templates/reversion/version_list.html @@ -0,0 +1,9 @@ +{% extends basetemplate %} + +{% block content %} + +{% endblock content %} diff --git a/apis_core/core/views.py b/apis_core/core/views.py new file mode 100644 index 000000000..6f8dce065 --- /dev/null +++ b/apis_core/core/views.py @@ -0,0 +1,21 @@ +from django.views.generic.list import ListView +from django.contrib.contenttypes.models import ContentType +from reversion.models import Revision, Version + + +class Versions(ListView): + paginate_by = 100 + model = Version + instance = None + + def dispatch(self, request, *args, **kwargs): + if content_type := kwargs.get("content_type"): + contenttype = ContentType.objects.get_for_id(content_type) + if object_id := kwargs.get("object_id"): + self.instance = contenttype.model_class().objects.get(pk=object_id) + return super().dispatch(request, *args, **kwargs) + + def get_queryset(self): + if self.instance: + return Version.objects.get_for_object(self.instance) + return Version.objects.all() diff --git a/apis_core/urls.py b/apis_core/urls.py index 13402e075..d60220660 100644 --- a/apis_core/urls.py +++ b/apis_core/urls.py @@ -10,6 +10,8 @@ from apis_core.api_routers import load_additional_serializers from apis_core.api_routers import views +from apis_core.core.views import Versions + # from apis_core.apis_entities.api_views import ( # NetJsonViewSet, # PlaceGeoJsonViewSet, @@ -185,6 +187,8 @@ def build_apis_mock_request(method, path, view, original_request, **kwargs): ), # url(r'^docs/', include('sphinxdoc.urls')), # url(r'^accounts/', include('registration.backends.simple.urls')), + path('reversion/versions/', Versions.as_view(), name="versions"), + path('reversion/versions//', Versions.as_view(), name="versions"), ] if "apis_highlighter" in settings.INSTALLED_APPS: