From e6fbd0b84f3836f66675107740f2957c524d3f36 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 20 Jun 2017 04:24:27 -0400 Subject: [PATCH] Add support for truncating view titles via the APPEARANCE_MAXIMUM_TITLE_LENGTH setting. The default value is 80 characters. Signed-off-by: Roberto Rosario --- HISTORY.rst | 1 + mayan/apps/appearance/literals.py | 1 + mayan/apps/appearance/settings.py | 13 +++++++++++++ .../templates/appearance/calculate_form_title.html | 6 +++++- .../templates/appearance/generic_list.html | 2 +- 5 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 mayan/apps/appearance/literals.py create mode 100644 mayan/apps/appearance/settings.py diff --git a/HISTORY.rst b/HISTORY.rst index a97e71cd97..dc59ab317d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,6 +10,7 @@ XX (2017-XX-XX) - Add support for updating configuration options from environment variables. - Add purgelocks management command. GitLab issue #221. - Fix index rebuilding for multi value first levels. GitLab issue #391. +- Truncate views titles via the APPEARANCE_MAXIMUM_TITLE_LENGTH setting. GitLab issue #217. 2.3 (2017-06-08) ================ diff --git a/mayan/apps/appearance/literals.py b/mayan/apps/appearance/literals.py new file mode 100644 index 0000000000..6266e3e975 --- /dev/null +++ b/mayan/apps/appearance/literals.py @@ -0,0 +1 @@ +DEFAULT_MAXIMUM_TITLE_LENGTH = 80 diff --git a/mayan/apps/appearance/settings.py b/mayan/apps/appearance/settings.py new file mode 100644 index 0000000000..94c73d2a57 --- /dev/null +++ b/mayan/apps/appearance/settings.py @@ -0,0 +1,13 @@ +from __future__ import unicode_literals + +from django.utils.translation import ugettext_lazy as _ + +from smart_settings import Namespace + +from .literals import DEFAULT_MAXIMUM_TITLE_LENGTH + +namespace = Namespace(name='appearance', label=_('Appearance')) +setting_max_title_length = namespace.add_setting( + global_name='APPEARANCE_MAXIMUM_TITLE_LENGTH', + default=DEFAULT_MAXIMUM_TITLE_LENGTH +) diff --git a/mayan/apps/appearance/templates/appearance/calculate_form_title.html b/mayan/apps/appearance/templates/appearance/calculate_form_title.html index da6f1c075a..ac3bf0dded 100644 --- a/mayan/apps/appearance/templates/appearance/calculate_form_title.html +++ b/mayan/apps/appearance/templates/appearance/calculate_form_title.html @@ -1,7 +1,11 @@ {% load i18n %} +{% load smart_settings_tags %} + +{% smart_setting 'APPEARANCE_MAXIMUM_TITLE_LENGTH' as maximum_title_length %} + {% if title %} - {{ title }} + {{ title|truncatechars:maximum_title_length }} {% else %} {% if read_only %} {% blocktrans %}Details for: {{ object }}{% endblocktrans %} diff --git a/mayan/apps/appearance/templates/appearance/generic_list.html b/mayan/apps/appearance/templates/appearance/generic_list.html index f728ac1b80..521e455e26 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list.html +++ b/mayan/apps/appearance/templates/appearance/generic_list.html @@ -8,7 +8,7 @@ {% block content %} {% if title %} -

{{ title }}

+

{% include 'appearance/calculate_form_title.html' %}


{% endif %}