Improve access grant and remove action form

Sort content type list of the access grant and remove action.
Use select2 for the content type filed of the access
grant and remove action.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-06-09 03:12:17 -04:00
parent cbfab25c94
commit 7407c67347
3 changed files with 14 additions and 2 deletions

View File

@@ -58,6 +58,11 @@ class GrantAccessAction(WorkflowAction):
field_order = ('content_type', 'object_id', 'roles', 'permissions')
label = _('Grant access')
widgets = {
'content_type': {
'class': 'django.forms.widgets.Select', 'kwargs': {
'attrs': {'class': 'select2'},
}
},
'roles': {
'class': 'django.forms.widgets.SelectMultiple', 'kwargs': {
'attrs': {'class': 'select2'},
@@ -97,7 +102,9 @@ class GrantAccessAction(WorkflowAction):
return form_data
def get_form_schema(self, *args, **kwargs):
self.fields['content_type']['kwargs']['queryset'] = ModelPermission.get_classes(as_content_type=True)
self.fields['content_type']['kwargs']['queryset'] = ModelPermission.get_classes(
as_content_type=True
).order_by('model')
self.fields['permissions']['kwargs']['choices'] = Permission.all(
as_choices=True
)