Skip to content

Commit

Permalink
[Change] Update Download batch CSV URL and add in API docs openwisp#373
Browse files Browse the repository at this point in the history
* 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/<uuid>/filename.csv to radius/organization/<slug:slug>/batch/<uuid:pk>/csv/filename.csv and added the same in API documentation as well.

Closes openwisp#373
  • Loading branch information
Dishant Sethi authored and dishantsethi committed Feb 10, 2022
1 parent e23afdc commit 9c48b5d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
19 changes: 19 additions & 0 deletions docs/source/user/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,25 @@ Param Description
phone_number string
=============== ===============================


Batch CSV Download
-------------------
.. code-block:: text
/api/v1/radius/organization/<organization-slug>/batch/<id>/csv/<filename>
Responds only to **GET**.

Parameters:

=============== ===============================
Param Description
=============== ===============================
slug string
id string
filename string
=============== ===============================

Batch user creation
-------------------

Expand Down
8 changes: 7 additions & 1 deletion openwisp_radius/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,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):
Expand Down
2 changes: 1 addition & 1 deletion openwisp_radius/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c48b5d

Please sign in to comment.