rdmo
rdmo copied to clipboard
825 add toggle to add/remove current site to/from element sites
Description
The new endpoints that add or remove the current site from the sites
of an element are:
Django back-end
questions
-
PUT /api/v1/questions/catalogs/{id}/toggle-site/
tasks
-
PUT /api/v1/tasks/tasks/{id}/toggle-site/
views
-
PUT /api/v1/views/views/{id}/toggle-site/
These are defined in a new ViewSetMixin
, ElementToggleCurrentSiteViewSetMixin
in
rdmo/management/viewsets.py
. This mixin has one action toggle-site
and only for put
is allowed.
It adds or removes the current site from the object, depending on whether is was there already or not (like a toggle).
For permissions it uses a new (rules-based) CanToggleElementCurrentSite
permission class.
The mixin class could be simplified by removing the serializer_class
and the get_queryset
method.
Could we adapt the ElementSucces
reducer to not need the serialized object for these actions?
Permissions could by checked right in the action methods by eg. test_rule()
.
React front-end:
- new component:
ToggleCurrentSiteLink
inrdmo/management/assets/js/components/common/Links.js
- added
elementAction
tostoreElement
andstoreElementInit
- the url routing is done in eg. the
MultiSiteApi.js
storeElement
via theaction
Related issue: #825
Motivation and Context
How has this been tested?
Screenshots (if appropriate)
Logged in as example-editor.
Types of Changes
- [x] New feature (non-breaking change which adds functionality)
Checklist
- [x] I have read the contributor guide.
- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
need to re-do the commits and add the tests but buttons seem to be working like this
- [x] the current site toggle should not be affected by the "locked" state of the element
Can this be merged?