Skip to content

Commit

Permalink
refactor(history): make ChangeHistoryView reuse existing views
Browse files Browse the repository at this point in the history
The DetailView is a TemplateView that inherits from BaseDetailView,
which inherits from SingleObjectMixin and implements a similar `get`
as ChangeHistoryView does. So inheriting from DetailView makes the whole
thing smaller.
  • Loading branch information
b1rger committed Apr 25, 2024
1 parent 7e27dde commit ab83ab9
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions apis_core/history/views.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
from apis_core.generic.views import GenericModelMixin
from django.shortcuts import redirect
from django.urls import reverse
from django.views.generic import TemplateView
from django.contrib.contenttypes.models import ContentType
from django.views.generic.detail import SingleObjectMixin
from django.views.generic.detail import DetailView
from django.utils import timezone


class ChangeHistoryView(GenericModelMixin, SingleObjectMixin, TemplateView):
class ChangeHistoryView(GenericModelMixin, DetailView):
template_name = "history/change_history.html"

def get(self, request, *args, **kwargs):
self.object = self.get_object()
return super().get(request, *args, **kwargs)


def create_new_version(request, contenttype, pk):
"""Gets the version of the history instance and creates a new version."""
Expand Down

0 comments on commit ab83ab9

Please sign in to comment.