Use TemplateField for the web link template
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
smart link views.
|
||||
- TemplateField shows the available variable in the help text
|
||||
automatically.
|
||||
- Use TemplateField for the web link template.
|
||||
|
||||
3.3.4 (2019-12-09)
|
||||
==================
|
||||
|
||||
@@ -2,10 +2,21 @@ from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
|
||||
from mayan.apps.documents.models import Document
|
||||
from mayan.apps.templating.fields import TemplateField
|
||||
|
||||
from .models import WebLink
|
||||
|
||||
|
||||
class WebLinkForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(WebLinkForm, self).__init__(*args, **kwargs)
|
||||
self.fields['template'] = TemplateField(
|
||||
initial_help_text=self.fields['template'].help_text,
|
||||
label=self.fields['template'].label, model=Document,
|
||||
model_variable='document', required=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
fields = ('label', 'template', 'enabled')
|
||||
model = WebLink
|
||||
|
||||
@@ -26,7 +26,7 @@ class WebLink(models.Model):
|
||||
template = models.TextField(
|
||||
help_text=_(
|
||||
'Template that will be used to craft the final URL of the '
|
||||
'web link. The {{ document }} variable is available to the template.'
|
||||
'web link.'
|
||||
), verbose_name=_('Template')
|
||||
)
|
||||
enabled = models.BooleanField(default=True, verbose_name=_('Enabled'))
|
||||
|
||||
Reference in New Issue
Block a user