Merge pull request #1565 from OpenSlides/revert-1564-RelatedAgendaItems
Revert "Added view to create related assignment and motion items. Upd…
This commit is contained in:
commit
836d5042ad
@ -1,15 +1,12 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import transaction
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from openslides.agenda.models import Item
|
||||
from openslides.utils.rest_api import (
|
||||
DictField,
|
||||
IntegerField,
|
||||
ListField,
|
||||
ListSerializer,
|
||||
ModelSerializer,
|
||||
SerializerMethodField,
|
||||
ValidationError,
|
||||
)
|
||||
|
||||
@ -159,7 +156,6 @@ class AssignmentFullSerializer(ModelSerializer):
|
||||
"""
|
||||
Serializer for assignment.models.Assignment objects. With all polls.
|
||||
"""
|
||||
agenda_items = SerializerMethodField()
|
||||
assignment_related_users = AssignmentRelatedUserSerializer(many=True, read_only=True)
|
||||
polls = AssignmentAllPollSerializer(many=True, read_only=True)
|
||||
|
||||
@ -174,22 +170,14 @@ class AssignmentFullSerializer(ModelSerializer):
|
||||
'assignment_related_users',
|
||||
'poll_description_default',
|
||||
'polls',
|
||||
'tags',
|
||||
'agenda_items',)
|
||||
|
||||
def get_agenda_items(self, obj):
|
||||
"""
|
||||
Returns a list of ids of all agenda items that are related to this
|
||||
assignment.
|
||||
"""
|
||||
assignment_content_type = ContentType.objects.get_for_model(obj)
|
||||
return (item.pk for item in Item.objects.filter(content_type=assignment_content_type, object_id=obj.pk))
|
||||
'tags',)
|
||||
|
||||
|
||||
class AssignmentShortSerializer(AssignmentFullSerializer):
|
||||
"""
|
||||
Serializer for assignment.models.Assignment objects. Without unpublished poll.
|
||||
"""
|
||||
assignment_related_users = AssignmentRelatedUserSerializer(many=True, read_only=True)
|
||||
polls = AssignmentShortPollSerializer(many=True, read_only=True)
|
||||
|
||||
class Meta:
|
||||
@ -203,5 +191,4 @@ class AssignmentShortSerializer(AssignmentFullSerializer):
|
||||
'assignment_related_users',
|
||||
'poll_description_default',
|
||||
'polls',
|
||||
'tags',
|
||||
'agenda_items',)
|
||||
'tags',)
|
||||
|
@ -15,7 +15,6 @@ from reportlab.platypus import (
|
||||
TableStyle,
|
||||
)
|
||||
|
||||
from openslides.agenda.models import Item
|
||||
from openslides.config.api import config
|
||||
from openslides.users.models import Group, User # TODO: remove this
|
||||
from openslides.utils.pdf import stylesheet
|
||||
@ -214,25 +213,6 @@ class AssignmentViewSet(ModelViewSet):
|
||||
assignment.create_poll()
|
||||
return Response({'detail': _(' Poll created successfully.')})
|
||||
|
||||
@detail_route(methods=['post'])
|
||||
def create_agenda_item(self, request, pk=None):
|
||||
"""
|
||||
Speacial view endpoint to create an agenda item that is related to
|
||||
this assignment.
|
||||
"""
|
||||
# Check permission.
|
||||
if not request.user.has_perm('assignments.can_manage'):
|
||||
self.permission_denied(request)
|
||||
|
||||
# Retrieve motion.
|
||||
assignment = self.get_object()
|
||||
|
||||
# Create agenda item.
|
||||
Item.objects.create(content_object=assignment)
|
||||
|
||||
# Initiate response.
|
||||
return Response({'detail': _('Agenda item successfully created.')})
|
||||
|
||||
|
||||
class AssignmentPollViewSet(UpdateModelMixin, DestroyModelMixin, GenericViewSet):
|
||||
"""
|
||||
|
@ -1,15 +1,12 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import transaction
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from openslides.agenda.models import Item
|
||||
from openslides.config.api import config
|
||||
from openslides.utils.rest_api import (
|
||||
CharField,
|
||||
IntegerField,
|
||||
ModelSerializer,
|
||||
PrimaryKeyRelatedField,
|
||||
SerializerMethodField,
|
||||
ValidationError,
|
||||
)
|
||||
|
||||
@ -141,7 +138,6 @@ class MotionSerializer(ModelSerializer):
|
||||
Serializer for motion.models.Motion objects.
|
||||
"""
|
||||
active_version = PrimaryKeyRelatedField(read_only=True)
|
||||
agenda_items = SerializerMethodField()
|
||||
log_messages = MotionLogSerializer(many=True, read_only=True)
|
||||
polls = MotionPollSerializer(many=True, read_only=True)
|
||||
reason = CharField(allow_blank=True, required=False, write_only=True)
|
||||
@ -169,7 +165,6 @@ class MotionSerializer(ModelSerializer):
|
||||
'workflow',
|
||||
'tags',
|
||||
'attachments',
|
||||
'agenda_items',
|
||||
'polls',
|
||||
'log_messages',)
|
||||
read_only_fields = ('parent',) # Some other fields are also read_only. See definitions above.
|
||||
@ -233,11 +228,3 @@ class MotionSerializer(ModelSerializer):
|
||||
attr.add(*validated_data[key])
|
||||
|
||||
return motion
|
||||
|
||||
def get_agenda_items(self, obj):
|
||||
"""
|
||||
Returns a list of ids of all agenda items that are related to this
|
||||
motion.
|
||||
"""
|
||||
motion_content_type = ContentType.objects.get_for_model(obj)
|
||||
return (item.pk for item in Item.objects.filter(content_type=motion_content_type, object_id=obj.pk))
|
||||
|
@ -6,7 +6,6 @@ from django.utils.translation import ugettext_noop
|
||||
from reportlab.platypus import SimpleDocTemplate
|
||||
from rest_framework import status
|
||||
|
||||
from openslides.agenda.models import Item
|
||||
from openslides.config.api import config
|
||||
from openslides.utils.rest_api import (
|
||||
ModelViewSet,
|
||||
@ -245,28 +244,6 @@ class MotionViewSet(ModelViewSet):
|
||||
person=request.user)
|
||||
return Response({'detail': message})
|
||||
|
||||
@detail_route(methods=['post'])
|
||||
def create_agenda_item(self, request, pk=None):
|
||||
"""
|
||||
Speacial view endpoint to create an agenda item that is related to
|
||||
this motion.
|
||||
"""
|
||||
# Check permission.
|
||||
if not request.user.has_perm('motions.can_manage'):
|
||||
self.permission_denied(request)
|
||||
|
||||
# Retrieve motion.
|
||||
motion = self.get_object()
|
||||
|
||||
# Create agenda item.
|
||||
Item.objects.create(content_object=motion)
|
||||
|
||||
# Write the log message and initiate response.
|
||||
motion.write_log(
|
||||
message_list=[ugettext_noop('Agenda item created')],
|
||||
person=request.user)
|
||||
return Response({'detail': _('Agenda item successfully created.')})
|
||||
|
||||
|
||||
class PollPDFView(PDFView):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user