From 0e764626e80e19c0b9682ed07d61cfcccc368835 Mon Sep 17 00:00:00 2001 From: Dishant Sethi Date: Wed, 9 Mar 2022 00:29:21 +0530 Subject: [PATCH] [change] Updated download batch CSV URL #373 * 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. Related to #373 Co-authored-by: Dishant Sethi Co-authored-by: Federico Capoano --- 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 8c693760..5375094e 100644 --- a/docs/source/user/api.rst +++ b/docs/source/user/api.rst @@ -766,3 +766,22 @@ When using this strategy, in the response you can find the field (example: ``[['username', 'password'], ['sample_user', 'BBuOb5sN']]``) and the field ``pdf_link`` which can be used to download a PDF file containing the user credentials. + +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 +=============== =============================== diff --git a/openwisp_radius/base/models.py b/openwisp_radius/base/models.py index beb3675f..84b49830 100644 --- a/openwisp_radius/base/models.py +++ b/openwisp_radius/base/models.py @@ -830,7 +830,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 609b2686..bd897659 100644 --- a/openwisp_radius/settings.py +++ b/openwisp_radius/settings.py @@ -135,7 +135,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