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

Add meeting_user_id to user.create action result #1865

Closed
wants to merge 110 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
db7c973
github checks also for feature branches
Oct 26, 2022
5288c0b
Move template field comment_$ into meeting_user (#1514)
reiterl Nov 9, 2022
ef88a99
Move personal data template fields into meeting_user (#1516)
reiterl Nov 10, 2022
6697fee
Move personal_note_ids into meeting_user. (#1523)
reiterl Nov 10, 2022
42efb39
Add meeting_user collection and actions and tests for it. (#1513)
reiterl Oct 27, 2022
d40f458
Add user_meeting collection and actions and tests for it.
reiterl Oct 25, 2022
49e793d
Rename user_meeting into meeting_user.
reiterl Oct 26, 2022
bdbfa8f
Move personal data template fields in meeting_user.
reiterl Oct 28, 2022
772ddbb
Add draft version of rm template fields speaker_ids.
reiterl Nov 3, 2022
a64c1d0
Move speaker_ into meeting_user, update tests and actions.
reiterl Nov 7, 2022
c22bbbc
Add missing import And
reiterl Nov 9, 2022
0f8c068
Small change after rebase.
reiterl Nov 10, 2022
cd4e968
Update error message. Give user_id.
reiterl Nov 10, 2022
7bfca74
Move template field speaker_ids into meeting_user. (#1526)
reiterl Nov 11, 2022
971f41f
Add user_meeting collection and actions and tests for it.
reiterl Oct 25, 2022
2ac6ea1
Rename user_meeting into meeting_user.
reiterl Oct 26, 2022
081a3a7
Move personal data template fields in meeting_user.
reiterl Oct 28, 2022
3b55ff0
Add missing import And
reiterl Nov 9, 2022
dc39ca6
Move chat_message_ into meeting_user. Update tests.
reiterl Nov 8, 2022
3cc4193
Move template field chat_message_ids into meeting_user (#1528)
reiterl Nov 11, 2022
7a8aa61
Add user_meeting collection and actions and tests for it.
reiterl Oct 25, 2022
468e7c0
Rename user_meeting into meeting_user.
reiterl Oct 26, 2022
1bb0301
Move personal data template fields in meeting_user.
reiterl Oct 28, 2022
83668ec
Add missing import And
reiterl Nov 9, 2022
437ca08
Move template field supported_motion_ids into meeting_user.
reiterl Nov 11, 2022
01fc0a9
Move template field supported_motion_ids into meeting_user. (#1529)
reiterl Nov 16, 2022
6eb28ab
Add user_meeting collection and actions and tests for it.
reiterl Oct 25, 2022
4f9df2f
Rename user_meeting into meeting_user.
reiterl Oct 26, 2022
fc44040
Move personal data template fields in meeting_user.
reiterl Oct 28, 2022
c45e954
Add missing import And
reiterl Nov 9, 2022
3cb9d6c
Move submitted_motion_ids into meeting_user. Update model, actions an…
reiterl Nov 15, 2022
df45a47
Small changes.
reiterl Nov 17, 2022
403ed6b
github checks also for feature branches
Oct 26, 2022
ca4b463
Move template field comment_$ into meeting_user (#1514)
reiterl Nov 9, 2022
2cf1c37
Move personal data template fields into meeting_user (#1516)
reiterl Nov 10, 2022
e737020
Move personal_note_ids into meeting_user. (#1523)
reiterl Nov 10, 2022
6a41322
PR1526 Move template field speaker_ids into meeting_user
reiterl Nov 21, 2022
5f319ed
Move template field chat_message_ids into meeting_user #1528
reiterl Nov 21, 2022
d97e4a7
Move template field supported_motion_ids into meeting_user. #1529
reiterl Nov 21, 2022
3574ff3
Move submitted_motion_ids into meeting_user #1532
reiterl Nov 21, 2022
4caaed7
Move assignment_candidate_ids into meeting_user (#1538)
reiterl Nov 22, 2022
06b3c1e
Move template field projection ids into meeting_user (#1539)
reiterl Nov 22, 2022
242e5e7
Move template fields poll_voted_ids, option_ids, vote_ids into meetin…
reiterl Nov 25, 2022
7a5f3c7
Move template fields vote_delegated_vote_ids, vote_delegated_to_id, …
reiterl Nov 25, 2022
0808fe9
Flatten logo_$_ids, font_$_ids and reverse fields to remove template …
reiterl Dec 1, 2022
cf59153
Flatten default_projector_xxx_id. Add a const to meeting. (#1551)
reiterl Dec 2, 2022
59977ba
Replace template field committee_management__ids (#1558)
reiterl Dec 14, 2022
c99a188
Replace template field amendment_paragraph with json field (#1562)
reiterl Dec 21, 2022
63a4e00
Rename motion.supporter_ids into motion.supporter_meeting_user_ids (#…
reiterl Jan 17, 2023
5742494
trigger feature/** branches for github workflow
r-peschke Jan 17, 2023
643afcc
Merge branch 'main on commit 1d2c303aabd31' into feature/remove-templ…
r-peschke Feb 15, 2023
5a704a9
fix import tests
r-peschke Feb 15, 2023
c817461
Issue1592 fix some restriction modes lost on moving template fields f…
r-peschke Feb 15, 2023
3d8307e
Add meeting_user.set_data and use it in user actions. (#1640)
reiterl Feb 17, 2023
cd7258d
Merge branch 'main' into feature/remove-template-fields
jsangmeister Feb 23, 2023
6f8a48b
Fix tests
jsangmeister Feb 23, 2023
fe1b0f1
Merge branch 'main' into feature/remove-template-fields
r-peschke Mar 7, 2023
7940990
Move template field group_ids into meeting_user (#1563)
reiterl Mar 10, 2023
9b1a707
Main with fixed motion forwarding merged
r-peschke Mar 13, 2023
11ce41e
Main with changed user_scope merged
r-peschke Mar 16, 2023
0069bda
main merged
r-peschke Mar 27, 2023
f25c0a1
I1660 remove template fields, reactivate tests (#1672)
r-peschke Mar 30, 2023
bd60052
I1681 remove template fields related code (#1682)
r-peschke Mar 31, 2023
ee04e19
I1649 some required changes (#1689)
r-peschke Apr 3, 2023
6b99ae2
Merge branch 'main' into feature/remove-template-fields
jsangmeister Apr 3, 2023
de68dc5
Merge branch 'main' into feature/remove-template-fields with models.yml
r-peschke Apr 5, 2023
5679f85
Reactivate user history (#1690)
jsangmeister Apr 12, 2023
b4a482a
Add topic.json_upload/import (#1678)
reiterl Apr 12, 2023
5b8da68
Add account import (#1697)
reiterl May 8, 2023
ec0de55
merged main into branch
r-peschke May 10, 2023
0879973
fix
r-peschke May 10, 2023
f00c799
Merge branch 'main' into feature/remove-template-fields
jsangmeister May 22, 2023
0a2dd28
Merge branch 'main' into feature/remove-template-fields
jsangmeister May 24, 2023
41c611a
Merge branch 'main' into feature/remove-template-fields
r-peschke Jun 2, 2023
13c2485
current datastore set commit hash
r-peschke Jun 2, 2023
1319b48
set datastore commit hash to e4edbb3a856ec3a24bcbe5eba73482da61ba24c7
r-peschke Jun 5, 2023
fd41ea8
merge main
r-peschke Jun 7, 2023
57ab1f3
merge main and fix conflicts
r-peschke Jun 7, 2023
395679d
fix test error
r-peschke Jun 7, 2023
d53c718
Merge branch 'main' into feature/remove-template-fields
jsangmeister Jun 8, 2023
98794a5
Template field removal migration (#1739)
jsangmeister Jun 9, 2023
e9241b7
Merge branch 'main' into feature/remove-template-fields
jsangmeister Jun 12, 2023
d0b5add
Merge branch 'main' into feature/remove-template-fields
jsangmeister Jun 13, 2023
c1c75c2
schema must allow None to reset vote forwarding (#1768)
r-peschke Jun 20, 2023
1fc0d64
Rename default_projector_agenda_item_ids field (#1772)
reiterl Jun 22, 2023
aea9be8
merge main into feature/remove-template-fields and fix errors
r-peschke Jun 28, 2023
7515d67
rename test_0043 file
r-peschke Jun 30, 2023
baf9c76
Merge branch 'main' into feature/remove-template-fields
reiterl Jun 30, 2023
97be1bf
Merge branch 'feature/remove-template-fields' of ssh://github.com/Ope…
reiterl Jun 30, 2023
6895a12
Small fix
reiterl Jun 30, 2023
7adea4b
Merge branch 'main' into feature/remove-template-fields
jsangmeister Jul 6, 2023
b306c21
base permissin test for feature/remove-template-fields fixed (#1791)
r-peschke Jul 6, 2023
2385f36
merge main into feature/remove-template-fields
r-peschke Jul 7, 2023
f95bb39
merge missed feature/remove-template-fields into branch
r-peschke Jul 7, 2023
03423c7
Fix test errors from main-merge
r-peschke Jul 10, 2023
01831e4
fix models.py checksum
r-peschke Jul 10, 2023
ea2238c
Merge branch 'main' into feature/remove-template-fields
jsangmeister Jul 11, 2023
2ca3823
Merge branch 'main' into feature/remove-template-fields
jsangmeister Jul 12, 2023
1a0d3a2
Merge branch 'main' into feature/remove-template-fields
jsangmeister Jul 12, 2023
fb140e3
[feature/remove-template-fields] Cleanup (#1754)
jsangmeister Jul 12, 2023
6024d30
Merge remote-tracking branch 'upstream/feature/remove-template-fields…
jsangmeister Jul 12, 2023
70ffa01
Merge branch 'main' into feature/remove-template-fields
jsangmeister Jul 13, 2023
ca31184
Merge branch 'main' into feature/remove-template-fields
reiterl Jul 13, 2023
998bea5
Merge branch 'feature/remove-template-fields' of ssh://github.com/Ope…
reiterl Jul 13, 2023
4e46350
Merge branch 'main' into feature/remove-template-fields
jsangmeister Jul 18, 2023
95d52ad
Merge branch 'main' into feature/remove-template-fields
reiterl Aug 7, 2023
ce018db
Fix relation handling with calculated fields handler (#1839)
reiterl Aug 8, 2023
3e0e64b
Add saml_id to the account import actions (#1821)
reiterl Aug 8, 2023
79e8a4e
Move additional model code to mixins (#1808)
jsangmeister Aug 8, 2023
99b1b0a
Add meeting_user_id to user.create action result
reiterl Aug 11, 2023
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
4 changes: 3 additions & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Continuous Integration

on:
pull_request:
branches: [ main ]
branches:
- main
- 'feature/**'

env:
PYTHON_VERSION: 3.10.x
Expand Down
194 changes: 65 additions & 129 deletions cli/generate_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
import string
import sys
from collections import ChainMap
from textwrap import dedent, indent
from typing import Any, Dict, List, Optional, Union
from textwrap import dedent
from typing import Any, Dict, List, Optional, Type, Union

import requests
import yaml

from openslides_backend.models.base import Model as BaseModel
from openslides_backend.models.fields import OnDelete
from openslides_backend.models.mixins import (
AgendaItemModelMixin,
MeetingModelMixin,
PollModelMixin,
)
from openslides_backend.shared.patterns import KEYSEPARATOR, Collection

SOURCE = "./global/meta/models.yml"
Expand Down Expand Up @@ -47,12 +53,18 @@
"generic-relation-list": "GenericRelationListField",
}

MODEL_MIXINS: Dict[str, Type] = {
"agenda_item": AgendaItemModelMixin,
"meeting": MeetingModelMixin,
"poll": PollModelMixin,
}

FILE_TEMPLATE = dedent(
"""\
# Code generated. DO NOT EDIT.

from openslides_backend.models import fields
from openslides_backend.models.base import Model
from . import fields
from .base import Model
"""
)

Expand All @@ -72,22 +84,13 @@ def main() -> None:
to:
collection: another_model
field:
type: structured-relation
name: another_$_attribute
replacement_collection: ...
through:
- ...
- ...
type: relation
name: another_attribute

another_model:
another_$_attribute:
type: template
replacement_collection: ...
fields:
type: relation-list
to:
collection: some_model
field: some_attribute
another_attribute:
type: relation_list
to: some_model/some_attribute_id
"""

global MODELS
Expand Down Expand Up @@ -122,6 +125,11 @@ def main() -> None:
MODELS = yaml.safe_load(models_yml)
with open(DESTINATION, "w") as dest:
dest.write(FILE_TEMPLATE)
dest.write(
"from .mixins import "
+ ", ".join(mixin.__name__ for mixin in MODEL_MIXINS.values())
+ "\n"
)
dest.write("\nMODELS_YML_CHECKSUM = " + repr(checksum) + "\n")
for collection, fields in MODELS.items():
if collection == "_migration_index":
Expand Down Expand Up @@ -163,37 +171,13 @@ class Model(Node):
MODEL_TEMPLATE = string.Template(
dedent(
"""

class ${class_name}(Model):
class ${class_name}(${base_classes}):
collection = "${collection}"
verbose_name = "${verbose_name}"

"""
)
)

ADDITIONAL_MODEL_CODE = {
"agenda_item": dedent(
"""
AGENDA_ITEM = "common"
INTERNAL_ITEM = "internal"
HIDDEN_ITEM = "hidden"
"""
),
"poll": dedent(
"""
STATE_CREATED = "created"
STATE_STARTED = "started"
STATE_FINISHED = "finished"
STATE_PUBLISHED = "published"

TYPE_ANALOG = "analog"
TYPE_NAMED = "named"
TYPE_PSEUDOANONYMOUS = "pseudoanonymous"
"""
),
}

def __init__(self, collection: str, fields: Dict[str, Dict[str, Any]]) -> None:
self.collection = collection
assert collection
Expand All @@ -205,16 +189,22 @@ def __init__(self, collection: str, fields: Dict[str, Dict[str, Any]]) -> None:

def get_code(self) -> str:
verbose_name = " ".join(self.collection.split("_"))
code = self.MODEL_TEMPLATE.substitute(
dict(
class_name=self.get_class_name(),
collection=self.collection,
verbose_name=verbose_name,
base_classes: List[Type] = [BaseModel]
if self.collection in MODEL_MIXINS:
base_classes.append(MODEL_MIXINS[self.collection])
code = (
self.MODEL_TEMPLATE.substitute(
{
"class_name": self.get_class_name(),
"base_classes": ", ".join(cls.__name__ for cls in base_classes),
"collection": self.collection,
"verbose_name": verbose_name,
}
)
+ "\n"
)
for field_name, attribute in self.attributes.items():
code += attribute.get_code(field_name)
code += indent(self.ADDITIONAL_MODEL_CODE.get(self.collection, ""), " " * 4)
return code

def get_class_name(self) -> str:
Expand All @@ -223,8 +213,6 @@ def get_class_name(self) -> str:

class Attribute(Node):
type: str
replacement_collection: Optional[Collection] = None
replacement_enum: Optional[List[str]] = None
to: Optional["To"] = None
fields: Optional["Attribute"] = None
required: bool = False
Expand All @@ -234,15 +222,11 @@ class Attribute(Node):
equal_fields: Optional[Union[str, List[str]]] = None
contraints: Dict[str, Any]

is_template: bool = False

FIELD_TEMPLATE = string.Template(
" ${field_name} = fields.${field_class}(${properties})\n"
)

def __init__(
self, value: Union[str, Dict], is_inner_attribute: bool = False
) -> None:
def __init__(self, value: Union[str, Dict]) -> None:
self.FIELD_CLASSES = {
**COMMON_FIELD_CLASSES,
**RELATION_FIELD_CLASSES,
Expand All @@ -253,59 +237,34 @@ def __init__(
self.type = value
else:
self.type = value.get("type", "")
if self.type == "template":
self.is_template = True
replacement_str = value.get("replacement_collection")
self.replacement_collection = (
replacement_str if replacement_str else None
)
inner_value = value.get("fields")
assert not is_inner_attribute and inner_value
self.fields = type(self)(inner_value, is_inner_attribute=True)
if self.fields.type in ("relation", "relation-list"):
self.replacement_enum = value.get("replacement_enum")
assert not self.replacement_collection or not self.replacement_enum
if self.replacement_enum:
self.required = self.fields.required
if self.type in RELATION_FIELD_CLASSES.keys():
self.to = To(value.get("to", {}))
self.on_delete = value.get("on_delete")
else:
if self.type in RELATION_FIELD_CLASSES.keys():
self.to = To(value.get("to", {}))
self.on_delete = value.get("on_delete")
else:
assert self.type in COMMON_FIELD_CLASSES.keys(), (
"Invalid type: " + self.type
)
self.required = value.get("required", False)
self.read_only = value.get("read_only", False)
self.default = value.get("default")
self.equal_fields = value.get("equal_fields")
for k, v in value.items():
if k not in (
"type",
"to",
"required",
"read_only",
"default",
"on_delete",
"equal_fields",
"items",
"restriction_mode",
):
self.contraints[k] = v
elif self.type in ("string[]", "number[]") and k == "items":
self.in_array_constraints.update(v)
assert self.type in COMMON_FIELD_CLASSES.keys(), (
"Invalid type: " + self.type
)
self.required = value.get("required", False)
self.read_only = value.get("read_only", False)
self.default = value.get("default")
self.equal_fields = value.get("equal_fields")
for k, v in value.items():
if k not in (
"type",
"to",
"required",
"read_only",
"default",
"on_delete",
"equal_fields",
"items",
"restriction_mode",
):
self.contraints[k] = v
elif self.type in ("string[]", "number[]") and k == "items":
self.in_array_constraints.update(v)

def get_code(self, field_name: str) -> str:
structured_field_sign = field_name.find("$")
if structured_field_sign == -1:
assert not self.is_template
return self.get_code_for_normal(field_name)
assert self.is_template
field_name = field_name.replace("$", "", 1)
assert field_name.find("$") == -1
return self.get_code_for_template(field_name, structured_field_sign)

def get_code_for_normal(self, field_name: str) -> str:
if field_name == "organization_id":
field_class = "OrganizationField"
else:
Expand Down Expand Up @@ -336,29 +295,6 @@ def get_code_for_normal(self, field_name: str) -> str:
)
)

def get_code_for_template(self, field_name: str, index: int) -> str:
assert self.fields is not None
field_class = f"Template{self.FIELD_CLASSES[self.fields.type]}"
properties = f"index={index}, "
if self.replacement_collection:
properties += f"replacement_collection={repr(self.replacement_collection)},"
if self.fields.to:
properties += self.fields.to.get_properties()
if self.fields.required:
properties += "required=True,"
if self.fields.on_delete:
assert self.fields.on_delete in [mode.value for mode in OnDelete]
properties += f"on_delete=fields.OnDelete.{self.fields.on_delete},"
if self.contraints:
properties += f"constraints={repr(self.contraints)},"
if self.fields.contraints:
properties += f"constraints={repr(self.fields.contraints)},"
if self.replacement_enum:
properties += f"replacement_enum={repr(self.replacement_enum)},"
return self.FIELD_TEMPLATE.substitute(
dict(field_name=field_name, field_class=field_class, properties=properties)
)


class To(Node):
to: Dict[Collection, str] # collection <-> field_name
Expand Down
Loading