Skip to content

Commit

Permalink
Add dbtemplates configuration to example project
Browse files Browse the repository at this point in the history
  • Loading branch information
goinnn committed Oct 6, 2013
1 parent 0c4b611 commit b3f55ea
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions example/example/app/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.

from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test import TestCase
Expand All @@ -38,6 +39,9 @@ def check_url(self, client, url):
response = client.get(url)
str_extension = 'Overwriting the change_form template in our project without to have to copy every line of this template in our project'
self.assertEqual(str_extension in response.content.decode('utf-8'), True)
if 'example.dbtemplates_fixtures' in settings.INSTALLED_APPS:
str_extension_db_templates = 'Overwriting the change_form template using '
self.assertEqual(str_extension_db_templates in response.content.decode('utf-8'), True)

def test_smart_extends_add_form(self):
client = self.__client_login()
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions example/example/dbtemplates_fixtures/fixtures/initial_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[{
"pk": 1,
"model": "dbtemplates.template",
"fields": {
"content": "{% smart_extends \"admin/change_form.html\" %}\r\n\r\n{% block content_title %}\r\n {{ block.super }}\r\n <p style=\"color:blue\">\r\n Overwriting the change_form template using <a href=\"https://pypi.python.org/pypi/django-dbtemplates\" target=\"_blank\">dbtemplate</a> without to have to copy every line of this template in our database (without repeating code).\r\n <a href=\"/admin/dbtemplates/template/1/\" target=\"_blank\">See the code</a>\r\n </p>\r\n{% endblock %}",
"sites": [
1
],
"last_changed": "2013-10-06 05:21:27.568",
"name": "admin/change_form.html",
"creation_date": "2013-10-06T04:56:37"
}
}
]
Empty file.
14 changes: 13 additions & 1 deletion example/example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@
'django.contrib.sites',
'django.contrib.admin',
'example.app',
'smartextends'
'smartextends',
)


TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
Expand Down Expand Up @@ -152,8 +153,19 @@
}
}

# dbtemplates configuration. This is to test the smartextends with three TEMPLATE_LOADERS installed

try:
import dbtemplates
INSTALLED_APPS += ('dbtemplates',
'example.dbtemplates_fixtures')
TEMPLATE_LOADERS = ('dbtemplates.loader.Loader',) + TEMPLATE_LOADERS
except ImportError:
pass

# Custom settings to the different django versions


import django

if django.VERSION[0] >= 1 and django.VERSION[1] >= 4:
Expand Down

0 comments on commit b3f55ea

Please sign in to comment.