Skip to content

Commit

Permalink
[change] Updated download batch CSV URL #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.

Related to #373

Co-authored-by: Dishant Sethi <dishantsethi@Dishants-MacBook-Air.local>
Co-authored-by: Federico Capoano <f.capoano@openwisp.io>
  • Loading branch information
3 people committed Mar 8, 2022
1 parent 74fc5e1 commit 0e76462
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 @@ -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/<organization-slug>/batch/<id>/csv/<filename>
Responds only to **GET**.

Parameters:

=============== ===============================
Param Description
=============== ===============================
slug string
id string
filename string
=============== ===============================
8 changes: 7 additions & 1 deletion openwisp_radius/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion openwisp_radius/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e76462

Please sign in to comment.