kopia lustrzana https://github.com/wagtail/wagtail
Fix permission checkboxes for Django 3.1
rodzic
884b055289
commit
12a35c79b4
|
@ -1,5 +1,6 @@
|
|||
import itertools
|
||||
|
||||
from django import VERSION as DJANGO_VERSION
|
||||
from django import template
|
||||
|
||||
from wagtail.core import hooks
|
||||
|
@ -29,8 +30,7 @@ def format_permissions(permission_bound_field):
|
|||
]
|
||||
|
||||
(where 'checkbox' is an object with a tag() method that renders the checkbox as HTML;
|
||||
this is an instance of django.forms.widgets.CheckboxChoiceInput on Django <1.11,
|
||||
and a BoundWidget on Django >=1.11)
|
||||
this is a BoundWidget on Django >=1.11)
|
||||
|
||||
- and returns a table template formatted with this list.
|
||||
|
||||
|
@ -41,10 +41,18 @@ def format_permissions(permission_bound_field):
|
|||
|
||||
# iterate over permission_bound_field to build a lookup of individual renderable
|
||||
# checkbox objects
|
||||
checkboxes_by_id = {
|
||||
int(checkbox.data['value']): checkbox
|
||||
for checkbox in permission_bound_field
|
||||
}
|
||||
if DJANGO_VERSION < (3, 1):
|
||||
# checkbox.data['value'] gives the ID
|
||||
checkboxes_by_id = {
|
||||
int(checkbox.data['value']): checkbox
|
||||
for checkbox in permission_bound_field
|
||||
}
|
||||
else:
|
||||
# checkbox.data['value'] gives a ModelChoiceIteratorValue
|
||||
checkboxes_by_id = {
|
||||
int(checkbox.data['value'].value): checkbox
|
||||
for checkbox in permission_bound_field
|
||||
}
|
||||
|
||||
object_perms = []
|
||||
other_perms = []
|
||||
|
|
Ładowanie…
Reference in New Issue