Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement motion import #1923

Merged
merged 84 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6af4af9
Create mixin for motion update and create payload validation
luisa-beerboom Oct 12, 2023
4bbf5a0
Make mixin check extensions
luisa-beerboom Oct 12, 2023
bb7c985
Split mixin into two and make recognizing multiple problems possible
luisa-beerboom Oct 13, 2023
883d72a
Prepare mixin for usage in json_upload
luisa-beerboom Oct 13, 2023
9fa591c
Un-comment json_upload headers
luisa-beerboom Oct 13, 2023
b951f32
Start implementing motion.json_upload
luisa-beerboom Oct 16, 2023
d79526b
Start building in lookups
luisa-beerboom Oct 18, 2023
427c05e
Finish implementing lookups
luisa-beerboom Oct 20, 2023
842b946
Start implementing motion.import
luisa-beerboom Oct 20, 2023
7afdd0f
Start writing tests for json_upload
luisa-beerboom Oct 23, 2023
2d6659b
Generalize test framework
luisa-beerboom Oct 24, 2023
fc4dda4
Fix tests
luisa-beerboom Oct 25, 2023
a0ed3b5
Fix tests anew
luisa-beerboom Oct 26, 2023
882437f
Add new tests
luisa-beerboom Oct 26, 2023
4ba788a
Fix more tests
luisa-beerboom Oct 26, 2023
67cbbbb
Refactor tests
luisa-beerboom Oct 26, 2023
f8967a4
Add duplicate tests
luisa-beerboom Oct 27, 2023
9edc874
Add category tests
luisa-beerboom Oct 27, 2023
d03fc9a
Add notes
luisa-beerboom Oct 27, 2023
2aa1fe0
Fix find duplicate test
luisa-beerboom Nov 6, 2023
36a7447
Add more category tests and expand Lookup class
luisa-beerboom Nov 6, 2023
9c8680a
Add last category test
luisa-beerboom Nov 6, 2023
8f1062a
Clean up category tests
luisa-beerboom Nov 6, 2023
709c486
Start adding username tests
luisa-beerboom Nov 6, 2023
2c19d6b
a
luisa-beerboom Nov 7, 2023
cf5c046
Generate users
luisa-beerboom Nov 8, 2023
9de6720
Add basic submitter tests
luisa-beerboom Nov 9, 2023
70d6ca8
Make first couple of submitter tests work
luisa-beerboom Nov 10, 2023
e64f402
Add more expansive submitter tests
luisa-beerboom Nov 10, 2023
10cb1d6
Finish simple user tests
luisa-beerboom Nov 13, 2023
2de0e69
Finalize user field functionality
luisa-beerboom Nov 13, 2023
8a67492
Finish json_upload
luisa-beerboom Nov 14, 2023
d87fee1
general cleanup and start work on import
luisa-beerboom Nov 14, 2023
a6030d7
Write motion import
luisa-beerboom Nov 15, 2023
d1e58c7
Add motion amendment test
luisa-beerboom Nov 15, 2023
f6c0f52
Add more tests
luisa-beerboom Nov 15, 2023
517b1ee
Make sure the json_upload registers intended deletions
luisa-beerboom Nov 16, 2023
1c4b790
Cleanup json upload
luisa-beerboom Nov 16, 2023
13190d6
First tests with references
luisa-beerboom Nov 16, 2023
1045d9c
Build in submitter sorting
luisa-beerboom Nov 17, 2023
cd85fdd
Finish import code for now
luisa-beerboom Nov 20, 2023
12ce905
Make payload checks in import
luisa-beerboom Nov 21, 2023
f5cfb43
Test different models found
luisa-beerboom Nov 21, 2023
6e3262d
Add more tests for import
luisa-beerboom Nov 22, 2023
f1c97dd
cleanup
luisa-beerboom Nov 22, 2023
e0bae68
Use datastore filters instead of lookups for foreign relations
luisa-beerboom Nov 22, 2023
24f00d2
Add amendment and verbose user field tests
luisa-beerboom Nov 22, 2023
2af82b4
add json_upload result based import tests
luisa-beerboom Nov 23, 2023
2708013
Remove wrong is_object flag from category_prefix header
luisa-beerboom Nov 27, 2023
51bc26a
Remove collection_field from Lookup class
luisa-beerboom Nov 28, 2023
e0df244
Stop mocking ids
luisa-beerboom Nov 28, 2023
62d3ac0
cleanup
luisa-beerboom Nov 28, 2023
83b1d08
Check forbidden_numbers first
luisa-beerboom Dec 4, 2023
651d3b1
Remove unnecessary code, make user warn messages more precise
luisa-beerboom Dec 5, 2023
d1dd5ea
Make tag warn messages more precise
luisa-beerboom Dec 5, 2023
b405013
cleanup
luisa-beerboom Dec 6, 2023
82cebbf
Fix after rebase
luisa-beerboom Dec 6, 2023
723b94b
Determine meeting membership via meeting_ids field in json_upload
luisa-beerboom Dec 7, 2023
7b966da
Change how list field errors are generated in json_upload
luisa-beerboom Dec 7, 2023
d7fc132
Make changes in accordance to recent models yml changes
luisa-beerboom Dec 12, 2023
1ec84af
Use one datastore call for all user fields in import
luisa-beerboom Dec 12, 2023
5b9d746
Show tag- and usernames in import errors
luisa-beerboom Dec 13, 2023
4e7ef87
Add database corrupt error for if user is found multiple times
luisa-beerboom Dec 13, 2023
5bebf40
Merge remote-tracking branch 'upstream/main' into 1713-motion-import
luisa-beerboom Feb 7, 2024
6bf2db4
Fix after merge
luisa-beerboom Feb 7, 2024
e50c7c4
cleanup
luisa-beerboom Feb 7, 2024
ee0f64c
Rewrite motion.json_upload test
luisa-beerboom Feb 9, 2024
828a905
Start reimplementing import tests
luisa-beerboom Feb 12, 2024
0f45d83
Fix current tests
luisa-beerboom Feb 13, 2024
43d607f
Finish tests and function for now
luisa-beerboom Feb 14, 2024
4818a9a
Merge branch 'main' into 1713-motion-import
luisa-beerboom Feb 15, 2024
590f82c
cleanup
luisa-beerboom Feb 15, 2024
5576ffd
Merge remote-tracking branch 'upstream/main' into 1713-motion-import
luisa-beerboom Feb 15, 2024
4d6148e
cleanup
luisa-beerboom Feb 15, 2024
6e5924c
Maybe fix tests
luisa-beerboom Feb 15, 2024
cfdae3d
Add som tests
luisa-beerboom Feb 16, 2024
944c74b
Fix tests
luisa-beerboom Feb 19, 2024
d102dfd
Merge remote-tracking branch 'upstream/main' into 1713-motion-import
luisa-beerboom Feb 19, 2024
21ed7af
Fix meta reference
luisa-beerboom Feb 20, 2024
79fc088
use assert_model_exists
luisa-beerboom Feb 21, 2024
ebddc9a
Update meta to main
luisa-beerboom Feb 21, 2024
9cb3bb5
Update meta to main 2
luisa-beerboom Feb 21, 2024
aa818a6
Merge remote-tracking branch 'upstream/main' into 1713-motion-import
luisa-beerboom Feb 21, 2024
201e85f
Merge branch 'main' into 1713-motion-import
jsangmeister Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/actions/motion.json_upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The types noted below are the internal types after conversion in the backend. Se
text: string, // info: done, error
// all optional, but see rules below
number: string, // unique when set, info: done, generated or error
reason: string, // required if the meeting has "motions_reason_required", info: done or error
reason: string, // required for create if the meeting has "motions_reason_required", info: done or error
submitters_verbose: string[],
submitters_username: string[], // info: done, generated, warning, error if len(submitters_verbose) > len(submitters_username)
supporters_verbose: string[],
Expand Down
2 changes: 1 addition & 1 deletion global/meta
Submodule meta updated 1 files
+1 −0 models.yml
2 changes: 2 additions & 0 deletions openslides_backend/action/actions/motion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
create_forwarded,
delete,
follow_recommendation,
import_,
json_upload,
reset_recommendation,
reset_state,
set_recommendation,
Expand Down
35 changes: 12 additions & 23 deletions openslides_backend/action/actions/motion/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
from ..agenda_item.agenda_creation import agenda_creation_properties
from .create_base import MotionCreateBase
from .mixins import AmendmentParagraphHelper, TextHashMixin
from .payload_validation_mixin import MotionCreatePayloadValidationMixin


