Add support for form media to DynamicFormMixin
Fix tag attach and remove action form media. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -288,6 +288,8 @@
|
|||||||
* Disable hiding page navigation on idle.
|
* Disable hiding page navigation on idle.
|
||||||
* Display namespace in the transition trigger view.
|
* Display namespace in the transition trigger view.
|
||||||
* Sort events list in the transition trigger view.
|
* Sort events list in the transition trigger view.
|
||||||
|
* Add support for form media to DynamicFormMixin.
|
||||||
|
* Fix tag attach and remove action form media.
|
||||||
|
|
||||||
3.1.11 (2019-04-XX)
|
3.1.11 (2019-04-XX)
|
||||||
===================
|
===================
|
||||||
|
|||||||
@@ -717,6 +717,8 @@ Other changes
|
|||||||
- Disable hiding page navigation on idle.
|
- Disable hiding page navigation on idle.
|
||||||
- Display namespace in the transition trigger view.
|
- Display namespace in the transition trigger view.
|
||||||
- Sort events list in the transition trigger view.
|
- Sort events list in the transition trigger view.
|
||||||
|
- Add support for form media to DynamicFormMixin.
|
||||||
|
- Fix tag attach and remove action form media.
|
||||||
|
|
||||||
|
|
||||||
Removals
|
Removals
|
||||||
|
|||||||
@@ -173,6 +173,11 @@ class DynamicFormMixin(object):
|
|||||||
self.fields[field_name] = field_class(**kwargs)
|
self.fields[field_name] = field_class(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def media(self):
|
||||||
|
return forms.Media(**self.schema.get('media', {}))
|
||||||
|
|
||||||
|
|
||||||
class DynamicForm(DynamicFormMixin, forms.Form):
|
class DynamicForm(DynamicFormMixin, forms.Form):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ class WorkflowAction(six.with_metaclass(WorkflowActionMetaclass, WorkflowActionB
|
|||||||
def get_form_schema(self, request=None):
|
def get_form_schema(self, request=None):
|
||||||
result = {
|
result = {
|
||||||
'fields': self.fields or (),
|
'fields': self.fields or (),
|
||||||
'widgets': getattr(self, 'widgets', {})
|
'media': getattr(self, 'media', {}),
|
||||||
|
'widgets': getattr(self, 'widgets', {}),
|
||||||
}
|
}
|
||||||
|
|
||||||
if hasattr(self, 'field_order'):
|
if hasattr(self, 'field_order'):
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ class AttachTagAction(WorkflowAction):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
label = _('Attach tag')
|
label = _('Attach tag')
|
||||||
|
media = {
|
||||||
|
'js': ('tags/js/tags_form.js',)
|
||||||
|
}
|
||||||
widgets = {
|
widgets = {
|
||||||
'tags': {
|
'tags': {
|
||||||
'class': 'mayan.apps.tags.widgets.TagFormWidget', 'kwargs': {
|
'class': 'mayan.apps.tags.widgets.TagFormWidget', 'kwargs': {
|
||||||
@@ -33,6 +36,10 @@ class AttachTagAction(WorkflowAction):
|
|||||||
}
|
}
|
||||||
permission = permission_tag_attach
|
permission = permission_tag_attach
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
for tag in self.get_tags():
|
||||||
|
tag.attach_to(document=context['document'])
|
||||||
|
|
||||||
def get_form_schema(self, request):
|
def get_form_schema(self, request):
|
||||||
user = request.user
|
user = request.user
|
||||||
logger.debug('user: %s', user)
|
logger.debug('user: %s', user)
|
||||||
@@ -46,16 +53,13 @@ class AttachTagAction(WorkflowAction):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'fields': self.fields,
|
'fields': self.fields,
|
||||||
|
'media': self.media,
|
||||||
'widgets': self.widgets
|
'widgets': self.widgets
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_tags(self):
|
def get_tags(self):
|
||||||
return Tag.objects.filter(pk__in=self.form_data.get('tags', ()))
|
return Tag.objects.filter(pk__in=self.form_data.get('tags', ()))
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
for tag in self.get_tags():
|
|
||||||
tag.attach_to(document=context['document'])
|
|
||||||
|
|
||||||
|
|
||||||
class RemoveTagAction(AttachTagAction):
|
class RemoveTagAction(AttachTagAction):
|
||||||
fields = {
|
fields = {
|
||||||
|
|||||||
Reference in New Issue
Block a user