Repository: digitalfabrik/integreat-cms

Issue:
Git release tag message malformed
### Describe the Bug
<!-- A clear and concise description of what the bug is. -->
Our release workflow parses the changelog and puts it as git tag message.
Unfortunately, this cannot contain markdown, but only plain text.

### Expected Behavior
<!-- A clear and concise description of what you expected to happen. -->
Since issue links are automatically converted, I suggest to convert each line
`* [ [#num](link) ] description` to
`* [ link ] description`
before the git tag is created.
The format of the changelog itself should remain the same, since it's used in other places that expect markdown syntax.

Additionally, there is a spacing between the first and the second line, so I suggest to add an additional subject line before the normal changelog entries.
### Actual Behavior
<!-- A clear and concise description of what actually happened. -->
See https://github.com/digitalfabrik/integreat-cms/tags:
![Screenshot 2022-02-15 at 12-18-22 digitalfabrik integreat-cms New content management back end for the Integreat App - a mul](https://user-images.githubusercontent.com/16021269/154051761-f4ceb170-82d0-4ce5-a3e9-a9b3d9e018a3.png)


### Additional Information
<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->
These are the lines where we need to change the format of the git tag:
https://github.com/digitalfabrik/integreat-cms/blob/8391dd4e3a53758c3b7851bfaf76073f3859a31c/.circleci/config.yml#L307-L309



Discussion:

Resolving patch:
diff --git a/integreat_cms/cms/migrations/0002_roles.py b/integreat_cms/cms/migrations/0002_roles.py
--- a/integreat_cms/cms/migrations/0002_roles.py
+++ b/integreat_cms/cms/migrations/0002_roles.py
@@ -233,7 +233,7 @@ def add_roles(apps, schema_editor):
     """
     Add the default roles for users
 
-    :param apps:
+    :param apps: The configuration of installed applications
     :type apps: ~django.apps.registry.Apps
 
     :param schema_editor: The database abstraction layer that creates actual SQL code
@@ -266,7 +266,7 @@ def remove_roles(apps, schema_editor):
     """
     Remove the default roles for users
 
-    :param apps: The
+    :param apps: The configuration of installed applications
     :type apps: ~django.apps.registry.Apps
 
     :param schema_editor: The database abstraction layer that creates actual SQL code
diff --git a/integreat_cms/cms/migrations/0005_grant_imprint_deletion_permission.py b/integreat_cms/cms/migrations/0005_grant_imprint_deletion_permission.py
--- a/integreat_cms/cms/migrations/0005_grant_imprint_deletion_permission.py
+++ b/integreat_cms/cms/migrations/0005_grant_imprint_deletion_permission.py
@@ -7,7 +7,7 @@ def add_roles(apps, schema_editor):
     """
     Add the default roles for users
 
-    :param apps:
+    :param apps: The configuration of installed applications
     :type apps: ~django.apps.registry.Apps
 
     :param schema_editor: The database abstraction layer that creates actual SQL code
@@ -28,7 +28,7 @@ def remove_roles(apps, schema_editor):
     """
     Remove the default roles for users
 
-    :param apps: The
+    :param apps: The configuration of installed applications
     :type apps: ~django.apps.registry.Apps
 
     :param schema_editor: The database abstraction layer that creates actual SQL code
diff --git a/integreat_cms/cms/migrations/0007_change_role_permissions.py b/integreat_cms/cms/migrations/0007_change_role_permissions.py
new file mode 100644
--- /dev/null
+++ b/integreat_cms/cms/migrations/0007_change_role_permissions.py
@@ -0,0 +1,98 @@
+# Generated by Django 3.2.12 on 2022-02-21 13:05
+from django.db import migrations
+
+
+ROLES = [
+    {
+        "name": "EDITOR",
+        "add_permissions": [
+            "publish_event",
+        ],
+        "remove_permissions": [
+            "change_feedback",
+            "change_imprintpage",
+            "view_feedback",
+            "view_imprintpage",
+        ],
+    },
+    {
+        "name": "EVENT_MANAGER",
+        "add_permissions": [],
+        "remove_permissions": [
+            "change_feedback",
+            "view_feedback",
+            "view_imprintpage",
+        ],
+    },
+]
+
+# pylint: disable=unused-argument
+def update_roles(apps, schema_editor):
+    """
+    Update the permissions of roles
+
+    :param apps: The configuration of installed applications
+    :type apps: ~django.apps.registry.Apps
+
+    :param schema_editor: The database abstraction layer that creates actual SQL code
+    :type schema_editor: ~django.db.backends.base.schema.BaseDatabaseSchemaEditor
+    """
+    # We can't import the Person model directly as it may be a newer
+    # version than this migration expects. We use the historical version.
+    Group = apps.get_model("auth", "Group")
+    Permission = apps.get_model("auth", "Permission")
+
+    for role_conf in ROLES:
+        group = Group.objects.get(name=role_conf.get("name"))
+        add_permissions = Permission.objects.filter(
+            codename__in=role_conf.get("add_permissions")
+        )
+        group.permissions.add(*add_permissions)
+        remove_permissions = Permission.objects.filter(
+            codename__in=role_conf.get("remove_permissions")
+        )
+        group.permissions.remove(*remove_permissions)
+
+
+# pylint: disable=unused-argument
+def revert_roles(apps, schema_editor):
+    """
+    Revert the permission changes of this migration
+
+    :param apps: The configuration of installed applications
+    :type apps: ~django.apps.registry.Apps
+
+    :param schema_editor: The database abstraction layer that creates actual SQL code
+    :type schema_editor: ~django.db.backends.base.schema.BaseDatabaseSchemaEditor
+    """
+    # We can't import the Person model directly as it may be a newer
+    # version than this migration expects. We use the historical version.
+    Group = apps.get_model("auth", "Group")
+    Permission = apps.get_model("auth", "Permission")
+
+    for role_conf in ROLES:
+        group = Group.objects.get(name=role_conf.get("name"))
+        # The permissions that were added with this migration need to be removed
+        add_permissions = Permission.objects.filter(
+            codename__in=role_conf.get("add_permissions")
+        )
+        group.permissions.remove(*add_permissions)
+        # The migrations that were removed with this migration need to be added again
+        remove_permissions = Permission.objects.filter(
+            codename__in=role_conf.get("remove_permissions")
+        )
+        group.permissions.add(*remove_permissions)
+
+
+class Migration(migrations.Migration):
+    """
+    Migration file to update permissions of roles
+    """
+
+    dependencies = [
+        ("cms", "0006_region_custom_prefix"),
+    ]
+
+    operations = [
+        migrations.RunPython(update_roles, revert_roles),
+    ]


Test patch:
diff --git a/tests/cms/views/view_config.py b/tests/cms/views/view_config.py
--- a/tests/cms/views/view_config.py
+++ b/tests/cms/views/view_config.py
@@ -68,7 +68,7 @@
                 PRIV_STAFF_ROLES + [MANAGEMENT],
                 {"username": "new_username", "email": "new@email.address", "role": 1},
             ),
-            ("region_feedback", ROLES),
+            ("region_feedback", STAFF_ROLES + [MANAGEMENT]),
             ("region_users", STAFF_ROLES + [MANAGEMENT]),
             ("translation_coverage", ROLES),
             ("user_settings", ROLES),
@@ -320,10 +320,10 @@
             ("sitemap:region_language", ALL_ROLES),
             ("archived_pages", STAFF_ROLES + [MANAGEMENT, EDITOR]),
             ("archived_pois", ROLES),
-            ("edit_imprint", ROLES),
+            ("edit_imprint", STAFF_ROLES + [MANAGEMENT]),
             (
                 "edit_imprint",
-                PRIV_STAFF_ROLES + [MANAGEMENT, EDITOR],
+                PRIV_STAFF_ROLES + [MANAGEMENT],
                 {"title": "imprint", "submit_draft": True},
             ),
             ("events", ROLES),