From e41873b75d4c8f17187b02c0212e2f09ce21d6df Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Mon, 22 Jan 2024 08:30:14 +0100 Subject: [PATCH] revert: Remove export to JSON button from section change form --- backend/section/admin.py | 20 +------------------- backend/section/templates/change_form.html | 1 - backend/section/tests.py | 7 ------- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/backend/section/admin.py b/backend/section/admin.py index af607fd56..1abd91126 100644 --- a/backend/section/admin.py +++ b/backend/section/admin.py @@ -50,7 +50,7 @@ class PlaylistAdmin(InlineActionsModelAdminMixin, admin.ModelAdmin): list_display = ('name', 'section_count', 'experiment_count') search_fields = ['name', 'section__song__artist', 'section__song__name'] inline_actions = ['add_sections', - 'edit_sections', 'export_json', 'export_csv'] + 'edit_sections', 'export_csv'] def save_model(self, request, obj, form, change): @@ -160,19 +160,6 @@ def edit_sections(self, request, obj, parent_obj=None): 'sections': sections} ) - def export_json(self, request, obj, parent_obj=None): - """Export playlist data in JSON, force download""" - - response = JsonResponse( - obj.export_admin(), json_dumps_params={'indent': 4}) - - # force download attachment - response['Content-Disposition'] = 'attachment; filename="playlist_' + \ - str(obj.id)+'.json"' - return response - - export_json.short_description = "Export JSON" - def export_csv(self, request, obj, parent_obj=None): """Export playlist sections to csv, force download""" @@ -193,15 +180,10 @@ def export_csv_view(self, request, pk): obj = self.get_object(request, pk) return self.export_csv(request, obj) - def export_json_view(self, request, pk): - obj = self.get_object(request, pk) - return self.export_json(request, obj) - def get_urls(self): urls = super().get_urls() custom_urls = [ path('/export_csv/', self.export_csv_view, name='section_playlist_export_csv'), - path('/export_json/', self.export_json_view, name='section_playlist_export_json'), ] return custom_urls + urls diff --git a/backend/section/templates/change_form.html b/backend/section/templates/change_form.html index 1c13c687d..962680a08 100644 --- a/backend/section/templates/change_form.html +++ b/backend/section/templates/change_form.html @@ -20,6 +20,5 @@ {% block after_field_sets %} {% endblock %} diff --git a/backend/section/tests.py b/backend/section/tests.py index 6db10bc8f..dcfe942b8 100644 --- a/backend/section/tests.py +++ b/backend/section/tests.py @@ -146,13 +146,6 @@ def test_export_csv(self): self.assertEqual(response.status_code, 200) self.assertEqual(response['Content-Type'], 'text/csv') - def test_export_json(self): - url = reverse('admin:section_playlist_export_json', args=[self.playlist.pk]) - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertEqual(response['Content-Type'], 'application/json') - - class PlaylistAdminFormTest(TestCase): def setUp(self):