{
// Required
title: string;
meeting_id: Id;
// Optional
number: string;
additional_submitter: string;
sort_parent_id: Id;
category_id: Id;
block_id: Id;
supporter_meeting_user_ids: Id[]; // meeting user ids
tag_ids: Id[];
attachment_mediafile_ids: Id[];
// Special logic given by the type of the motion
text: HTML;
amendment_paragraph: {
[paragraph_number: number]: HTML;
}; // JSON Field
lead_motion_id: Id;
reason: HTML; // is required, if special settings are set
// Optional special fields, see notes below
workflow_id: Id;
submitter_ids: Id[];
// Non-model fields for customizing the agenda item creation, optional
agenda_create: boolean;
agenda_type: number;
agenda_parent_id: number;
agenda_comment: string;
agenda_duration: number;
agenda_weight: number;
}
Creates a new motion.
The motion is an amendment to another motion if lead_motion_id
is given. Otherwise it is a normal motion.
This is the logic for other fields depending on the motion type:
- normal motion:
text
required- error, if
amendment_paragraph
is given
- amendment:
text
XORamendment_paragraph
required- error otherwise
reason
must independently of the above be given, if meeting/motions_reason_required
is true.
There are some fields that need special attention:
workflow_id
: If it is given, the motion's state is set to the workflow's first state. The workflow must be from the same meeting. If the field is not given, one of the three default (meeting/motions_default_workflow_id
ormeeting/motions_default_amendment_workflow_id
) workflows is used depending on the type of the motion to create.submitter_ids
: These are user ids and not ids of thesubmitter
model. If nothing is given ([]
), the request user's id is used. For each id in the list amotion_submitter
model is created. The weight must be set to the order of the given list.agenda_*
: See Agenda.
Other things to do when creating motions:
- Set the field
sequential_number
: It is themax+1
ofsequential_number
of all motions in the same meeting. If there are no other motions in this meeting (e.g. this is the first one), it gets 1. - Set timestamps:
- always set
last_modified
andcreated
to the current timestamp - if the state pointed to by
first_state_id
of the given workflow has the flagset_workflow_timestamp
set, also setworkflow_timestamp
to the current timestamp.
- always set
- Field
number
: Attention, it is a string, even if the field is namednumber
. Note that thenumber
must be unique within the meeting if it is set (so all numbers with length > 0 are unique). See the next paragraph how to get a value fornumber
.
This is the procedure to determine what to set for the field number
:
- If
number
in the payload is a string with a length > 0, set it as the number and stop, but raise an error, if it exists. - If
meeting/motions_number_type
=="manually"
or notmotion.state.set_number
: stop. We should not set the number automatically - A prefix is created:
- If the motion is an amendment (it has a lead motion), the prefix is:
if meeting/motions_number_with_blank: prefix = f"{lead_motion.number} {meeting/motions_amendments_prefix}" else: prefix = f"{lead_motion.number}{meeting/motions_amendments_prefix}"
- Else if the motion has a category, the prefix is:
if meeting/motions_number_with_blank: prefix = f"{category.prefix} " else: prefix = f"{category.prefix}"
- Else, the prefix is an empty string
- If the motion is an amendment (it has a lead motion), the prefix is:
- choose a number_value. This is a numerical variable with the actual numerical number:
- If the motion is an amendment (it has a lead motion),
number_value
is the maximum+1 ofnumber_value
of all lead_motion.amendments. If there are no other amendments,number_value
is 1. Hint: To easily access thenumber_value
of other motions, it can be saved into the Datastore. - Else if
meeting/motions_number_type
is"per_category"
, choose the maximum+1 ofnumber_value
of all motions in the motions category. This includes the "None"-category; if the motion has no category, the maximum is choosen of all motions, that do not have a category. If there are no other motions,number_value
is 1. - Else: Choose the maximum+1 of
number_value
of all lead motions. If there are no other lead motions, choose 1.
- If the motion is an amendment (it has a lead motion),
- create
number
fromprefix
andnumber_value
:- First,
number_value
is converted to the stringnumber_value_string
and potentially filled with leading zeros. The valuemeeting/motions_number_min_digits
gives the amount of minimum digits. E.g. ifnumber_value
is 12 andmeeting/motions_number_min_digits=3
, thenumber_value_string
is"012"
. Ifnumber_value
is 3582, thenumber_value_string
is"3582"
. - Set
number = f"{prefix}{number_value_string}"
- First,
- Remember:
number
must be unique. If a motion with this number already exists, incrementnumber_value
by one and go to the last step (the prefix is the same, the number incremented - try again). - If there is a unique
number
, save it into the motion. Done! - Note: The complete calculation is restricted to motions and other objects from the same meeting.
Some examples for determinating the number. First comes the general setup and the test cases are numbered:
meeting/motions_number_type="manually"
- Create a motion without a number in the payload. It now has a blank one.
- Create two motion without a number in the payload. Both have a blank one.
- Create two motion with the same number in the payload. The second one fails since numbers must be unique.
meeting/motions_number_type="serially_numbered"
, meeting/motions_number_min_digits=3
, meeting/motions_number_with_blank=true
. Create three categories: {name: "A", prefix: "A"}
, {name: "B", prefix: "B"}
, {name: "no prefix"}
(the last one has an empty prefix, see OpenSlides/OpenSlides#5723). Make sure the state the motions get has set_number=true
.
- Create three motions with no number in the payloads and each motion assigned to one category in the order A, B, no prefix. The resulting numbers should be
A 001
,B 002
,003
. - Create a motion with category A, it should get
A 001
. Create a second motion with the numberB 002
in the payload. Create a third motion with category B and no number in the payload. It must get the numberB 003
. - Create a motion in category A. It must get
A 001
. Delete it and create a new motion in category A. It should also getA 001
.
meeting/motions_number_type="per_category"
, meeting/motions_number_min_digits=3
, meeting/motions_number_with_blank=false
. Create three categories: {name: "A", prefix: "A"}
, {name: "B", prefix: "B"}
, {name: "no prefix"}
. Make sure the state the motions get has set_number=true
.
- Create two motions in category A. Than two motions in category B. Than two motions in category
no prefix
. The numbers must beA001
,A002
,B001
,B002
,001
and002
. - Create a motion without a category. It gets the number
001
. Setmeeting/motions_number_min_digits=1
. Create a plain motion. It must get the number2
.
meeting/motions_number_type="per_category"
, meeting/motions_number_min_digits=3
, meeting/motions_number_with_blank=true
, meeting/motions_amendments_prefix="X-"
. Create a category: {name: "A", prefix: "A"}
. Make sure the state the motions get has set_number=true
.
- Create a motion in category A. It must get
A 001
. Create two amendments (motions withlead_motion_id
set to the id ofA 001
). The numbers areA 001 X-001
andA 001 X-002
. - Do 1) again, but with
meeting/motions_number_with_blank=false
andmeeting/motions_number_min_digits=1
. The numbers areA1
,A1X-1
,A1X-2
. - Do 1) again, but set
meeting/motions_number_with_blank=false
andmeeting/motions_number_min_digits=1
after creating the first lead motion. The numbers areA 001
,A 001X-1
,A 001X-2
. - Do 1) again. Create a new motion without an identifier and no
lead_motion_id
. It gets the number002
.
Repeat an autonumbering task from above, but set the states set_number=false
. The motions should not get a number and have a blank one, if it was not provided in the payload.
The request user needs:
motion.can_manage
if he has his vote delegated and the meeting hasusers_forbid_delegator_as_submitter
motion.can_create_amendments
iflead_motion_id
is givenmotion.can_create
else
If the request user does not have motion.can_manage
, the fields in the payload are restricted with a whitelist. These fields are contained:
meeting_id
title
text
reason
lead_motion_id
amendment_paragraph
category_id
workflow_id
If lead_motion_id
is given and category_id
is empty, the value of category_id
is set to the value of the lead motion.