From d4a9751474ef49000a418c70ee09bba6baa3b97f Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Wed, 18 Apr 2018 16:19:51 +0200 Subject: [PATCH] Added motions from state and recommendation to the projector requirements --- openslides/motions/projector.py | 35 ++++++++++++++++++++ openslides/motions/static/js/motions/base.js | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/openslides/motions/projector.py b/openslides/motions/projector.py index 391c1fcfd..8388fe0a6 100644 --- a/openslides/motions/projector.py +++ b/openslides/motions/projector.py @@ -1,5 +1,8 @@ +import re + from typing import Generator, Type +from ..core.config import config from ..core.exceptions import ProjectorException from ..utils.projector import ProjectorElement from .models import Motion, MotionBlock, MotionChangeRecommendation, Workflow @@ -25,10 +28,42 @@ class MotionSlide(ProjectorElement): yield motion yield motion.agenda_item yield motion.state.workflow + yield from self.required_motions_for_state_and_recommendation(motion) yield from motion.submitters.all() yield from motion.supporters.all() yield from MotionChangeRecommendation.objects.filter(motion_version=motion.get_active_version().id) + def required_motions_for_state_and_recommendation(self, motion): + """ + Returns a list of motions needed for the projector, because they are mentioned + in additional fieds for the state and recommendation. + Keep the motion_syntax syncronized with the MotionStateAndRecommendationParser on the client. + """ + # get the comments field for state and recommendation + motion_syntax = re.compile('\[motion:(\d+)\]') + fields = config['motions_comments'] + state_field_id = None + recommendation_field_id = None + + for id, field in fields.items(): + if field.get('forState', False): + state_field_id = id + if field.get('forRecommendation', False): + recommendation_field_id = id + + # extract all mentioned motions from the state and recommendation + motion_ids = set() + if state_field_id is not None: + state_text = motion.comments.get(state_field_id) + motion_ids.update([int(id) for id in motion_syntax.findall(state_text)]) + + if recommendation_field_id is not None: + recommendation_text = motion.comments.get(recommendation_field_id) + motion_ids.update([int(id) for id in motion_syntax.findall(recommendation_text)]) + + # return all motions + return Motion.objects.filter(pk__in=motion_ids) + def get_collection_elements_required_for_this(self, collection_element, config_entry): output = super().get_collection_elements_required_for_this(collection_element, config_entry) # Full update if motion changes because then we may have new diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index 90d3191bf..70167fb81 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -201,7 +201,7 @@ angular.module('OpenSlidesApp.motions', [ if (motion) { return motion.identifier ? motion.identifier : motion.getTitle(); } else { - return gettextCatalog.getString(""); + return gettextCatalog.getString(''); } }); },