From dfdd2b7af009d1455266bb6a022409d1a7a22697 Mon Sep 17 00:00:00 2001 From: Dishant Sethi Date: Sun, 6 Feb 2022 13:46:43 +0530 Subject: [PATCH] [Change] Update Download batch CSV URL and add in API docs URL generated with radius:serve_private_file was not consistent with the rest of the API URLs Changed Download batch CSV API endpoint from radiusbatch/csv//filename.csv to radius/organization//batch//csv/filename.csv and added the same in API documentation as well. Fixes issue #373 --- docs/source/user/api.rst | 19 +++++++++++++++++++ openwisp_radius/base/models.py | 8 +++++++- openwisp_radius/settings.py | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/source/user/api.rst b/docs/source/user/api.rst index 1f12282d..b34982ba 100644 --- a/docs/source/user/api.rst +++ b/docs/source/user/api.rst @@ -694,6 +694,25 @@ Param Description phone_number string =============== =============================== + +Batch CSV Download +------------------- +.. code-block:: text + + /api/v1/radius/organization//batch//csv/ + +Responds only to **GET**. + +Parameters: + +=============== =============================== +Param Description +=============== =============================== +slug string +id string +filename string +=============== =============================== + Batch user creation ------------------- diff --git a/openwisp_radius/base/models.py b/openwisp_radius/base/models.py index 7b7cc268..57331e72 100644 --- a/openwisp_radius/base/models.py +++ b/openwisp_radius/base/models.py @@ -821,7 +821,13 @@ def __str__(self): def _get_csv_file_location(instance, filename): - return os.path.join(str(instance.organization.pk), filename) + return os.path.join( + str(instance.organization.slug), + 'batch', + str(instance.organization.pk), + 'csv', + filename, + ) class AbstractRadiusBatch(OrgMixin, TimeStampedEditableModel): diff --git a/openwisp_radius/settings.py b/openwisp_radius/settings.py index b6d1718a..a2eb47ee 100644 --- a/openwisp_radius/settings.py +++ b/openwisp_radius/settings.py @@ -131,7 +131,7 @@ def get_settings_value(option, default): ) # Path of urls that need to be refered in migrations files. -CSV_URL_PATH = 'api/v1/radiusbatch/csv/' +CSV_URL_PATH = 'api/v1/radius/organization/' CALLED_STATION_IDS = get_settings_value('CALLED_STATION_IDS', {}) CONVERT_CALLED_STATION_ON_CREATE = get_settings_value( 'CONVERT_CALLED_STATION_ON_CREATE', False