Add support for truncating view titles via the APPEARANCE_MAXIMUM_TITLE_LENGTH

setting. The default value is 80 characters.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-06-20 04:24:27 -04:00
parent b79a64c5ed
commit e6fbd0b84f
5 changed files with 21 additions and 2 deletions

View File

@@ -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)
================

View File

@@ -0,0 +1 @@
DEFAULT_MAXIMUM_TITLE_LENGTH = 80

View File

@@ -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
)

View File

@@ -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 %}

View File

@@ -8,7 +8,7 @@
{% block content %}
{% if title %}
<h3>{{ title }}</h3>
<h3>{% include 'appearance/calculate_form_title.html' %}</h3>
<hr>
{% endif %}