Use TemplateField for the web link template

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-12-10 22:31:46 -04:00
parent 913e57a010
commit 0b4c8242ee
3 changed files with 13 additions and 1 deletions

View File

@@ -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)
==================

View File

@@ -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

View File

@@ -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'))