From a172538dfc630fde8836cb885b310be45bb9676a Mon Sep 17 00:00:00 2001 From: Michael Price Date: Tue, 13 Mar 2018 15:27:19 -0400 Subject: [PATCH] Sort smartlinks by label. Signed-off-by: Michael Price --- HISTORY.rst | 2 +- .../migrations/0002_auto_20180313_1926.py | 24 +++++++++++++++++++ mayan/apps/linking/models.py | 5 +++- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 mayan/apps/linking/migrations/0002_auto_20180313_1926.py diff --git a/HISTORY.rst b/HISTORY.rst index fef2465aa7..a6a56abea5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -44,7 +44,7 @@ Next (2018-XX-XX) - Split documents.tests.test_views into base.py, test_deleted_document_views.py, test_document_page_views.py, test_document_type_views.py, test_document_version_views.py, test_document_views.py, test_duplicated_document_views.py - +- Sort smart links by label. 2.8 (2018-02-27) ================ diff --git a/mayan/apps/linking/migrations/0002_auto_20180313_1926.py b/mayan/apps/linking/migrations/0002_auto_20180313_1926.py new file mode 100644 index 0000000000..04d9641dc5 --- /dev/null +++ b/mayan/apps/linking/migrations/0002_auto_20180313_1926.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-03-13 19:26 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('linking', '0001_initial_squashed_0005_auto_20150729_2344'), + ] + + operations = [ + migrations.AlterModelOptions( + name='smartlink', + options={'ordering': ('label',), 'verbose_name': 'Smart link', 'verbose_name_plural': 'Smart links'}, + ), + migrations.AlterField( + model_name='smartlink', + name='label', + field=models.CharField(db_index=True, max_length=96, verbose_name='Label'), + ), + ] diff --git a/mayan/apps/linking/models.py b/mayan/apps/linking/models.py index 68498d873b..22aa81b2f8 100644 --- a/mayan/apps/linking/models.py +++ b/mayan/apps/linking/models.py @@ -16,7 +16,9 @@ from .managers import SmartLinkManager @python_2_unicode_compatible class SmartLink(models.Model): - label = models.CharField(max_length=96, verbose_name=_('Label')) + label = models.CharField( + db_index=True, max_length=96, verbose_name=_('Label') + ) dynamic_label = models.CharField( blank=True, max_length=96, help_text=_( 'Enter a template to render. ' @@ -90,6 +92,7 @@ class SmartLink(models.Model): ) class Meta: + ordering = ('label',) verbose_name = _('Smart link') verbose_name_plural = _('Smart links')