From ac5f403997426326eceed028fee52fdb21421f03 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 7 Jul 2015 23:20:48 -0400 Subject: [PATCH] Rename smart links title and dynamic_title fileds to label and dynamic_label. --- mayan/apps/linking/forms.py | 4 +-- .../migrations/0003_auto_20150708_0318.py | 24 +++++++++++++++++ .../migrations/0004_auto_20150708_0320.py | 26 +++++++++++++++++++ mayan/apps/linking/models.py | 16 ++++++------ mayan/apps/linking/views.py | 6 ++--- 5 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 mayan/apps/linking/migrations/0003_auto_20150708_0318.py create mode 100644 mayan/apps/linking/migrations/0004_auto_20150708_0320.py diff --git a/mayan/apps/linking/forms.py b/mayan/apps/linking/forms.py index 1d8ed1e6c7..6f719edc43 100644 --- a/mayan/apps/linking/forms.py +++ b/mayan/apps/linking/forms.py @@ -12,10 +12,10 @@ from .models import SmartLink, SmartLinkCondition class SmartLinkForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(SmartLinkForm, self).__init__(*args, **kwargs) - self.fields['dynamic_title'].help_text = ' '.join([unicode(self.fields['dynamic_title'].help_text), ModelAttribute.help_text_for(Document, type_names=['field', 'related', 'property'])]) + self.fields['dynamic_label'].help_text = ' '.join([unicode(self.fields['dynamic_label'].help_text), ModelAttribute.help_text_for(Document, type_names=['field', 'related', 'property'])]) class Meta: - fields = ('title', 'dynamic_title', 'enabled') + fields = ('label', 'dynamic_label', 'enabled') model = SmartLink diff --git a/mayan/apps/linking/migrations/0003_auto_20150708_0318.py b/mayan/apps/linking/migrations/0003_auto_20150708_0318.py new file mode 100644 index 0000000000..49e34f6b84 --- /dev/null +++ b/mayan/apps/linking/migrations/0003_auto_20150708_0318.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('linking', '0002_resolvedsmartlink'), + ] + + operations = [ + migrations.RenameField( + model_name='smartlink', + old_name='dynamic_title', + new_name='dynamic_label', + ), + migrations.RenameField( + model_name='smartlink', + old_name='title', + new_name='label', + ), + ] diff --git a/mayan/apps/linking/migrations/0004_auto_20150708_0320.py b/mayan/apps/linking/migrations/0004_auto_20150708_0320.py new file mode 100644 index 0000000000..31aaaa971e --- /dev/null +++ b/mayan/apps/linking/migrations/0004_auto_20150708_0320.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('linking', '0003_auto_20150708_0318'), + ] + + operations = [ + migrations.AlterField( + model_name='smartlink', + name='dynamic_label', + field=models.CharField(help_text='This expression will be evaluated against the current selected document.', max_length=96, verbose_name='Dynamic label', blank=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='smartlink', + name='label', + field=models.CharField(max_length=96, verbose_name='Label'), + preserve_default=True, + ), + ] diff --git a/mayan/apps/linking/models.py b/mayan/apps/linking/models.py index edcbb8db0b..f5313caa50 100644 --- a/mayan/apps/linking/models.py +++ b/mayan/apps/linking/models.py @@ -14,22 +14,22 @@ from .literals import ( @python_2_unicode_compatible class SmartLink(models.Model): - title = models.CharField(max_length=96, verbose_name=_('Title')) - dynamic_title = models.CharField(blank=True, max_length=96, verbose_name=_('Dynamic title'), help_text=_('This expression will be evaluated against the current selected document.')) + label = models.CharField(max_length=96, verbose_name=_('Label')) + dynamic_label = models.CharField(blank=True, max_length=96, verbose_name=_('Dynamic label'), help_text=_('This expression will be evaluated against the current selected document.')) enabled = models.BooleanField(default=True, verbose_name=_('Enabled')) document_types = models.ManyToManyField(DocumentType, verbose_name=_('Document types')) def __str__(self): - return self.title + return self.label - def get_dynamic_title(self, document): - if self.dynamic_title: + def get_dynamic_label(self, document): + if self.dynamic_label: try: - return eval(self.dynamic_title, {'document': document}) + return eval(self.dynamic_label, {'document': document}) except Exception as exception: - return Exception(_('Error generating dynamic title; %s' % unicode(exception))) + return Exception(_('Error generating dynamic label; %s' % unicode(exception))) else: - return self.title + return self.label def resolve_for(self, document): return ResolvedSmartLink(smart_link=self, queryset=self.get_linked_document_for(document)) diff --git a/mayan/apps/linking/views.py b/mayan/apps/linking/views.py index ba35753d57..b39559f19c 100644 --- a/mayan/apps/linking/views.py +++ b/mayan/apps/linking/views.py @@ -95,7 +95,7 @@ class ResolvedSmartLinkView(DocumentListView): 'object': self.document, 'title': _('Documents in smart link "%(smart_link)s" as relation to "%(document)s"') % { 'document': self.document, - 'smart_link': self.smart_link.get_dynamic_title(self.document), + 'smart_link': self.smart_link.get_dynamic_label(self.document), } } @@ -113,7 +113,7 @@ class SmartLinkListView(SingleObjectListView): def get_extra_context(self): return { 'extra_columns': [ - {'name': _('Dynamic title'), 'attribute': 'dynamic_title'}, + {'name': _('Dynamic label'), 'attribute': 'dynamic_label'}, {'name': _('Enabled'), 'attribute': encapsulate(lambda instance: two_state_template(instance.enabled))}, ], 'hide_link': True, @@ -139,7 +139,7 @@ class DocumentSmartLinkListView(SmartLinkListView): return { 'document': self.document, 'extra_columns': ( - {'name': _('Title'), 'attribute': encapsulate(lambda smart_link: smart_link.get_dynamic_title(self.document))}, + {'name': _('Label'), 'attribute': encapsulate(lambda smart_link: smart_link.get_dynamic_label(self.document))}, ), 'hide_object': True, 'hide_link': True,