Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(history): remove unused code #794

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions apis_core/history/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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()
Expand Down
Loading