From 6b745b0dfc3e86b7bc2211edee51ba0fd4ecf9d1 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Thu, 18 Apr 2024 13:12:53 +0200 Subject: [PATCH] refactor(history): remove unused code The `convert_timestamps` function is not used anymore since ace42ef The `create_new_version` view contained code thats not being used. --- apis_core/history/views.py | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/apis_core/history/views.py b/apis_core/history/views.py index 369b85d0e..cbca97a55 100644 --- a/apis_core/history/views.py +++ b/apis_core/history/views.py @@ -3,28 +3,10 @@ from django.urls import reverse from django.views.generic import TemplateView from django.contrib.contenttypes.models import ContentType -from datetime import datetime from django.views.generic.detail import SingleObjectMixin from django.utils import timezone -def convert_timestamps(data): - for key, value in data.items(): - if isinstance(value, str): - try: - timestamp = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ") - data[key] = timestamp.strftime("%d.%m.%Y %H:%M") - except ValueError: - continue - elif isinstance(value, dict): - data[key] = convert_timestamps(value) - elif isinstance(value, list): - for i in range(len(value)): - if isinstance(value[i], dict): - value[i] = convert_timestamps(value[i]) - return data - - class ChangeHistoryView(GenericModelMixin, SingleObjectMixin, TemplateView): template_name = "history/change_history.html" @@ -35,13 +17,6 @@ def get(self, request, *args, **kwargs): def create_new_version(request, contenttype, pk): """Gets the version of the history instance and creates a new version.""" - historytripel_ids = request.GET.getlist("historytripel_ids") - for ent in historytripel_ids: - if "," in ent: - historytripel_ids.remove(ent) - ent = ent.split(",") - historytripel_ids += ent - historytripel_ids = list(set(historytripel_ids)) model = contenttype.model_class() instance = model.objects.get(id=pk) history_latest = instance.history.latest()