Reinstate nullable GroupPagePermission.permission_type and make Permission FK nullable

pull/10616/head
Sage Abdullah 2023-06-21 11:15:48 +01:00 zatwierdzone przez Matt Westcott
rodzic 34adc4c657
commit b4cb61aaf6
3 zmienionych plików z 22 dodań i 37 usunięć

Wyświetl plik

@ -10,6 +10,9 @@ class Migration(migrations.Migration):
("wagtailcore", "0084_add_default_page_permissions"),
]
# Add a nullable permission ForeignKey and make the old permission_type
# field nullable so both formats still work for the duration of the
# deprecation period.
operations = [
migrations.AddField(
model_name="grouppagepermission",
@ -22,23 +25,23 @@ class Migration(migrations.Migration):
verbose_name="permission",
),
),
# Make permission_type nullable so the RemoveField operation will be reversible
migrations.AlterField(
model_name="grouppagepermission",
name="permission_type",
field=models.CharField(
verbose_name="permission type",
null=True,
blank=True,
max_length=20,
choices=[
("add", "Add/edit pages you own"),
("edit", "Edit any page"),
("publish", "Publish any page"),
("bulk_delete", "Delete pages with children"),
# Use "change" instead of "edit" to match Django's permission codename
("change", "Edit any page"),
("lock", "Lock/unlock pages you've locked"),
("publish", "Publish any page"),
("unlock", "Unlock any page"),
],
max_length=20,
verbose_name="permission type",
),
),
]

Wyświetl plik

@ -1,31 +0,0 @@
# Generated by Django 4.2.1 on 2023-06-14 16:35
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("wagtailcore", "0086_populate_grouppagepermission_permission"),
]
operations = [
migrations.AlterField(
model_name="grouppagepermission",
name="permission",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="auth.permission",
verbose_name="permission",
),
),
migrations.AlterUniqueTogether(
name="grouppagepermission",
unique_together={("group", "page", "permission")},
),
migrations.RemoveField(
model_name="grouppagepermission",
name="permission_type",
),
]

Wyświetl plik

@ -1110,6 +1110,10 @@ PAGE_PERMISSION_TYPES = [
("unlock_page", _("Unlock"), _("Unlock any page")),
]
PAGE_PERMISSION_TYPE_CHOICES = [
(identifier[:-5], long_label) for identifier, _, long_label in PAGE_PERMISSION_TYPES
]
PAGE_PERMISSION_CODENAMES = [identifier for identifier, *_ in PAGE_PERMISSION_TYPES]
@ -2928,13 +2932,22 @@ class GroupPagePermission(models.Model):
permission = models.ForeignKey(
Permission,
verbose_name=_("permission"),
null=True,
blank=True,
on_delete=models.CASCADE,
)
permission_type = models.CharField(
verbose_name=_("permission type"),
null=True,
blank=True,
max_length=20,
choices=PAGE_PERMISSION_TYPE_CHOICES,
)
objects = GroupPagePermissionManager()
class Meta:
unique_together = ("group", "page", "permission")
unique_together = ("group", "page", "permission_type")
verbose_name = _("group page permission")
verbose_name_plural = _("group page permissions")