-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Add support to reversion to the REST API #994
base: master
Are you sure you want to change the base?
Conversation
8690016
to
3fdfcaf
Compare
Implemented three endpoints: 1. List all revisions with optional filtering by model. 2. Inspect a specific revision by its ID. 3. Restore a revision using its ID. Fixes openwisp#894
3fdfcaf
to
98ca619
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! The code is clean and well-structured.
However, this PR seems to be missing its main goal: ensuring that every versioned model admin has a corresponding versioned REST API that logs revisions—tracking who changed what—each time a modification is made.
Please check my comments below for further details.
model = filters.CharFilter(field_name="content_type__model", lookup_expr="iexact") | ||
|
||
def _set_valid_filterform_labels(self): | ||
self.filters["model"].label = _("Model") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using single quotes for strings, eg: 'model'
. Please maintain consistency!
name='reversion_detail', | ||
), | ||
path( | ||
'controller/reversion/<str:pk>/restore/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URLs seem to be heavily focused on the django-reversion
implementation rather than aligning with OpenWISP's approach.
This was not the original intention of the issue. The goal is to introduce additional URLs for each resource (e.g., Device
, Template
, etc.) that supports reversion, allowing users to list revisions, review revisions, and restore them.
For example, for Template
:
GET /controller/template/revisions/
GET /controller/template/revisions/{pk}/
POST /controller/template/revisions/{pk}/restore/
Checklist
Reference to Existing Issue
Closes #894.
Description of Changes
Introduces three new REST API endpoints for managing revisions:
List all revisions with optional filtering by model:
GET /controller/reversion/?model=<model_name>
Inspect a specific revision using its ID:
GET /controller/reversion/<revision_id>/
Restore a revision based on its ID:
POST /controller/reversion/<revision_id>/restore/
Let me know if any changes are needed in the response data whether anything should be included, excluded, or modified. Also, please share any suggestions for adding more filters or adjusting the response format for the restore endpoint