From ba258c66999c0a2fc87089dbe945e4e02c208d89 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Wed, 24 Jan 2024 18:34:39 -0400
Subject: [PATCH] fix: add change permissions to the Host+ group

---
 program/management/commands/addpermissions.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/program/management/commands/addpermissions.py b/program/management/commands/addpermissions.py
index 40147440..3eef524c 100644
--- a/program/management/commands/addpermissions.py
+++ b/program/management/commands/addpermissions.py
@@ -12,7 +12,7 @@ class Command(BaseCommand):
             codename__startswith="edit"
         )
         self.stdout.write(
-            f"  Adding app permissions to the '{program_group}' group... ",
+            f"Adding app permissions to the '{program_group}' group... ",
             ending="",
         )
         self.stdout.flush()
@@ -24,7 +24,7 @@ class Command(BaseCommand):
             content_type__model__in=["note", "notelink"]
         ).exclude(codename__startswith="edit")
         self.stdout.write(
-            f"  Adding model permissions on note & notelink to the '{host_group}' group... ",
+            f"Adding model permissions on note & notelink to the '{host_group}' group... ",
             ending="",
         )
         self.stdout.flush()
@@ -32,11 +32,21 @@ class Command(BaseCommand):
         self.stdout.write(self.style.SUCCESS(len(model_permissions)))
 
         host_plus_group = Group.objects.get(name=settings.ENTITLED_GROUPS[1])
+        change_permissions = Permission.objects.filter(
+            codename__startswith="change", content_type__model__in=["host", "note", "show"]
+        )
+        self.stdout.write(
+            f"Adding change permissions on host, note & show to the '{host_plus_group}' group... ",
+            ending="",
+        )
+        host_plus_group.permissions.add(*change_permissions)
+        self.stdout.write(self.style.SUCCESS(len(change_permissions)))
+        self.stdout.flush()
         edit_permissions = Permission.objects.filter(
             codename__startswith="edit", content_type__model__in=["host", "note", "show"]
         )
         self.stdout.write(
-            f"  Adding edit permissions on host, note & show to the '{host_plus_group}' group... ",
+            f"Adding edit permissions on host, note & show to the '{host_plus_group}' group... ",
             ending="",
         )
         self.stdout.flush()
-- 
GitLab