Fixed getting states of amendments (closes #4677)

This commit is contained in:
FinnStutzenstein 2019-05-10 07:07:59 +02:00
parent 183f671fee
commit 284e90961a
2 changed files with 16 additions and 14 deletions

View File

@ -98,6 +98,10 @@ export class MotionSlideComponent extends BaseMotionSlideComponent<MotionSlideDa
* @returns {MotionSlideObjAmendmentParagraph[]} * @returns {MotionSlideObjAmendmentParagraph[]}
*/ */
public getAmendmentAmendedParagraphs(amendment: MotionSlideDataAmendment): MotionSlideObjAmendmentParagraph[] { public getAmendmentAmendedParagraphs(amendment: MotionSlideDataAmendment): MotionSlideObjAmendmentParagraph[] {
if (!amendment.amendment_paragraphs) {
return [];
}
let baseHtml = this.data.data.text; let baseHtml = this.data.data.text;
baseHtml = this.lineNumbering.insertLineNumbers(baseHtml, this.lineLength); baseHtml = this.lineNumbering.insertLineNumbers(baseHtml, this.lineLength);
const baseParagraphs = this.lineNumbering.splitToParagraphs(baseHtml); const baseParagraphs = this.lineNumbering.splitToParagraphs(baseHtml);

View File

@ -18,7 +18,7 @@ motion_placeholder_regex = re.compile(r"\[motion:(\d+)\]")
async def get_state( async def get_state(
all_data: AllData, motion: Dict[str, Any], state_id: int all_data: AllData, motion: Dict[str, Any], state_id_key: str
) -> Dict[str, Any]: ) -> Dict[str, Any]:
""" """
Returns a state element from one motion. Returns a state element from one motion.
@ -27,21 +27,21 @@ async def get_state(
""" """
states = all_data["motions/workflow"][motion["workflow_id"]]["states"] states = all_data["motions/workflow"][motion["workflow_id"]]["states"]
for state in states: for state in states:
if state["id"] == state_id: if state["id"] == motion[state_id_key]:
return state return state
raise ProjectorElementException( raise ProjectorElementException(
f"motion {motion['id']} can not be on the state with id {state_id}" f"motion {motion['id']} can not be on the state with id {motion[state_id_key]}"
) )
async def get_amendment_merge_into_motion_diff(all_data, motion, amendment): async def get_amendment_merge_into_motion_diff(all_data, amendment):
""" """
HINT: This implementation should be consistent to showInDiffView() in ViewMotionAmendedParagraph.ts HINT: This implementation should be consistent to showInDiffView() in ViewMotionAmendedParagraph.ts
""" """
if amendment["state_id"] is None: if amendment["state_id"] is None:
return 0 return 0
state = await get_state(all_data, motion, amendment["state_id"]) state = await get_state(all_data, amendment, "state_id")
if state["merge_amendment_into_final"] == -1: if state["merge_amendment_into_final"] == -1:
return 0 return 0
if state["merge_amendment_into_final"] == 1: if state["merge_amendment_into_final"] == 1:
@ -49,21 +49,21 @@ async def get_amendment_merge_into_motion_diff(all_data, motion, amendment):
if amendment["recommendation_id"] is None: if amendment["recommendation_id"] is None:
return 0 return 0
recommendation = await get_state(all_data, motion, amendment["recommendation_id"]) recommendation = await get_state(all_data, amendment, "recommendation_id")
if recommendation["merge_amendment_into_final"] == 1: if recommendation["merge_amendment_into_final"] == 1:
return 1 return 1
return 0 return 0
async def get_amendment_merge_into_motion_final(all_data, motion, amendment): async def get_amendment_merge_into_motion_final(all_data, amendment):
""" """
HINT: This implementation should be consistent to showInFinalView() in ViewMotionAmendedParagraph.ts HINT: This implementation should be consistent to showInFinalView() in ViewMotionAmendedParagraph.ts
""" """
if amendment["state_id"] is None: if amendment["state_id"] is None:
return 0 return 0
state = await get_state(all_data, motion, amendment["state_id"]) state = await get_state(all_data, amendment, "state_id")
if state["merge_amendment_into_final"] == 1: if state["merge_amendment_into_final"] == 1:
return 1 return 1
@ -75,10 +75,10 @@ async def get_amendments_for_motion(motion, all_data):
for amendment_id, amendment in all_data["motions/motion"].items(): for amendment_id, amendment in all_data["motions/motion"].items():
if amendment["parent_id"] == motion["id"]: if amendment["parent_id"] == motion["id"]:
merge_amendment_into_final = await get_amendment_merge_into_motion_final( merge_amendment_into_final = await get_amendment_merge_into_motion_final(
all_data, motion, amendment all_data, amendment
) )
merge_amendment_into_diff = await get_amendment_merge_into_motion_diff( merge_amendment_into_diff = await get_amendment_merge_into_motion_diff(
all_data, motion, amendment all_data, amendment
) )
amendment_data.append( amendment_data.append(
{ {
@ -235,7 +235,7 @@ async def motion_slide(
and motion["recommendation_id"] and motion["recommendation_id"]
): ):
recommendation_state = await get_state( recommendation_state = await get_state(
all_data, motion, motion["recommendation_id"] all_data, motion, "recommendation_id"
) )
return_value["recommendation"] = recommendation_state[ return_value["recommendation"] = recommendation_state[
"recommendation_label" "recommendation_label"
@ -298,9 +298,7 @@ async def motion_block_slide(
recommendation_id = motion["recommendation_id"] recommendation_id = motion["recommendation_id"]
if recommendation_id is not None: if recommendation_id is not None:
recommendation = await get_state( recommendation = await get_state(all_data, motion, "recommendation_id")
all_data, motion, motion["recommendation_id"]
)
motion_object["recommendation"] = { motion_object["recommendation"] = {
"name": recommendation["recommendation_label"], "name": recommendation["recommendation_label"],
"css_class": recommendation["css_class"], "css_class": recommendation["css_class"],