Merge pull request #4836 from FinnStutzenstein/agendaPermissions
Requires agenda.can_manage for settings agenda item information
This commit is contained in:
commit
b67ccf0c29
@ -1,4 +1,5 @@
|
|||||||
<ng-container *ngIf="showForm">
|
<ng-container *osPerms="'agenda.can_manage'">
|
||||||
|
<ng-container *ngIf="showForm">
|
||||||
<div [formGroup]="form">
|
<div [formGroup]="form">
|
||||||
<mat-checkbox formControlName="agenda_create">
|
<mat-checkbox formControlName="agenda_create">
|
||||||
<span translate>Add to agenda</span>
|
<span translate>Add to agenda</span>
|
||||||
@ -29,4 +30,5 @@
|
|||||||
></os-search-value-selector>
|
></os-search-value-selector>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -2,6 +2,7 @@ from django.db import transaction
|
|||||||
|
|
||||||
from openslides.poll.serializers import default_votes_validator
|
from openslides.poll.serializers import default_votes_validator
|
||||||
from openslides.utils.rest_api import (
|
from openslides.utils.rest_api import (
|
||||||
|
BooleanField,
|
||||||
DecimalField,
|
DecimalField,
|
||||||
DictField,
|
DictField,
|
||||||
IntegerField,
|
IntegerField,
|
||||||
@ -11,6 +12,7 @@ from openslides.utils.rest_api import (
|
|||||||
ValidationError,
|
ValidationError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from ..utils.auth import has_perm
|
||||||
from ..utils.autoupdate import inform_changed_data
|
from ..utils.autoupdate import inform_changed_data
|
||||||
from ..utils.validate import validate_html
|
from ..utils.validate import validate_html
|
||||||
from .models import (
|
from .models import (
|
||||||
@ -186,8 +188,9 @@ class AssignmentFullSerializer(ModelSerializer):
|
|||||||
many=True, read_only=True
|
many=True, read_only=True
|
||||||
)
|
)
|
||||||
polls = AssignmentAllPollSerializer(many=True, read_only=True)
|
polls = AssignmentAllPollSerializer(many=True, read_only=True)
|
||||||
|
agenda_create = BooleanField(write_only=True, required=False, allow_null=True)
|
||||||
agenda_type = IntegerField(
|
agenda_type = IntegerField(
|
||||||
write_only=True, required=False, min_value=1, max_value=3
|
write_only=True, required=False, min_value=1, max_value=3, allow_null=True
|
||||||
)
|
)
|
||||||
agenda_parent_id = IntegerField(write_only=True, required=False, min_value=1)
|
agenda_parent_id = IntegerField(write_only=True, required=False, min_value=1)
|
||||||
|
|
||||||
@ -204,6 +207,7 @@ class AssignmentFullSerializer(ModelSerializer):
|
|||||||
"polls",
|
"polls",
|
||||||
"agenda_item_id",
|
"agenda_item_id",
|
||||||
"list_of_speakers_id",
|
"list_of_speakers_id",
|
||||||
|
"agenda_create",
|
||||||
"agenda_type",
|
"agenda_type",
|
||||||
"agenda_parent_id",
|
"agenda_parent_id",
|
||||||
"tags",
|
"tags",
|
||||||
@ -221,13 +225,19 @@ class AssignmentFullSerializer(ModelSerializer):
|
|||||||
Customized create method. Set information about related agenda item
|
Customized create method. Set information about related agenda item
|
||||||
into agenda_item_update_information container.
|
into agenda_item_update_information container.
|
||||||
"""
|
"""
|
||||||
agenda_type = validated_data.pop("agenda_type", None)
|
|
||||||
agenda_parent_id = validated_data.pop("agenda_parent_id", None)
|
|
||||||
tags = validated_data.pop("tags", [])
|
tags = validated_data.pop("tags", [])
|
||||||
attachments = validated_data.pop("attachments", [])
|
attachments = validated_data.pop("attachments", [])
|
||||||
|
request_user = validated_data.pop("request_user") # this should always be there
|
||||||
|
agenda_create = validated_data.pop("agenda_create", None)
|
||||||
|
agenda_type = validated_data.pop("agenda_type", None)
|
||||||
|
agenda_parent_id = validated_data.pop("agenda_parent_id", None)
|
||||||
|
|
||||||
assignment = Assignment(**validated_data)
|
assignment = Assignment(**validated_data)
|
||||||
|
if has_perm(request_user, "agenda.can_manage"):
|
||||||
|
assignment.agenda_item_update_information["create"] = agenda_create
|
||||||
assignment.agenda_item_update_information["type"] = agenda_type
|
assignment.agenda_item_update_information["type"] = agenda_type
|
||||||
assignment.agenda_item_update_information["parent_id"] = agenda_parent_id
|
assignment.agenda_item_update_information["parent_id"] = agenda_parent_id
|
||||||
|
|
||||||
assignment.save()
|
assignment.save()
|
||||||
assignment.tags.add(*tags)
|
assignment.tags.add(*tags)
|
||||||
assignment.attachments.add(*attachments)
|
assignment.attachments.add(*attachments)
|
||||||
|
@ -66,6 +66,9 @@ class AssignmentViewSet(ModelViewSet):
|
|||||||
result = False
|
result = False
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def perform_create(self, serializer):
|
||||||
|
serializer.save(request_user=self.request.user)
|
||||||
|
|
||||||
@detail_route(methods=["post", "delete"])
|
@detail_route(methods=["post", "delete"])
|
||||||
def candidature_self(self, request, pk=None):
|
def candidature_self(self, request, pk=None):
|
||||||
"""
|
"""
|
||||||
|
@ -5,7 +5,7 @@ from django.db import transaction
|
|||||||
|
|
||||||
from ..core.config import config
|
from ..core.config import config
|
||||||
from ..poll.serializers import default_votes_validator
|
from ..poll.serializers import default_votes_validator
|
||||||
from ..utils.auth import get_group_model
|
from ..utils.auth import get_group_model, has_perm
|
||||||
from ..utils.autoupdate import inform_changed_data
|
from ..utils.autoupdate import inform_changed_data
|
||||||
from ..utils.rest_api import (
|
from ..utils.rest_api import (
|
||||||
BooleanField,
|
BooleanField,
|
||||||
@ -97,7 +97,9 @@ class MotionBlockSerializer(ModelSerializer):
|
|||||||
agenda_create = validated_data.pop("agenda_create", None)
|
agenda_create = validated_data.pop("agenda_create", None)
|
||||||
agenda_type = validated_data.pop("agenda_type", None)
|
agenda_type = validated_data.pop("agenda_type", None)
|
||||||
agenda_parent_id = validated_data.pop("agenda_parent_id", None)
|
agenda_parent_id = validated_data.pop("agenda_parent_id", None)
|
||||||
|
request_user = validated_data.pop("request_user") # this should always be there
|
||||||
motion_block = MotionBlock(**validated_data)
|
motion_block = MotionBlock(**validated_data)
|
||||||
|
if has_perm(request_user, "agenda.can_manage"):
|
||||||
motion_block.agenda_item_update_information["create"] = agenda_create
|
motion_block.agenda_item_update_information["create"] = agenda_create
|
||||||
motion_block.agenda_item_update_information["type"] = agenda_type
|
motion_block.agenda_item_update_information["type"] = agenda_type
|
||||||
motion_block.agenda_item_update_information["parent_id"] = agenda_parent_id
|
motion_block.agenda_item_update_information["parent_id"] = agenda_parent_id
|
||||||
@ -535,6 +537,7 @@ class MotionSerializer(ModelSerializer):
|
|||||||
motion.parent = validated_data.get("parent")
|
motion.parent = validated_data.get("parent")
|
||||||
motion.statute_paragraph = validated_data.get("statute_paragraph")
|
motion.statute_paragraph = validated_data.get("statute_paragraph")
|
||||||
motion.reset_state(validated_data.get("workflow_id"))
|
motion.reset_state(validated_data.get("workflow_id"))
|
||||||
|
if has_perm(validated_data["request_user"], "agenda.can_manage"):
|
||||||
motion.agenda_item_update_information["create"] = validated_data.get(
|
motion.agenda_item_update_information["create"] = validated_data.get(
|
||||||
"agenda_create"
|
"agenda_create"
|
||||||
)
|
)
|
||||||
|
@ -1444,6 +1444,9 @@ class MotionBlockViewSet(ModelViewSet):
|
|||||||
result = False
|
result = False
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def perform_create(self, serializer):
|
||||||
|
serializer.save(request_user=self.request.user)
|
||||||
|
|
||||||
@detail_route(methods=["post"])
|
@detail_route(methods=["post"])
|
||||||
def follow_recommendations(self, request, pk=None):
|
def follow_recommendations(self, request, pk=None):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user