From f53d3c2069e52b39b1f83caa1b796fb02aa14451 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Tue, 7 May 2019 15:53:04 +0200 Subject: [PATCH] Fix numbering with amendments --- openslides/motions/views.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/openslides/motions/views.py b/openslides/motions/views.py index b4209aba3..6fbaf07d1 100644 --- a/openslides/motions/views.py +++ b/openslides/motions/views.py @@ -1224,7 +1224,7 @@ class CategoryViewSet(ModelViewSet): Send POST {'motions': []} to sort the given motions in a special order. Ids of motions which do not belong to the category are just ignored. Send just POST {} to sort all - motions in the category by database id. + motions in the category ordered by their category weight. Amendments will get a new identifier prefix if the old prefix matches the old parent motion identifier. @@ -1241,12 +1241,14 @@ class CategoryViewSet(ModelViewSet): # Prepare ordered list of motions. if not category.prefix: - prefix = "" + category_prefix = "" elif without_blank: - prefix = category.prefix + category_prefix = category.prefix else: - prefix = f"{category.prefix} " - motions = category.motion_set.all() + category_prefix = f"{category.prefix} " + + # get motions + motions = category.motion_set.order_by("category_weight") motion_list = request.data.get("motions") if motion_list: motion_dict = {} @@ -1261,13 +1263,17 @@ class CategoryViewSet(ModelViewSet): # Collect old and new identifiers. motions_to_be_sorted = [] for motion in motions: + prefix = category_prefix + + # Change prefix for amendments if motion.is_amendment(): parent_identifier = motion.parent.identifier or "" if without_blank: prefix = f"{parent_identifier}{config['motions_amendments_prefix']}" else: prefix = f"{parent_identifier} {config['motions_amendments_prefix']} " - number += 1 + else: + number += 1 new_identifier = ( f"{prefix}{motion.extend_identifier_number(number)}" )