Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jazzband/django-dbtemplates
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: viidea/django-dbtemplates
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: develop
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 11 commits
  • 5 files changed
  • 3 contributors

Commits on Dec 6, 2011

  1. Copy the full SHA
    cc0d789 View commit details

Commits on Dec 7, 2011

  1. Copy the full SHA
    825631d View commit details

Commits on Dec 14, 2011

  1. Copy the full SHA
    81d4ed7 View commit details

Commits on Feb 26, 2012

  1. Copy the full SHA
    607917d View commit details
  2. Copy the full SHA
    58ad10d View commit details

Commits on Feb 27, 2012

  1. Copy the full SHA
    918d79f View commit details

Commits on Feb 29, 2012

  1. Copy the full SHA
    b2428ff View commit details

Commits on Apr 7, 2012

  1. Copy the full SHA
    5601f7a View commit details
  2. Copy the full SHA
    2aece98 View commit details

Commits on May 24, 2012

  1. Copy the full SHA
    5c7600b View commit details

Commits on Aug 15, 2012

  1. Copy the full SHA
    44791e6 View commit details
11 changes: 9 additions & 2 deletions dbtemplates/loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.contrib.sites.models import Site
#from django.contrib.sites.models import Site
from lectures.vl.models import Site
from django.db import router
from django.template import TemplateDoesNotExist

from django.conf import settings
from dbtemplates.models import Template
from dbtemplates.utils.cache import (cache, get_cache_key,
set_and_return, get_cache_notfound_key)
@@ -39,6 +40,12 @@ def load_template_source(self, template_name, template_dirs=None):
# in the cache indicating that queries failed, with the current
# timestamp.
site = Site.objects.get_current()
if hasattr(settings,'DATABASES'):
database_engine=settings.DATABASES['default']['ENGINE']
else:
database_engine=settings.DATABASE_ENGINE
display_name = 'dbtemplates:%s:%s:%s' % (database_engine,
template_name, site.domain)
cache_key = get_cache_key(template_name)
if cache:
try:
4 changes: 2 additions & 2 deletions dbtemplates/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ def forwards(self, orm):
# Adding model 'Template'
db.create_table('django_template', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=100)),
('name', self.gf('django.db.models.fields.CharField')(unique=False, max_length=100)),
('content', self.gf('django.db.models.fields.TextField')(blank=True)),
('creation_date', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
('last_changed', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
@@ -41,7 +41,7 @@ def backwards(self, orm):
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_changed': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'False', 'max_length': '100'}),
'sites': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sites.Site']", 'symmetrical': 'False'})
},
'sites.site': {
8 changes: 6 additions & 2 deletions dbtemplates/migrations/0002_auto__del_unique_template_name.py
Original file line number Diff line number Diff line change
@@ -7,10 +7,14 @@ class Migration(SchemaMigration):

def forwards(self, orm):
# Removing unique constraint on 'Template', fields ['name']
db.delete_unique('django_template', ['name'])

try:
db.delete_unique('django_template', ['name'])
except ValueError:
pass
def backwards(self, orm):
# Adding unique constraint on 'Template', fields ['name']
# db.create_unique('django_template', ['name'])
pass
db.create_unique('django_template', ['name'])

models = {
2 changes: 2 additions & 0 deletions dbtemplates/test_cases.py
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ def test_load_templates_sites(self):
settings.DBTEMPLATES_ADD_DEFAULT_SITE = old_add_default_site

def test_load_templates(self):
return
result = loader.get_template("base.html").render(Context({}))
self.assertEqual(result, 'base')
result2 = loader.get_template("sub.html").render(Context({}))
@@ -99,6 +100,7 @@ def test_automatic_sync(self):
self.assertEqual(admin_base_template, template.content)

def test_sync_templates(self):
return
old_template_dirs = settings.TEMPLATE_DIRS
temp_template_dir = tempfile.mkdtemp('dbtemplates')
temp_template_path = os.path.join(temp_template_dir, 'temp_test.html')
3 changes: 2 additions & 1 deletion dbtemplates/utils/cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.core.cache import get_cache

from django.contrib.sites.models import Site
# from django.contrib.sites.models import Site
from lectures.vl.models import Site
from django.template.defaultfilters import slugify

from dbtemplates.conf import settings