|
|
|
|
@ -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
|
|
|
|
|
|