rdmo icon indicating copy to clipboard operation
rdmo copied to clipboard

825 add toggle to add/remove current site to/from element sites

Open MyPyDavid opened this issue 1 year ago • 2 comments

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 in rdmo/management/assets/js/components/common/Links.js
  • added elementAction to storeElement and storeElementInit
  • the url routing is done in eg. the MultiSiteApi.js storeElement via the action

Related issue: #825

Motivation and Context

How has this been tested?

Screenshots (if appropriate)

Logged in as example-editor. image

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.

MyPyDavid avatar Dec 08 '23 17:12 MyPyDavid

need to re-do the commits and add the tests but buttons seem to be working like this

MyPyDavid avatar Dec 08 '23 17:12 MyPyDavid

  • [x] the current site toggle should not be affected by the "locked" state of the element

MyPyDavid avatar May 21 '24 15:05 MyPyDavid

Can this be merged?

jochenklar avatar Jun 06 '24 09:06 jochenklar