Allow line breaks in config descriptions - Fix #95

This commit is contained in:
Jannis Leidel 2015-09-24 12:21:29 +02:00
parent 7f5ca04f25
commit e41710616b
4 changed files with 28 additions and 2 deletions

View file

@ -63,7 +63,7 @@
{% for item in config %}
<tr class="{% cycle 'row1' 'row2' %}">
<th>{{ item.name }}
<div class="help">{{ item.help_text }}</div>
<div class="help">{{ item.help_text|linebreaksbr }}</div>
</th>
<td>
{{ item.default }}

View file

@ -63,6 +63,7 @@ CONSTANCE_CONFIG = {
'FLOAT_VALUE': (3.1415926536, 'PI'),
'DATE_VALUE': (date(2010, 12, 24), 'Merry Chrismas'),
'TIME_VALUE': (time(23, 59, 59), 'And happy New Year'),
'LINEBREAK_VALUE': ('Spam spam', 'eggs\neggs'),
}
DEBUG = True
@ -70,3 +71,19 @@ DEBUG = True
STATIC_ROOT = './static/'
STATIC_URL = '/static/'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

View file

@ -50,3 +50,11 @@ class TestAdmin(TestCase):
def test_str(self):
ct = ContentType.objects.get(app_label='constance', model='config')
self.assertEqual(six.text_type(ct), 'config')
def test_linebreaks(self):
self.client.login(username='admin', password='nimda')
request = self.rf.get('/admin/constance/config/')
request.user = self.superuser
response = self.options.changelist_view(request, {})
self.assertContains(response, 'LINEBREAK_VALUE')
self.assertContains(response, 'eggs<br />eggs')

View file

@ -19,7 +19,8 @@ deps =
django-master: https://github.com/django/django/archive/master.tar.gz
usedevelop = true
commands =
coverage run {envbindir}/django-admin.py test --settings=tests.settings -v2
coverage run {envbindir}/django-admin.py test -v2
coverage report
setenv =
PYTHONDONTWRITEBYTECODE=1
DJANGO_SETTINGS_MODULE=tests.settings