Instead of inserting the path of the apps into the Python app, the apps are now referenced by their full import path. This solves name clashes with external or native Python libraries. Example: Mayan statistics app vs. Python new statistics library. Every app reference is now prepended with 'mayan.apps'. Existing config.yml files need to be updated manually. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from django import forms
|
|
from django.utils.encoding import force_text
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from mayan.apps.common.classes import ModelField, ModelProperty
|
|
from mayan.apps.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(
|
|
[
|
|
force_text(self.fields['dynamic_label'].help_text),
|
|
ModelProperty.get_help_text_for(
|
|
model=Document, show_name=True
|
|
).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=ModelField.get_choices_for(
|
|
model=Document,
|
|
), label=_('Foreign document field')
|
|
)
|
|
self.fields['expression'].help_text = ' '.join(
|
|
[
|
|
force_text(self.fields['expression'].help_text),
|
|
ModelProperty.get_help_text_for(
|
|
model=Document, show_name=True
|
|
).replace('\n', '<br>')
|
|
]
|
|
)
|
|
|
|
class Meta:
|
|
model = SmartLinkCondition
|
|
exclude = ('smart_link',)
|