Allow set state for submitters in some states.

This commit is contained in:
Norman Jäckel 2019-01-31 23:32:36 +01:00 committed by Emanuel Schütze
parent 448ea6df28
commit 286c81e007
2 changed files with 10 additions and 3 deletions

View File

@ -34,6 +34,8 @@ Motions:
follow recommendation, manage submitters and supporters, change motion follow recommendation, manage submitters and supporters, change motion
category, motion block and origin and manage motion polls [#3913]. category, motion block and origin and manage motion polls [#3913].
- Added new permission to create amendments [#4128]. - Added new permission to create amendments [#4128].
- Allowed submitters to set state of new motions in complex and customized
workflow [#4236].
- Added multi select action to manage submitters, tags, states and - Added multi select action to manage submitters, tags, states and
recommendations [#4037, #4132]. recommendations [#4037, #4132].
- Added timestampes for motions [#4134]. - Added timestampes for motions [#4134].

View File

@ -75,11 +75,10 @@ class MotionViewSet(ModelViewSet):
result = has_perm(self.request.user, "motions.can_see") result = has_perm(self.request.user, "motions.can_see")
# For partial_update, update and destroy requests the rest of the check is # For partial_update, update and destroy requests the rest of the check is
# done in the update method. See below. # done in the update method. See below.
elif self.action == "create": elif self.action in ("create", "set_state"):
result = has_perm(self.request.user, "motions.can_see") result = has_perm(self.request.user, "motions.can_see")
# For create the rest of the check is done in the create method. See below. # For create the rest of the check is done in the respective method. See below.
elif self.action in ( elif self.action in (
"set_state",
"manage_multiple_state", "manage_multiple_state",
"set_recommendation", "set_recommendation",
"manage_multiple_recommendation", "manage_multiple_recommendation",
@ -561,6 +560,10 @@ class MotionViewSet(ModelViewSet):
# Set or reset state. # Set or reset state.
if state is not None: if state is not None:
# Check data and set state. # Check data and set state.
if not has_perm(request.user, "motions.can_manage_metadata") and not (
motion.is_submitter(request.user) and motion.state.allow_submitter_edit
):
self.permission_denied(request)
try: try:
state_id = int(state) state_id = int(state)
except ValueError: except ValueError:
@ -574,6 +577,8 @@ class MotionViewSet(ModelViewSet):
motion.set_state(state_id) motion.set_state(state_id)
else: else:
# Reset state. # Reset state.
if not has_perm(self.request.user, "motions.can_manage_metadata"):
self.permission_denied(request)
motion.reset_state() motion.reset_state()
# Save motion. # Save motion.