diff --git a/program/management/commands/addpermissions.py b/program/management/commands/addpermissions.py index 24bb99928fabe2532c0b962a225676963dcda7ad..9dacb9dacfb7e3ef7177c0957255a5fc7482da97 100644 --- a/program/management/commands/addpermissions.py +++ b/program/management/commands/addpermissions.py @@ -60,3 +60,24 @@ class Command(BaseCommand): self.stdout.flush() program_group.permissions.add(*edit_permissions) self.stdout.write(self.style.SUCCESS(str(len(edit_permissions)))) + + update_permissions = Permission.objects.filter( + codename__startswith="update", content_type__model__in=["host", "note", "show"] + ) + self.stdout.write( + f"Adding update permissions on host, note & show to the '{program_group}' group... ", + ending="", + ) + self.stdout.flush() + program_group.permissions.add(*update_permissions) + self.stdout.write(self.style.SUCCESS(str(len(update_permissions)))) + + create_permissions = Permission.objects.filter( + codename__startswith="create", content_type__model__in=["note"] + ) + self.stdout.write( + f"Adding create permissions on note to the '{program_group}' group... ", ending="" + ) + self.stdout.flush() + program_group.permissions.add(*create_permissions) + self.stdout.write(self.style.SUCCESS(str(len(update_permissions)))) diff --git a/program/migrations/0083_alter_host_options_alter_note_options_and_more.py b/program/migrations/0083_alter_host_options_alter_note_options_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..663b0977646928144f300d565a506e12cc18d901 --- /dev/null +++ b/program/migrations/0083_alter_host_options_alter_note_options_and_more.py @@ -0,0 +1,74 @@ +# Generated by Django 4.2.10 on 2024-03-13 20:53 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("program", "0082_remove_note_slug"), + ] + + operations = [ + migrations.AlterModelOptions( + name="host", + options={ + "ordering": ("name",), + "permissions": [ + ("edit__host__biography", "Can edit Host biography field"), + ("edit__host__name", "Can edit Host name field"), + ("update_host", "Can update host"), + ], + }, + ), + migrations.AlterModelOptions( + name="note", + options={ + "ordering": ("timeslot",), + "permissions": [ + ("edit__note__content", "Can edit content field"), + ("edit__note__contributors", "Can edit contributor field"), + ("edit__note__image", "Can edit image field"), + ("edit__note__languages", "Can edit language field"), + ("edit__note__links", "Can edit links field"), + ("edit__note__summary", "Can edit summary field"), + ("edit__note__tags", "Can edit tags field"), + ("edit__note__title", "Can edit title field"), + ("edit__note__topics", "Can edit topics field"), + ("create_note", "Can create note"), + ("update_note", "Can update note"), + ], + }, + ), + migrations.AlterModelOptions( + name="show", + options={ + "ordering": ("slug",), + "permissions": [ + ("display__show__internal_note", "Can display internal note field"), + ("edit__show__categories", "Can edit category field"), + ("edit__show__cba_series_id", "Can edit cba series id field"), + ("edit__show__default_playlist", "Can edit default playlist id field"), + ("edit__show__description", "Can edit description field"), + ("edit__show__email", "Can edit email field"), + ("edit__show__funding_categories", "Can edit funding category field"), + ("edit__show__hosts", "Can edit hosts field"), + ("edit__show__image", "Can edit image field"), + ("edit__show__internal_note", "Can edit internal note field"), + ("edit__show__is_active", "Can edit is active field"), + ("edit__show__languages", "Can edit language field"), + ("edit__show__links", "Can edit links field"), + ("edit__show__logo", "Can edit logo field"), + ("edit__show__music_focuses", "Can edit music focus field"), + ("edit__show__name", "Can edit name field"), + ("edit__show__owners", "Can edit owners field"), + ("edit__show__predecessor", "Can edit predecessor field"), + ("edit__show__short_description", "Can edit short_description field"), + ("edit__show__slug", "Can edit slug field"), + ("edit__show__topics", "Can edit topic field"), + ("edit__show__type", "Can edit type field"), + ("update_show", "Can update show"), + ], + }, + ), + ] diff --git a/program/models.py b/program/models.py index 3547ff27a2e58e553645cfa05d693f5240c2d259..091d66ed0798ec8b7cbc72f31ec27c9a7c4682ea 100644 --- a/program/models.py +++ b/program/models.py @@ -176,6 +176,8 @@ class Host(models.Model): permissions = [ ("edit__host__biography", "Can edit Host biography field"), ("edit__host__name", "Can edit Host name field"), + # overrides ownership + ("update_host", "Can update host"), ] def __str__(self): @@ -278,6 +280,8 @@ class Show(models.Model): ("edit__show__slug", "Can edit slug field"), ("edit__show__topics", "Can edit topic field"), ("edit__show__type", "Can edit type field"), + # overrides ownership + ("update_show", "Can update show"), ] def __str__(self): @@ -487,6 +491,9 @@ class Note(models.Model): ("edit__note__tags", "Can edit tags field"), ("edit__note__title", "Can edit title field"), ("edit__note__topics", "Can edit topics field"), + # overrides ownership + ("create_note", "Can create note"), + ("update_note", "Can update note"), ] def __str__(self):