Files
mayan-edms/mayan/apps/linking/forms.py
Roberto Rosario 5798cabd7c Add support to update the document indexes from workflow state changes.
Add a new workflow field called internal_name for easier workflow
reference in document index templates.
Generalize the PropertyHelper class.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2017-06-06 20:07:15 -04:00

49 lines
1.6 KiB
Python

from __future__ import unicode_literals
from django import forms
from django.utils.translation import ugettext_lazy as _
from common.classes import ModelAttribute
from documents.models import Document
from .models import SmartLink, SmartLinkCondition
class SmartLinkForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(SmartLinkForm, self).__init__(*args, **kwargs)
self.fields['dynamic_label'].help_text = ' '.join(
[
unicode(self.fields['dynamic_label'].help_text),
ModelAttribute.help_text_for(
Document, type_names=['field', 'related', 'property']
).replace('\n', '<br>')
]
)
class Meta:
fields = ('label', 'dynamic_label', 'enabled')
model = SmartLink
class SmartLinkConditionForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(SmartLinkConditionForm, self).__init__(*args, **kwargs)
self.fields['foreign_document_data'] = forms.ChoiceField(
choices=ModelAttribute.get_choices_for(
Document, type_names=['field', 'query']
), label=_('Foreign document attribute')
)
self.fields['expression'].help_text = ' '.join(
[
unicode(self.fields['expression'].help_text),
ModelAttribute.help_text_for(
Document, type_names=['field', 'related', 'property']
).replace('\n', '<br>')
]
)
class Meta:
model = SmartLinkCondition
exclude = ('smart_link',)