@register_action("motion.create")
class MotionCreate(AmendmentParagraphHelper, TextHashMixin, MotionCreateBase):
class MotionCreate(
AmendmentParagraphHelper,
MotionCreatePayloadValidationMixin,
TextHashMixin,
MotionCreateBase,
):
"""
Create Action for motions.
"""
Expand Down Expand Up @@ -85,30 +91,16 @@ def prefetch(self, action_data: ActionData) -> None:

def update_instance(self, instance: dict[str, Any]) -> dict[str, Any]:
# special check logic
error_messages = self.get_create_payload_integrity_error_message(
instance, instance["meeting_id"]
)
if len(error_messages):
raise ActionException(error_messages[0]["message"])
if instance.get("lead_motion_id"):
if instance.get("statute_paragraph_id"):
raise ActionException(
"You can't give both of lead_motion_id and statute_paragraph_id."
)
if not instance.get("text") and not instance.get("amendment_paragraphs"):
raise ActionException(
"Text or amendment_paragraphs is required in this context."
)
if instance.get("text") and instance.get("amendment_paragraphs"):
raise ActionException(
"You can't give both of text and amendment_paragraphs"
)
if instance.get("text") and "amendment_paragraphs" in instance:
del instance["amendment_paragraphs"]
if instance.get("amendment_paragraphs") and "text" in instance:
del instance["text"]
else:
if not instance.get("text"):
raise ActionException("Text is required")
if instance.get("amendment_paragraphs"):
raise ActionException(
"You can't give amendment_paragraphs in this context"
)
if instance.get("amendment_paragraphs"):
self.validate_amendment_paragraphs(instance)
# if amendment and no category set, use category from the lead motion
Expand All @@ -128,11 +120,8 @@ def update_instance(self, instance: dict[str, Any]) -> dict[str, Any]:
"motions_default_workflow_id",
"motions_default_amendment_workflow_id",
"motions_default_statute_amendment_workflow_id",
"motions_reason_required",
],
)
if meeting.get("motions_reason_required") and not instance.get("reason"):
raise ActionException("Reason is required")

self.set_state_from_workflow(instance, meeting)
self.create_submitters(instance)
Expand Down
Loading