From f56a9e300e823cd2b9eb4d97a292af627d2fdb49 Mon Sep 17 00:00:00 2001 From: AlexP077 Date: Tue, 28 Mar 2023 12:10:45 +0300 Subject: [PATCH] filename_to_settings --- postamates/settings.py | 2 ++ service/views.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/postamates/settings.py b/postamates/settings.py index 4338af1..aed089c 100644 --- a/postamates/settings.py +++ b/postamates/settings.py @@ -171,3 +171,5 @@ CACHE_TIMEOUT = 0 DEFAULT_PLACEMENT_POINT_UPDATE_RADIUS = 500 AGE_DAY_LIMIT = 270 AGE_DAY_BORDER = 30 +EXCEL_EXPORT_FILENAME = 'placement_points.xlsx' +JSON_EXPORT_FILENAME = 'placement_points.json' diff --git a/service/views.py b/service/views.py index d73b3a2..1574412 100644 --- a/service/views.py +++ b/service/views.py @@ -13,6 +13,8 @@ from rest_framework.views import APIView from rest_framework.viewsets import ReadOnlyModelViewSet from postamates.settings import AGE_DAY_BORDER +from postamates.settings import EXCEL_EXPORT_FILENAME +from postamates.settings import JSON_EXPORT_FILENAME from service import models from service import pagination from service import serializers @@ -186,7 +188,7 @@ class PlacementPointViewSet(ReadOnlyModelViewSet): @action(detail=False, methods=['get']) def to_excel(self, request): qs = self.get_queryset() - filename = 'placement_points.xlsx' + filename = EXCEL_EXPORT_FILENAME res = HttpResponse( PointService.to_excel(qs), content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', @@ -197,7 +199,7 @@ class PlacementPointViewSet(ReadOnlyModelViewSet): @action(detail=False, methods=['get']) def to_json(self, request): qs = self.get_queryset() - filename = 'placement_points.json' + filename = JSON_EXPORT_FILENAME response = HttpResponse(PointService.to_json(qs), content_type='application/json') response['Content-Disposition'] = f'attachment; filename={filename}' return response