Revert "Fix inconsistent use of model verbose_name in permissions UI"

This reverts commit e03c412507.
pull/11666/head
Sage Abdullah 2024-02-14 10:15:24 +00:00
rodzic c11db31a78
commit c4335d35de
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
6 zmienionych plików z 5 dodań i 76 usunięć

Wyświetl plik

@ -14,7 +14,6 @@ Changelog
* Fix: Ensure that unit tests correctly check for migrations in all core Wagtail apps (Matt Westcott)
* Fix: Correctly handle `date` objects on `human_readable_date` template tag (Jhonatan Lopes)
* Fix: Ensure re-ordering buttons work correctly when using a nested InlinePanel (Adrien Hamraoui)
* Fix: Resolve inconsistent use of model `verbose_name` in group edit view when listing custom permissions (Neeraj Yetheendran, Omkar Jadhav)
* Docs: Add contributing development documentation on how to work with a fork of Wagtail (Nix Asteri, Dan Braghis)
* Docs: Make sure the settings panel is listed in tabbed interface examples (Tibor Leupold)
* Docs: Update content and page names to their US spelling instead of UK spelling (Victoria Poromon)

Wyświetl plik

@ -27,7 +27,6 @@ depth: 1
* Ensure that unit tests correctly check for migrations in all core Wagtail apps (Matt Westcott)
* Correctly handle `date` objects on `human_readable_date` template tag (Jhonatan Lopes)
* Ensure re-ordering buttons work correctly when using a nested InlinePanel (Adrien Hamraoui)
* Resolve inconsistent use of model `verbose_name` in group edit view when listing custom permissions (Neeraj Yetheendran, Omkar Jadhav)
### Documentation

Wyświetl plik

@ -1,31 +0,0 @@
# Generated by Django 4.2.7 on 2024-02-12 22:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("tests", "0033_customcopyformpage"),
]
operations = [
migrations.CreateModel(
name="ModelWithVerboseName",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
],
options={
"verbose_name": "Custom verbose name",
"verbose_name_plural": "Custom verbose names",
},
),
]

Wyświetl plik

@ -1921,15 +1921,6 @@ class TableBlockStreamPage(Page):
content_panels = [FieldPanel("table")]
class ModelWithVerboseName(ClusterableModel):
class Meta:
verbose_name = "Custom verbose name"
verbose_name_plural = "Custom verbose names"
register_snippet(ModelWithVerboseName)
class UserProfile(models.Model):
# Wagtail's schema must be able to coexist alongside a custom UserProfile model
user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)

Wyświetl plik

@ -1,4 +1,5 @@
import itertools
import re
from collections import defaultdict
from django import template
@ -92,10 +93,7 @@ def format_permissions(permission_bound_field):
checkbox = checkboxes_by_id[perm.id]
# identify the main categories of permission, and assign to
# the relevant dict key, else bung in the 'custom_perms' list
permission_action = perm.codename.split("_", maxsplit=1)
permission_action = permission_action[permission_action[0].lower() == "can"]
permission_action = permission_action.rsplit(maxsplit=1)[0]
permission_action = perm.codename.split("_")[0]
if permission_action in main_permission_names:
if permission_action in extra_perms_exist:
extra_perms_exist[permission_action] = True
@ -108,7 +106,9 @@ def format_permissions(permission_bound_field):
custom_perms.append(
{
"perm": perm,
"name": f"Can {permission_action}",
"name": re.sub(
f"{perm.content_type.name}$", "", perm.name, flags=re.I
).strip(),
"selected": checkbox.data["selected"],
}
)

Wyświetl plik

@ -1573,35 +1573,6 @@ class TestGroupCreateView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
# Should not show inputs for publish permissions on models without DraftStateMixin
self.assertNotInHTML("Can publish advert", html)
def test_view_permission_if_model_has_verbose(self):
"""
Tests for bug #10982
https://github.com/wagtail/wagtail/issues/10982
Ensures Model Name or Verbose Name is stripped from Custom Permissions before being displayed
A Model "ModelWithVerboseName" is added to wagtail.test.testapp.models with verbose_name = "Custom Verbose Name"
"""
response = self.get()
self.assertContains(response, "Can view", msg_prefix="No Can view permission")
self.assertNotContains(
response,
"Can view model with verbose name",
msg_prefix=" Model Name not stripped from Can view permission",
)
self.assertNotContains(
response,
"Can view custom verbose name",
msg_prefix="Verbose Name of ModelWithVerboseName not stripped from Can view permission",
)
pattern = r'Can\sview\s\[.*?"'
self.assertNotRegex(
response.content.decode(),
pattern,
msg="Model Name not stripped from custom permissions",
)
class TestGroupEditView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
def setUp(self):