From 823a87c1642879f3362e2ce40ee58af8d5e1bf20 Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Fri, 18 Sep 2020 16:02:16 +0200 Subject: [PATCH] Add amendment cr to lead motion slide Adds amendment cr to the lead motion slide. Previously the amendmet cr was only present in the amendment slide but was forgotten in the motion slide --- .../app/slides/motions/motion/motion-slide-data.ts | 1 + .../motions/motion/motion-slide.component.ts | 13 ++++++++----- server/openslides/motions/projector.py | 14 ++++++++++++++ server/tests/unit/motions/test_projector.py | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/client/src/app/slides/motions/motion/motion-slide-data.ts b/client/src/app/slides/motions/motion/motion-slide-data.ts index e60ef3080..47f7e6583 100644 --- a/client/src/app/slides/motions/motion/motion-slide-data.ts +++ b/client/src/app/slides/motions/motion/motion-slide-data.ts @@ -10,6 +10,7 @@ export interface MotionSlideDataAmendment { id: number; title: string; amendment_paragraphs: string[]; + change_recommendations: MotionSlideDataChangeReco[]; merge_amendment_into_final: number; merge_amendment_into_diff: number; } diff --git a/client/src/app/slides/motions/motion/motion-slide.component.ts b/client/src/app/slides/motions/motion/motion-slide.component.ts index cfe2e47f6..1a0d8ce47 100644 --- a/client/src/app/slides/motions/motion/motion-slide.component.ts +++ b/client/src/app/slides/motions/motion/motion-slide.component.ts @@ -79,9 +79,6 @@ export class MotionSlideComponent ); } - console.log('cr mode? ', this.crMode); - console.log('the data: ', this._data); - this.recalcUnifiedChanges(); } @@ -216,8 +213,14 @@ export class MotionSlideComponent } if (this.data.data.amendments) { this.data.data.amendments.forEach(amendment => { - const paras = this.getAmendmentAmendedParagraphs(amendment); - paras.forEach(para => this.allChangingObjects.push(para)); + if (amendment.change_recommendations?.length) { + const amendmentCRData = amendment.change_recommendations; + const amendmentCRs = amendmentCRData.map(cr => new MotionSlideObjChangeReco(cr)); + this.allChangingObjects.push(...amendmentCRs); + } else { + const paras = this.getAmendmentAmendedParagraphs(amendment); + this.allChangingObjects.push(...paras); + } }); } this.allChangingObjects.sort((a: ViewUnifiedChange, b: ViewUnifiedChange) => { diff --git a/server/openslides/motions/projector.py b/server/openslides/motions/projector.py index 16c46f622..45fdca983 100644 --- a/server/openslides/motions/projector.py +++ b/server/openslides/motions/projector.py @@ -71,18 +71,32 @@ async def get_amendments_for_motion(motion, all_data_provider): amendment_data = [] for amendment_id in motion["amendments_id"]: amendment = await all_data_provider.get("motions/motion", amendment_id) + merge_amendment_into_final = await get_amendment_merge_into_motion_final( all_data_provider, amendment ) merge_amendment_into_diff = await get_amendment_merge_into_motion_diff( all_data_provider, amendment ) + + # Add change recommendations to the amendments: + change_recommendations = [] # type: ignore + for change_recommendation_id in amendment["change_recommendations_id"]: + cr = await get_model( + all_data_provider, + "motions/motion-change-recommendation", + change_recommendation_id, + ) + if cr is not None and not cr["internal"] and not cr["rejected"]: + change_recommendations.append(cr) + amendment_data.append( { "id": amendment["id"], "identifier": amendment["identifier"], "title": amendment["title"], "amendment_paragraphs": amendment["amendment_paragraphs"], + "change_recommendations": change_recommendations, "merge_amendment_into_diff": merge_amendment_into_diff, "merge_amendment_into_final": merge_amendment_into_final, } diff --git a/server/tests/unit/motions/test_projector.py b/server/tests/unit/motions/test_projector.py index de18e35db..7315af2ee 100644 --- a/server/tests/unit/motions/test_projector.py +++ b/server/tests/unit/motions/test_projector.py @@ -276,6 +276,7 @@ async def test_motion_slide(all_data_provider): "identifier": "Ä1", "merge_amendment_into_final": 0, "merge_amendment_into_diff": 0, + "change_recommendations": [], } ], "amendment_paragraphs": None,