From 7a8e4475a96eed95c7615c01ee4de71e1291f74e Mon Sep 17 00:00:00 2001 From: Hannes Janott Date: Mon, 16 Dec 2024 12:28:21 +0100 Subject: [PATCH 1/3] remove global folder and move folder contents up --- .gitmodules | 2 +- Dockerfile | 3 ++- Makefile | 8 ++++---- README.md | 2 +- cli/generate_models.py | 2 +- cli/generate_permissions.py | 2 +- {global/data => data}/example-data.json | 0 {global/data => data}/initial-data.json | 0 dev/Dockerfile.dev | 3 ++- dev/docker-compose.dev.yml | 1 - docs/actions/group.update.md | 2 +- docs/actions/meeting.create.md | 4 ++-- global/meta => meta | 0 openslides_backend/http/application.py | 1 - openslides_backend/shared/util.py | 4 ++-- scripts/fetch-example-data.sh | 2 +- setup.cfg | 2 +- tests/system/action/mediafile/test_upload.py | 4 ++-- tests/system/action/meeting/test_import.py | 4 ++-- tests/system/action/organization/test_initial_import.py | 2 +- 20 files changed, 24 insertions(+), 24 deletions(-) rename {global/data => data}/example-data.json (100%) rename {global/data => data}/initial-data.json (100%) rename global/meta => meta (100%) diff --git a/.gitmodules b/.gitmodules index 455695422f..8cc7f3bc29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "openslides-meta"] - path = global/meta + path = meta url = https://github.com/OpenSlides/openslides-meta.git diff --git a/Dockerfile b/Dockerfile index d77d6ca825..340b0c33ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,8 @@ ENV PYTHONPATH /app COPY --chown=appuser:appuser scripts scripts COPY --chown=appuser:appuser entrypoint.sh ./ COPY --chown=appuser:appuser openslides_backend openslides_backend -COPY --chown=appuser:appuser global global +COPY --chown=appuser:appuser meta meta +COPY --chown=appuser:appuser data data ARG VERSION=dev RUN echo "$VERSION" > openslides_backend/version.txt diff --git a/Makefile b/Makefile index 658f265ab5..cb8ad0fe09 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Development and testing inside docker container or without docker (only unit and integration tests) -paths = openslides_backend/ tests/ cli/ global/meta/dev/src/ +paths = openslides_backend/ tests/ cli/ meta/dev/src/ all: pyupgrade black autoflake isort flake8 mypy @@ -40,7 +40,7 @@ test-unit-integration: check-all: validate-models-yml check-models check-initial-data-json check-example-data-json check-permissions validate-models-yml: - make -C global/meta/dev validate-models + make -C meta/dev validate-models generate-models: python cli/generate_models.py $(MODELS_PATH) @@ -57,10 +57,10 @@ check-permissions: python cli/generate_permissions.py --check check-initial-data-json: - python cli/check_json.py global/data/initial-data.json + python cli/check_json.py data/initial-data.json check-example-data-json: - python cli/check_json.py global/data/example-data.json + python cli/check_json.py data/example-data.json run-debug: OPENSLIDES_DEVELOPMENT=1 python -m openslides_backend diff --git a/README.md b/README.md index a09268a280..a99c478612 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ To generate a new models.py file run (inside the docker container) $ make generate-models -The original models.yml is now included in this repository at global/meta/. If you do not want to generate from the current backend, you can provide either a local path or an URL via the variable `MODELS_PATH`. This way, you can generate only partial changes if multiple changes to the models file were merged into the main: +The original models.yml is now included in this repository at meta/. If you do not want to generate from the current backend, you can provide either a local path or a URL via the variable `MODELS_PATH`. This way, you can generate only partial changes if multiple changes to the models file were merged into the main: $ MODEL_PATH="local path or GitHub link" make generate-models diff --git a/cli/generate_models.py b/cli/generate_models.py index 641ea97373..dbd2109725 100644 --- a/cli/generate_models.py +++ b/cli/generate_models.py @@ -20,7 +20,7 @@ ) from openslides_backend.shared.patterns import KEYSEPARATOR, Collection -SOURCE = "./global/meta/models.yml" +SOURCE = "./meta/models.yml" DESTINATION = os.path.abspath( os.path.join( diff --git a/cli/generate_permissions.py b/cli/generate_permissions.py index 0740edcc20..74f40221f1 100644 --- a/cli/generate_permissions.py +++ b/cli/generate_permissions.py @@ -10,7 +10,7 @@ from cli.util.util import assert_equal, open_output, open_yml_file, parse_arguments from openslides_backend.permissions.get_permission_parts import get_permission_parts -SOURCE = "./global/meta/permission.yml" +SOURCE = "./meta/permission.yml" DESTINATION = os.path.abspath( os.path.join( diff --git a/global/data/example-data.json b/data/example-data.json similarity index 100% rename from global/data/example-data.json rename to data/example-data.json diff --git a/global/data/initial-data.json b/data/initial-data.json similarity index 100% rename from global/data/initial-data.json rename to data/initial-data.json diff --git a/dev/Dockerfile.dev b/dev/Dockerfile.dev index 47a45a06fa..2000f9e75e 100644 --- a/dev/Dockerfile.dev +++ b/dev/Dockerfile.dev @@ -13,8 +13,9 @@ COPY dev/cleanup.sh . # Copy files which are mounted to make the full stack work COPY scripts scripts -COPY global global COPY cli cli +COPY data data +COPY meta meta COPY Makefile . COPY setup.cfg . diff --git a/dev/docker-compose.dev.yml b/dev/docker-compose.dev.yml index 572106bd6f..df50a7a186 100644 --- a/dev/docker-compose.dev.yml +++ b/dev/docker-compose.dev.yml @@ -15,7 +15,6 @@ services: - ../openslides_backend:/app/openslides_backend - ../tests:/app/tests - ../cli:/app/cli - - ../global:/app/global - ../scripts:/app/scripts environment: - DATASTORE_READER_HOST=datastore-reader diff --git a/docs/actions/group.update.md b/docs/actions/group.update.md index ac4b815345..074789f2e4 100644 --- a/docs/actions/group.update.md +++ b/docs/actions/group.update.md @@ -12,7 +12,7 @@ ``` ## Action -Updates the group. Permissions are restricted to the following enum: https://github.com/OpenSlides/openslides-backend/blob/fae36a0b055bbaa463da4768343080c285fe8178/global/meta/models.yml#L1621-L1656 +Updates the group. Permissions are restricted to the group.permissions enum inside https://github.com/OpenSlides/openslides-meta/blob/main/models.yml. If the group is the meetings anonymous group, the name may not be changed and the permissions have to be in the following whitelist: - agenda_item.can_see, diff --git a/docs/actions/meeting.create.md b/docs/actions/meeting.create.md index 6386c9a33d..6dda7ffbd0 100644 --- a/docs/actions/meeting.create.md +++ b/docs/actions/meeting.create.md @@ -24,10 +24,10 @@ It has to be checked whether the `organization.limit_of_meetings` is unlimited (=0) or lower than the amount of active meetings in `organization.active_meeting_ids`. When creating a meeting the following objects have to be created, too: -- Groups: `Default`, `Admin`, `Delegates`, `Staff`, `Committees`. The first one is set as `meeting/default_group_id`, the second one as `meeting/admin_group_id`. The permissions can be found in the [initial-data.json](https://github.com/OpenSlides/openslides-backend/tree/main/global/data/initial-data.json)). +- Groups: `Default`, `Admin`, `Delegates`, `Staff`, `Committees`. The first one is set as `meeting/default_group_id`, the second one as `meeting/admin_group_id`. The permissions can be found in the [initial-data.json](https://github.com/OpenSlides/openslides-backend/tree/main/data/initial-data.json)). - Projector: One projector named `"Default projector"` must be created and set as `meeting/reference_projector_id`. - All default projectors (`meeting/default_projector_*_ids`, see `models.yml`) must be set to the one projector -- Motion workflow and states: Create one workflow `"simple workflow"` which is set as `meeting/motions_default_workflow_id` and `meeting/motions_default_amendment_workflow_id`. Create four states (analog as in the [initial-data.json](https://github.com/OpenSlides/openslides-backend/tree/main/global/data/initial-data.json)). +- Motion workflow and states: Create one workflow `"simple workflow"` which is set as `meeting/motions_default_workflow_id` and `meeting/motions_default_amendment_workflow_id`. Create four states (analog as in the [initial-data.json](https://github.com/OpenSlides/openslides-backend/tree/main/data/initial-data.json)). - Two countdowns are created and set as `meeting/list_of_speakers_countdown` (name: "List of speakers countdown") and `meeting/voting_countdown` (name: "Voting countdown"). If `user_ids` are given, it must be checked that it is a subset of `committee/user_ids`. Each user is added to the meeting by being added to the default group. diff --git a/global/meta b/meta similarity index 100% rename from global/meta rename to meta diff --git a/openslides_backend/http/application.py b/openslides_backend/http/application.py index d55d647ab6..2b5e51ca51 100644 --- a/openslides_backend/http/application.py +++ b/openslides_backend/http/application.py @@ -57,7 +57,6 @@ def create_initial_data(self) -> None: Path(__file__).parent / ".." / ".." - / "global" / "data" / f"{file_prefix}-data.json" ) diff --git a/openslides_backend/shared/util.py b/openslides_backend/shared/util.py index b77c02cddd..a36c564c51 100644 --- a/openslides_backend/shared/util.py +++ b/openslides_backend/shared/util.py @@ -74,8 +74,8 @@ "word-wrap", ] -INITIAL_DATA_FILE = "global/data/initial-data.json" -EXAMPLE_DATA_FILE = "global/data/example-data.json" +INITIAL_DATA_FILE = "data/initial-data.json" +EXAMPLE_DATA_FILE = "data/example-data.json" ONE_ORGANIZATION_ID = 1 ONE_ORGANIZATION_FQID = fqid_from_collection_and_id("organization", ONE_ORGANIZATION_ID) diff --git a/scripts/fetch-example-data.sh b/scripts/fetch-example-data.sh index 9f223e327e..25d7271e3d 100755 --- a/scripts/fetch-example-data.sh +++ b/scripts/fetch-example-data.sh @@ -3,4 +3,4 @@ set -e file=${1:-example-data.json} -curl https://raw.githubusercontent.com/OpenSlides/openslides-backend/main/global/data/example-data.json --output $file +curl https://raw.githubusercontent.com/OpenSlides/openslides-backend/main/data/example-data.json --output $file diff --git a/setup.cfg b/setup.cfg index dc886bf457..78e91862eb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,4 @@ -# The following sections must be kept in sync with global/meta/dev/setup.cfg +# The following sections must be kept in sync with meta/dev/setup.cfg [autoflake] verbose = true diff --git a/tests/system/action/mediafile/test_upload.py b/tests/system/action/mediafile/test_upload.py index df3dffeee9..c0b24f67a7 100644 --- a/tests/system/action/mediafile/test_upload.py +++ b/tests/system/action/mediafile/test_upload.py @@ -6,7 +6,7 @@ from openslides_backend.permissions.management_levels import OrganizationManagementLevel from openslides_backend.permissions.permissions import Permissions -from openslides_backend.shared.util import ONE_ORGANIZATION_FQID, get_initial_data_file +from openslides_backend.shared.util import ONE_ORGANIZATION_FQID, get_initial_data_file, INITIAL_DATA_FILE from tests.system.action.base import BaseActionTestCase @@ -473,7 +473,7 @@ def test_upload_json_detect_html(self) -> None: ) filename = "test.json" data = json.dumps( - get_initial_data_file("global/data/initial-data.json") + get_initial_data_file(INITIAL_DATA_FILE) ).encode() json_content = base64.b64encode(data).decode() response = self.request( diff --git a/tests/system/action/meeting/test_import.py b/tests/system/action/meeting/test_import.py index a209d75b98..7a618fb4e8 100644 --- a/tests/system/action/meeting/test_import.py +++ b/tests/system/action/meeting/test_import.py @@ -2269,7 +2269,7 @@ def test_all_migrations(self) -> None: @performance def test_big_file(self) -> None: data = { - "meeting": get_initial_data_file("global/data/put_your_file.json"), + "meeting": get_initial_data_file("data/put_your_file.json"), "committee_id": 1, } with Profiler("test_meeting_import.prof"): @@ -2642,7 +2642,7 @@ def test_delete_statutes(self) -> None: @pytest.mark.skip() def test_import_os3_data(self) -> None: - data_raw = get_initial_data_file("global/data/export-OS3-demo.json") + data_raw = get_initial_data_file("data/export-OS3-demo.json") data = {"committee_id": 1, "meeting": data_raw} response = self.request("meeting.import", data) self.assert_status_code(response, 200) diff --git a/tests/system/action/organization/test_initial_import.py b/tests/system/action/organization/test_initial_import.py index 1762ba3bab..30f98c6f2c 100644 --- a/tests/system/action/organization/test_initial_import.py +++ b/tests/system/action/organization/test_initial_import.py @@ -32,7 +32,7 @@ def test_initial_import_with_initial_data_file(self) -> None: def test_initial_import_with_example_data_file(self) -> None: self.datastore.truncate_db() - request_data = {"data": get_initial_data_file("global/data/example-data.json")} + request_data = {"data": get_initial_data_file("data/example-data.json")} request_data["data"]["organization"]["1"]["default_language"] = "de" response = self.request("organization.initial_import", request_data) self.assert_status_code(response, 200) From 3f1bc6dacbf8bb7e675f7b385f496a42304bf95e Mon Sep 17 00:00:00 2001 From: Hannes Janott Date: Mon, 16 Dec 2024 13:18:15 +0100 Subject: [PATCH 2/3] black --- tests/system/action/mediafile/test_upload.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/system/action/mediafile/test_upload.py b/tests/system/action/mediafile/test_upload.py index c0b24f67a7..3f50a901bf 100644 --- a/tests/system/action/mediafile/test_upload.py +++ b/tests/system/action/mediafile/test_upload.py @@ -6,7 +6,11 @@ from openslides_backend.permissions.management_levels import OrganizationManagementLevel from openslides_backend.permissions.permissions import Permissions -from openslides_backend.shared.util import ONE_ORGANIZATION_FQID, get_initial_data_file, INITIAL_DATA_FILE +from openslides_backend.shared.util import ( + INITIAL_DATA_FILE, + ONE_ORGANIZATION_FQID, + get_initial_data_file, +) from tests.system.action.base import BaseActionTestCase @@ -472,9 +476,7 @@ def test_upload_json_detect_html(self) -> None: "meeting/110", {"name": "name_DsJFXoot", "is_active_in_organization_id": 1} ) filename = "test.json" - data = json.dumps( - get_initial_data_file(INITIAL_DATA_FILE) - ).encode() + data = json.dumps(get_initial_data_file(INITIAL_DATA_FILE)).encode() json_content = base64.b64encode(data).decode() response = self.request( "mediafile.upload", From afcdc64dcebaddbcd3b1295e20644407a4d31d75 Mon Sep 17 00:00:00 2001 From: Hannes Janott Date: Tue, 17 Dec 2024 14:11:49 +0100 Subject: [PATCH 3/3] add meta, data and requirements volumes in docker compose --- dev/docker-compose.dev.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev/docker-compose.dev.yml b/dev/docker-compose.dev.yml index df50a7a186..f0150c79f4 100644 --- a/dev/docker-compose.dev.yml +++ b/dev/docker-compose.dev.yml @@ -15,6 +15,9 @@ services: - ../openslides_backend:/app/openslides_backend - ../tests:/app/tests - ../cli:/app/cli + - ../data:/app/data + - ../meta:/app/meta + - ../requirements:/app/requirements - ../scripts:/app/scripts environment: - DATASTORE_READER_HOST=datastore-reader