This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
# Additional settings for django-dav
|
||||
#
|
||||
|
||||
BASE_VAR_DIR = os.path.join(BASE_DIR, 'var')
|
||||
BASE_SHARE_DIR = os.path.join(BASE_DIR, 'common')
|
||||
BASE_VAR_DIR = BASE_DIR / 'var'
|
||||
BASE_SHARE_DIR = BASE_DIR / 'common'
|
||||
|
||||
# Get modules config
|
||||
from dav_base.config.modules import ModuleConfig
|
||||
@@ -14,7 +14,7 @@ INSTALLED_APPS += [
|
||||
'bootstrap3',
|
||||
'datetimewidget',
|
||||
'django_countries',
|
||||
'django_extensions',
|
||||
# 'django_extensions',
|
||||
# Our main app
|
||||
'dav_base',
|
||||
]
|
||||
@@ -45,11 +45,11 @@ TEMPLATES += [
|
||||
|
||||
# Add our local templates directory to the template engine configurations.
|
||||
for config in TEMPLATES:
|
||||
config['DIRS'].append(os.path.join(BASE_SHARE_DIR, 'templates'))
|
||||
config['DIRS'].append(BASE_SHARE_DIR / 'templates')
|
||||
|
||||
DATABASES['default'] = {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_VAR_DIR, 'db', 'devel.sqlite3'),
|
||||
'NAME': BASE_VAR_DIR / 'db' / 'devel.sqlite3',
|
||||
}
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
@@ -76,7 +76,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
},
|
||||
]
|
||||
|
||||
STATIC_ROOT = os.path.join(BASE_VAR_DIR, 'www', 'static')
|
||||
STATIC_ROOT = BASE_VAR_DIR / 'www' / 'static'
|
||||
|
||||
LANGUAGE_CODE = 'de'
|
||||
TIME_ZONE = 'Europe/Berlin'
|
||||
@@ -130,20 +130,20 @@ LOGGING = {
|
||||
'default_log': {
|
||||
'level': 'INFO',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_VAR_DIR, 'log', 'default.log'),
|
||||
'filename': BASE_VAR_DIR / 'log' / 'default.log',
|
||||
'formatter': 'default',
|
||||
},
|
||||
'error_log': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_VAR_DIR, 'log', 'error.log'),
|
||||
'filename': BASE_VAR_DIR / 'log' / 'error.log',
|
||||
'formatter': 'default',
|
||||
},
|
||||
'debug_log': {
|
||||
'level': 'DEBUG',
|
||||
'filters': ['require_debug_true'],
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_VAR_DIR, 'log', 'debug.log'),
|
||||
'filename': BASE_VAR_DIR / 'log' / 'debug.log',
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# This template is used by software tests #}{% load dav_base %}
|
||||
--{% include_if_exist './includes/include_missing.html' %}--
|
||||
--{% include_if_exist './includes/include_missing.html' default 'dav_base/tests/includes/include_default.html' %}--
|
||||
--{% include_if_exist './includes/include_missing3.html' %}--
|
||||
--{% include_if_exist './includes/include_missing4.html' default 'dav_base/tests/includes/include_default.html' %}--
|
||||
--{% include_if_exist './includes/include_optional.html' %}--
|
||||
--{% include_if_exist './includes/include_optional.html' default 'dav_base/tests/includes/include_default.html' %}--
|
||||
--{% include_if_exist './includes/include_with_missing_include.html' %}--
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{# This template is used by software tests #}{% load dav_base %}
|
||||
--{% include_if_exist './includes/include_missing.html' default './includes/include_missing.html' %}--
|
||||
--{% include_if_exist './includes/include_missing1.html' default './includes/include_missing2.html' %}--
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{# This template is used by software tests #}{% load dav_base %}
|
||||
--{% include './include_missing.html' %}--
|
||||
--{% include './include_missing5.html' %}--
|
||||
|
||||
@@ -16,7 +16,7 @@ def do_include_if_exist(parser, token):
|
||||
"""
|
||||
bits = token.split_contents()
|
||||
if len(bits) < 2:
|
||||
raise template.TemplateSyntaxError("%r tag takes at least two arguments:"
|
||||
raise template.TemplateSyntaxError("%r tag takes at least one argument:"
|
||||
" the name of the template to be included" % bits[0])
|
||||
|
||||
try:
|
||||
@@ -27,6 +27,10 @@ def do_include_if_exist(parser, token):
|
||||
token = template.base.Token(token.token_type, ' '.join(bits))
|
||||
token2 = template.base.Token(token.token_type, bits[0] + ' ' + default_template + ' '.join(bits[2:]))
|
||||
default_node = template.loader_tags.do_include(parser, token2)
|
||||
# TODO: I belive, this ist not the correct way to do things.
|
||||
# But without setting default_node.origin here the following AttributeError will be risen within the tests:
|
||||
# AttributeError: 'IncludeNode' object has no attribute 'origin'
|
||||
default_node.origin = template.Origin(name='<unknown_source>', template_name=None)
|
||||
except ValueError:
|
||||
default_node = template.defaulttags.CommentNode()
|
||||
except IndexError:
|
||||
|
||||
@@ -28,20 +28,20 @@ class TemplateTagsTestCase(SimpleTestCase):
|
||||
|
||||
def test_include_if_exist(self):
|
||||
template_name = 'dav_base/tests/include_if_exist.html'
|
||||
template = get_template(template_name)
|
||||
|
||||
content = template.render()
|
||||
expected_content = """
|
||||
with self.settings(DEBUG=False):
|
||||
template = get_template(template_name)
|
||||
|
||||
content = template.render()
|
||||
expected_content = """
|
||||
----
|
||||
--DEFAULT INCLUDED HTML--
|
||||
--OPTIONAL INCLUDED HTML--
|
||||
--OPTIONAL INCLUDED HTML--
|
||||
--
|
||||
----
|
||||
--
|
||||
"""
|
||||
|
||||
self.assertEqual(content, expected_content)
|
||||
self.assertEqual(content, expected_content)
|
||||
|
||||
def test_include_if_exist_while_debug(self):
|
||||
template_name = 'dav_base/tests/include_if_exist.html'
|
||||
|
||||
Reference in New Issue
Block a user