1+ from django .utils .translation import gettext_lazy as _
2+ from drf_yasg import openapi
3+ from drf_yasg .utils import swagger_auto_schema
14from private_storage .views import PrivateStorageDetailView
5+ from rest_framework .views import APIView
26
37from ..settings import PRIVATE_STORAGE_INSTANCE
48from ..utils import load_model
@@ -10,6 +14,7 @@ class RadiusBatchCsvDownloadView(PrivateStorageDetailView):
1014 model_file_field = "csvfile"
1115 slug_field = "csvfile"
1216 slug_url_kwarg = "path"
17+ pk_url_kwarg = "pk"
1318
1419 def can_access_file (self , private_file ):
1520 user = private_file .request .user
@@ -19,3 +24,24 @@ def can_access_file(self, private_file):
1924
2025
2126rad_batch_csv_download_view = RadiusBatchCsvDownloadView .as_view ()
27+
28+
29+ class RadiusBatchCsvDownloadAPIView (APIView ):
30+ @swagger_auto_schema (
31+ operation_id = "radius_organization_batch_csv_read" ,
32+ operation_description = _ (
33+ "Allows downloading the CSV file used to import users for a "
34+ "specific batch user creation operation."
35+ ),
36+ responses = {
37+ 200 : openapi .Response (
38+ description = _ ("CSV file" ), schema = openapi .Schema (type = openapi .TYPE_FILE )
39+ ),
40+ },
41+ tags = ["radius" ],
42+ )
43+ def get (self , request , _slug , pk , * args , ** kwargs ):
44+ return rad_batch_csv_download_view (request , pk = pk , ** kwargs )
45+
46+
47+ rad_batch_csv_download_api_view = RadiusBatchCsvDownloadAPIView .as_view ()
0 commit comments