Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion openwisp_radius/private_storage/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,13 @@ def get_private_store_urls():
urljoin(app_settings.CSV_URL_PATH, "<path:path>"),
views.rad_batch_csv_download_view,
name="serve_private_file",
)
),
path(
urljoin(
app_settings.CSV_URL_PATH,
"<slug:slug>/batch/<uuid:pk>/csv/<str:filename>/",
),
views.RadiusBatchCsvDownloadAPIView.as_view(),
name="radius_organization_batch_csv_read",
),
]
38 changes: 38 additions & 0 deletions openwisp_radius/private_storage/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema
from private_storage.views import PrivateStorageDetailView
from rest_framework.views import APIView

from ..settings import PRIVATE_STORAGE_INSTANCE
from ..utils import load_model
Expand All @@ -19,3 +22,38 @@ def can_access_file(self, private_file):


rad_batch_csv_download_view = RadiusBatchCsvDownloadView.as_view()


# this is a drf wrapper view
@extend_schema(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operation_id="radius_organization_batch_csv_read",
description="Download the CSV export file for a specific RADIUS batch.",
parameters=[
OpenApiParameter(
name="slug",
type=str,
location=OpenApiParameter.PATH,
description="Organization slug",
),
OpenApiParameter(
name="pk",
type=str,
location=OpenApiParameter.PATH,
description="Batch UUID",
),
OpenApiParameter(
name="filename",
type=str,
location=OpenApiParameter.PATH,
description="CSV filename",
),
],
responses={
200: OpenApiResponse(description="CSV file", response=OpenApiTypes.BINARY)
},
tags=["radius"],
)
class RadiusBatchCsvDownloadAPIView(APIView):
def get(self, request, pk, filename):
view = RadiusBatchCsvDownloadView.as_view()
return view(request, pk=pk, filename=filename)
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ cssselect~=1.3.0
openwisp-monitoring @ https://github.com/openwisp/openwisp-monitoring/tarball/1.2
django-redis~=6.0.0
mock-ssh-server~=0.9.1
drf-spectacular
Loading