Move template sandbox to its own app

Improve UI for the sandbox template textarea.

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-11-11 02:59:26 -04:00
parent 81b1564535
commit 466f15e154
46 changed files with 1784 additions and 81 deletions

View File

@@ -0,0 +1,37 @@
from __future__ import absolute_import, unicode_literals
from collections import OrderedDict
from django import forms
from mayan.apps.common.classes import ModelProperty
from mayan.apps.common.widgets import NamedMultiWidget
class TemplateWidget(NamedMultiWidget):
def __init__(self, attrs=None, **kwargs):
widgets = OrderedDict()
widgets['model_property'] = forms.widgets.Select()
widgets['template'] = forms.widgets.Textarea(
attrs={'rows': 5}
)
super(TemplateWidget, self).__init__(
widgets=widgets, attrs=attrs, **kwargs
)
def decompress(self, value):
choices = ModelProperty.get_choices_for(
model=self.attrs['model']
)
self.widgets['model_property'].choices = (
[('', '----')] + choices
)
return {
'model_property': None, 'template': value
}
def value_from_datadict(self, querydict, files, name):
template = querydict.get('{}_template'.format(name))
return template