From 5d898b79386256ef02b23317f9335d9e414500ef Mon Sep 17 00:00:00 2001 From: matijakolaric Date: Mon, 9 Dec 2024 16:49:39 +0100 Subject: [PATCH] Bugfix - not importing recording title, version title, etc. Blacked. --- music_publisher/api.py | 20 ++++++++++---------- music_publisher/models.py | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/music_publisher/api.py b/music_publisher/api.py index 8c07cca..f9d1ff3 100644 --- a/music_publisher/api.py +++ b/music_publisher/api.py @@ -307,16 +307,12 @@ class BackupViewSet(viewsets.ViewSet): permission_classes = [IsSuperuser] renderer_classes = [renderers.JSONRenderer] - # def list(self, request, *args, **kwargs): - # d = {} - # d.update(Work.objects.get_dict(Work.objects.all())) - # d.update(CommercialRelease.objects.get_dict(Release.objects.all())) - # return Response(d) - def json(self, request, *args, **kwargs): yield """{"works":[""" renderer = JSONRenderer() - for i, work_item in enumerate(Work.objects.get_dict_items(Work.objects.all())): + for i, work_item in enumerate( + Work.objects.get_dict_items(Work.objects.all()) + ): if i > 0: yield "," yield renderer.render(work_item) @@ -327,7 +323,11 @@ def json(self, request, *args, **kwargs): yield renderer.render(release.get_dict(with_tracks=True)) yield """]}""" - def list(self,request, *args, **kwargs): - response = StreamingHttpResponse(self.json(request, *args, **kwargs),status=200, content_type='application/json') - response['Cache-Control']= 'no-cache', + def list(self, request, *args, **kwargs): + response = StreamingHttpResponse( + self.json(request, *args, **kwargs), + status=200, + content_type="application/json", + ) + response["Cache-Control"] = ("no-cache",) return response diff --git a/music_publisher/models.py b/music_publisher/models.py index c87399c..54a8e46 100644 --- a/music_publisher/models.py +++ b/music_publisher/models.py @@ -573,6 +573,7 @@ def get_dict(self, qs): "works": works, } + class Work(TitleBase): """Concrete class, with references to foreign objects.