From e694b3dfb8df3a3ba33a97b90b60d96d615081aa Mon Sep 17 00:00:00 2001 From: Jason Mayfield Date: Mon, 13 Dec 2010 19:32:27 -0500 Subject: [PATCH 001/103] remove name uniqueness, with migration Signed-off-by: Jannis Leidel --- dbtemplates/loader.py | 2 +- dbtemplates/migrations/0001_initial.py | 57 +++++++++++++++++++ .../0002_auto__del_unique_template_name.py | 39 +++++++++++++ dbtemplates/migrations/__init__.py | 0 dbtemplates/models.py | 2 +- example/requirements.txt | 2 +- example/settings.py | 1 + 7 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 dbtemplates/migrations/0001_initial.py create mode 100644 dbtemplates/migrations/0002_auto__del_unique_template_name.py create mode 100644 dbtemplates/migrations/__init__.py diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index 8912ba4..ca2d817 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -34,7 +34,7 @@ def load_template_source(template_name, template_dirs=None, annoy=True): except: pass try: - template = Template.on_site.get(name__exact=template_name) + template = Template.on_site.filter(name__exact=template_name)[0] # Save in cache backend explicitly if manually deleted or invalidated if cache: cache.set(cache_key, template.content) diff --git a/dbtemplates/migrations/0001_initial.py b/dbtemplates/migrations/0001_initial.py new file mode 100644 index 0000000..a5192af --- /dev/null +++ b/dbtemplates/migrations/0001_initial.py @@ -0,0 +1,57 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + 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)), + ('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)), + )) + db.send_create_signal('dbtemplates', ['Template']) + + # Adding M2M table for field sites on 'Template' + db.create_table('django_template_sites', ( + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), + ('template', models.ForeignKey(orm['dbtemplates.template'], null=False)), + ('site', models.ForeignKey(orm['sites.site'], null=False)) + )) + db.create_unique('django_template_sites', ['template_id', 'site_id']) + + + def backwards(self, orm): + + # Deleting model 'Template' + db.delete_table('django_template') + + # Removing M2M table for field sites on 'Template' + db.delete_table('django_template_sites') + + + models = { + 'dbtemplates.template': { + 'Meta': {'ordering': "('name',)", 'object_name': 'Template', 'db_table': "'django_template'"}, + 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + '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'}), + 'sites': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sites.Site']", 'symmetrical': 'False'}) + }, + 'sites.site': { + 'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"}, + 'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + } + } + + complete_apps = ['dbtemplates'] diff --git a/dbtemplates/migrations/0002_auto__del_unique_template_name.py b/dbtemplates/migrations/0002_auto__del_unique_template_name.py new file mode 100644 index 0000000..17a8a6e --- /dev/null +++ b/dbtemplates/migrations/0002_auto__del_unique_template_name.py @@ -0,0 +1,39 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Removing unique constraint on 'Template', fields ['name'] + db.delete_unique('django_template', ['name']) + + + def backwards(self, orm): + + # Adding unique constraint on 'Template', fields ['name'] + db.create_unique('django_template', ['name']) + + + models = { + 'dbtemplates.template': { + 'Meta': {'ordering': "('name',)", 'object_name': 'Template', 'db_table': "'django_template'"}, + 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + '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', [], {'max_length': '100'}), + 'sites': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sites.Site']", 'symmetrical': 'False'}) + }, + 'sites.site': { + 'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"}, + 'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + } + } + + complete_apps = ['dbtemplates'] diff --git a/dbtemplates/migrations/__init__.py b/dbtemplates/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dbtemplates/models.py b/dbtemplates/models.py index cf7035c..6ae4995 100644 --- a/dbtemplates/models.py +++ b/dbtemplates/models.py @@ -19,7 +19,7 @@ class Template(models.Model): Defines a template model for use with the database template loader. The field ``name`` is the equivalent to the filename of a static template. """ - name = models.CharField(_('name'), unique=True, max_length=100, + name = models.CharField(_('name'), max_length=100, help_text=_("Example: 'flatpages/default.html'")) content = models.TextField(_('content'), blank=True) sites = models.ManyToManyField(Site, verbose_name=_('sites')) diff --git a/example/requirements.txt b/example/requirements.txt index b9eea7a..474ccbb 100644 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -1 +1 @@ -django-staticfiles \ No newline at end of file +django-staticfiles south \ No newline at end of file diff --git a/example/settings.py b/example/settings.py index c18b770..59842f7 100644 --- a/example/settings.py +++ b/example/settings.py @@ -99,6 +99,7 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.flatpages', 'dbtemplates', + 'south', 'staticfiles', #'reversion', ) From 587b66232ca76bc4ef29684bd84b88c0b7729345 Mon Sep 17 00:00:00 2001 From: Jason Mayfield Date: Mon, 13 Dec 2010 19:35:57 -0500 Subject: [PATCH 002/103] typo --- dbtemplates/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbtemplates/settings.py b/dbtemplates/settings.py index 7fc5141..c1bef09 100644 --- a/dbtemplates/settings.py +++ b/dbtemplates/settings.py @@ -26,7 +26,7 @@ MEDIA_PREFIX = getattr(settings, 'DBTEMPLATES_MEDIA_PREFIX', USE_REVERSION = getattr(settings, 'DBTEMPLATES_USE_REVERSION', False) -if USE_REVERSION and 'reversion'not in settings.INSTALLED_APPS: +if USE_REVERSION and 'reversion' not in settings.INSTALLED_APPS: raise ImproperlyConfigured("Please add reversion to your " "INSTALLED_APPS setting to make use of it in dbtemplates.") From dd15deab60eab5177fe2b40f580d501666f2950f Mon Sep 17 00:00:00 2001 From: Jason Mayfield Date: Mon, 13 Dec 2010 19:46:33 -0500 Subject: [PATCH 003/103] filter horizontal the sites Signed-off-by: Jannis Leidel --- dbtemplates/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 0979971..2d50d5a 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -86,6 +86,7 @@ class TemplateAdmin(TemplateModelAdmin): 'classes': ('collapse',), }), ) + filter_horizontal = ('sites',) list_display = ('name', 'creation_date', 'last_changed', 'site_list') list_filter = ('sites',) search_fields = ('name', 'content') From 1415896b3d44c3e824455ec9eacb224b05795667 Mon Sep 17 00:00:00 2001 From: Jason Mayfield Date: Mon, 13 Dec 2010 20:05:05 -0500 Subject: [PATCH 004/103] allow save as for templates to easily copy templates for another site Signed-off-by: Jannis Leidel --- dbtemplates/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 2d50d5a..34e3865 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -89,6 +89,7 @@ class TemplateAdmin(TemplateModelAdmin): filter_horizontal = ('sites',) list_display = ('name', 'creation_date', 'last_changed', 'site_list') list_filter = ('sites',) + save_as = True search_fields = ('name', 'content') actions = ['invalidate_cache', 'repopulate_cache'] From 825e3b95ff27eb6e8c04a12feedd8c5d0ff5900f Mon Sep 17 00:00:00 2001 From: Jason Mayfield Date: Mon, 10 Jan 2011 08:25:27 -0500 Subject: [PATCH 005/103] allow blank sites Signed-off-by: Jannis Leidel --- dbtemplates/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbtemplates/models.py b/dbtemplates/models.py index 6ae4995..ef36677 100644 --- a/dbtemplates/models.py +++ b/dbtemplates/models.py @@ -22,7 +22,8 @@ class Template(models.Model): name = models.CharField(_('name'), max_length=100, help_text=_("Example: 'flatpages/default.html'")) content = models.TextField(_('content'), blank=True) - sites = models.ManyToManyField(Site, verbose_name=_('sites')) + sites = models.ManyToManyField(Site, verbose_name=_('sites'), blank=True, + null=True) creation_date = models.DateTimeField(_('creation date'), default=datetime.now) last_changed = models.DateTimeField(_('last changed'), From 519ad3763aa7f30aed57c93e0ee11cb61a6292a4 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 15 Jun 2011 16:20:30 +0200 Subject: [PATCH 006/103] Fixed import. --- dbtemplates/tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index ebf35ce..0ddd6d0 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -7,7 +7,8 @@ from django.contrib.sites.models import Site from dbtemplates import settings from dbtemplates.loader import load_template_source -from dbtemplates.models import Template, get_template_source +from dbtemplates.models import Template +from dbtemplates.utils import get_template_source class DbTemplatesTestCase(TestCase): def setUp(self): From 6caa401c7c7342c4c6075b27c492eef4a3a36642 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 15 Jun 2011 16:20:40 +0200 Subject: [PATCH 007/103] Use current example project. --- example/requirements.txt | 4 +++- example/settings.py | 10 +++++----- example/urls.py | 6 ------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/example/requirements.txt b/example/requirements.txt index 474ccbb..f03dcca 100644 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -1 +1,3 @@ -django-staticfiles south \ No newline at end of file +django-staticfiles +south +django>=1.3 \ No newline at end of file diff --git a/example/settings.py b/example/settings.py index 59842f7..392214c 100644 --- a/example/settings.py +++ b/example/settings.py @@ -70,10 +70,10 @@ SECRET_KEY = 'e-%(1e1f8ar2v)_8d!%-75a2ag(w(ht*l%n-wts5$li!5=97)8' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', - 'django.template.loaders.eggs.load_template_source', - 'dbtemplates.loader.load_template_source', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + 'django.template.loaders.eggs.Loader', + 'dbtemplates.loader.Loader', ) MIDDLEWARE_CLASSES = ( @@ -98,9 +98,9 @@ INSTALLED_APPS = ( 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.flatpages', + 'django.contrib.staticfiles', 'dbtemplates', 'south', - 'staticfiles', #'reversion', ) diff --git a/example/urls.py b/example/urls.py index 323d970..7b8c5ff 100644 --- a/example/urls.py +++ b/example/urls.py @@ -16,9 +16,3 @@ urlpatterns = patterns('', # Uncomment the next line to enable the admin: (r'^admin/', include(admin.site.urls)), ) - -# the following is used to serve up local media files like images -if settings.DEBUG: - urlpatterns += patterns("", - (r"", include("staticfiles.urls")), - ) From 2c814889edc9982749dfa2a615c2c78bc6fcb469 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 1 Jul 2011 14:27:21 +0200 Subject: [PATCH 008/103] 1.1 isn't supported anymore. --- tox.ini | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/tox.ini b/tox.ini index deb8479..5ab7af1 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,6 @@ downloadcache = .tox/_download/ distribute = False envlist = - py25-1.1.X, py26-1.1.X, py27-1.1.X, py25-1.2.X, py26-1.2.X, py27-1.2.X, py25-1.3.X, py26-1.3.X, py27-1.3.X @@ -10,22 +9,6 @@ envlist = commands = python runtests.py -[testenv:py25-1.1.X] -basepython = python2.5 -deps = - django==1.1.4 - -[testenv:py26-1.1.X] -basepython = python2.6 -deps = - django==1.1.4 - -[testenv:py27-1.1.X] -basepython = python2.7 -deps = - django==1.1.4 - - [testenv:py25-1.2.X] basepython = python2.5 deps = From ca032e70cf47c10e26566c84f6451c2fd2821ae5 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 1 Jul 2011 15:41:24 +0200 Subject: [PATCH 009/103] Split utils module. --- dbtemplates/utils/__init__.py | 0 dbtemplates/utils/cache.py | 39 ++++++++++++++++++ dbtemplates/{utils.py => utils/template.py} | 45 --------------------- 3 files changed, 39 insertions(+), 45 deletions(-) create mode 100644 dbtemplates/utils/__init__.py create mode 100644 dbtemplates/utils/cache.py rename dbtemplates/{utils.py => utils/template.py} (57%) diff --git a/dbtemplates/utils/__init__.py b/dbtemplates/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py new file mode 100644 index 0000000..0dbe9d2 --- /dev/null +++ b/dbtemplates/utils/cache.py @@ -0,0 +1,39 @@ +from django.core.cache import get_cache + +from django.contrib.sites.models import Site + +from dbtemplates.conf import settings + + +def get_cache_backend(): + return get_cache(settings.CACHE_BACKEND) + +cache = get_cache_backend() + + +def get_cache_key(name): + current_site = Site.objects.get_current() + return 'dbtemplates::%s::%s' % (name, current_site.pk) + + +def set_and_return(content): + # Save in cache backend explicitly if manually deleted or invalidated + if cache: + cache.set(cache_key, content) + return (content, display_name) + +def add_template_to_cache(instance, **kwargs): + """ + Called via Django's signals to cache the templates, if the template + in the database was added or changed. + """ + remove_cached_template(instance) + cache.set(get_cache_key(instance.name), instance.content) + + +def remove_cached_template(instance, **kwargs): + """ + Called via Django's signals to remove cached templates, if the template + in the database was changed or deleted. + """ + cache.delete(get_cache_key(instance.name)) diff --git a/dbtemplates/utils.py b/dbtemplates/utils/template.py similarity index 57% rename from dbtemplates/utils.py rename to dbtemplates/utils/template.py index 61e9f14..6a52a95 100644 --- a/dbtemplates/utils.py +++ b/dbtemplates/utils/template.py @@ -1,52 +1,7 @@ from django import VERSION -from django.core.cache import get_cache from django.template import TemplateDoesNotExist from django.utils.importlib import import_module -from django.contrib.sites.models import Site - -from dbtemplates import settings - - -def get_cache_backend(): - return get_cache(settings.CACHE_BACKEND) - -cache = get_cache_backend() - - -def add_default_site(instance, **kwargs): - """ - Called via Django's signals to cache the templates, if the template - in the database was added or changed, only if DBTEMPLATES_ADD_DEFAULT_SITE - setting is set. - """ - if settings.ADD_DEFAULT_SITE: - current_site = Site.objects.get_current() - if current_site not in instance.sites.all(): - instance.sites.add(current_site) - - -def get_cache_key(name): - current_site = Site.objects.get_current() - return 'dbtemplates::%s::%s' % (name, current_site.pk) - - -def add_template_to_cache(instance, **kwargs): - """ - Called via Django's signals to cache the templates, if the template - in the database was added or changed. - """ - remove_cached_template(instance) - cache.set(get_cache_key(instance.name), instance.content) - - -def remove_cached_template(instance, **kwargs): - """ - Called via Django's signals to remove cached templates, if the template - in the database was changed or deleted. - """ - cache.delete(get_cache_key(instance.name)) - def get_loaders(): from django.template.loader import template_source_loaders From a40204def748be653c8c7d3a36dc1132def7b455 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 1 Jul 2011 15:44:09 +0200 Subject: [PATCH 010/103] Moved setttings over to use AppSettings class. --- dbtemplates/admin.py | 14 +-- dbtemplates/conf.py | 42 +++++++ .../management/commands/sync_templates.py | 2 +- dbtemplates/models.py | 26 ++++- dbtemplates/settings.py | 33 ------ dbtemplates/tests.py | 66 +++++------ dbtemplates/utils/cache.py | 2 +- dbtemplates/utils/settings.py | 105 ++++++++++++++++++ runtests.py | 5 + 9 files changed, 206 insertions(+), 89 deletions(-) create mode 100644 dbtemplates/conf.py delete mode 100644 dbtemplates/settings.py create mode 100644 dbtemplates/utils/settings.py diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 34e3865..3109a41 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -4,13 +4,13 @@ from django.contrib import admin from django.utils.translation import ungettext, ugettext_lazy as _ from django.utils.safestring import mark_safe -from dbtemplates import settings +from dbtemplates.conf import settings from dbtemplates.models import (Template, remove_cached_template, add_template_to_cache) # Check if django-reversion is installed and use reversions' VersionAdmin # as the base admin class if yes -if settings.USE_REVERSION: +if settings.DBTEMPLATES_USE_REVERSION: from reversion.admin import VersionAdmin as TemplateModelAdmin else: from django.contrib.admin import ModelAdmin as TemplateModelAdmin @@ -23,8 +23,8 @@ class CodeMirrorTextArea(forms.Textarea): """ class Media: css = dict(screen=[ - posixpath.join(settings.MEDIA_PREFIX, 'css/editor.css')]) - js = [posixpath.join(settings.MEDIA_PREFIX, 'js/codemirror.js')] + posixpath.join(settings.DBTEMPLATES_MEDIA_PREFIX, 'css/editor.css')]) + js = [posixpath.join(settings.DBTEMPLATES_MEDIA_PREFIX, 'js/codemirror.js')] def render(self, name, value, attrs=None): result = [] @@ -43,15 +43,15 @@ class CodeMirrorTextArea(forms.Textarea): lineNumbers: true }); -""" % dict(media_prefix=settings.MEDIA_PREFIX, name=name)) +""" % dict(media_prefix=settings.DBTEMPLATES_MEDIA_PREFIX, name=name)) return mark_safe(u"".join(result)) -if settings.USE_CODEMIRROR: +if settings.DBTEMPLATES_USE_CODEMIRROR: TemplateContentTextArea = CodeMirrorTextArea else: TemplateContentTextArea = forms.Textarea -if settings.AUTO_POPULATE_CONTENT: +if settings.DBTEMPLATES_AUTO_POPULATE_CONTENT: content_help_text = _("Leaving this empty causes Django to look for a " "template with the given name and populate this field with its " "content.") diff --git a/dbtemplates/conf.py b/dbtemplates/conf.py new file mode 100644 index 0000000..34357d0 --- /dev/null +++ b/dbtemplates/conf.py @@ -0,0 +1,42 @@ +import posixpath + +from django.core.exceptions import ImproperlyConfigured + +from dbtemplates.utils.settings import AppSettings + + +class DbTemplatesSettings(AppSettings): + USE_CODEMIRROR = False + USE_REVERSION = False + ADD_DEFAULT_SITE = True + AUTO_POPULATE_CONTENT = True + MEDIA_PREFIX = None + CACHE_BACKEND = None + + def configure_media_prefix(self, value): + if value is None: + base_url = getattr(self, "STATIC_URL", None) + if base_url is None: + base_url = self.MEDIA_URL + value = posixpath.join(base_url, "dbtemplates/") + return value + + def configure_cache_backend(self, value): + # If we are on Django 1.3 AND using the new CACHES setting.. + if hasattr(self, "CACHES"): + if "dbtemplates" in self.CACHES: + return "dbtemplates" + else: + return "default" + if isinstance(value, basestring) and value.startswith("dbtemplates."): + raise ImproperlyConfigured("Please upgrade to one of the supported " + "backends as defined in the Django docs.") + return value + + def configure_use_reversion(self, value): + if value and 'reversion' not in self.INSTALLED_APPS: + raise ImproperlyConfigured("Please add 'reversion' to your " + "INSTALLED_APPS setting to make use of it in dbtemplates.") + return value + +settings = DbTemplatesSettings("DBTEMPLATES") diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index c4330e4..6288a7e 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -1,11 +1,11 @@ import os from optparse import make_option -from django.conf import settings from django.contrib.sites.models import Site from django.core.management.base import CommandError, NoArgsCommand from django.template.loaders.app_directories import app_template_dirs +from dbtemplates.conf import settings from dbtemplates.models import Template ALWAYS_ASK, FILES_TO_DATABASE, DATABASE_TO_FILES = ('0', '1', '2') diff --git a/dbtemplates/models.py b/dbtemplates/models.py index ef36677..2cc4cf2 100644 --- a/dbtemplates/models.py +++ b/dbtemplates/models.py @@ -9,9 +9,10 @@ from django.utils.translation import gettext_lazy as _ from django.contrib.sites.models import Site from django.contrib.sites.managers import CurrentSiteManager -from dbtemplates import settings -from dbtemplates.utils import (add_default_site, add_template_to_cache, - remove_cached_template, get_template_source) +from dbtemplates.conf import settings +from dbtemplates.utils.cache import add_template_to_cache, remove_cached_template +from dbtemplates.utils.template import get_template_source + class Template(models.Model): @@ -22,8 +23,8 @@ class Template(models.Model): name = models.CharField(_('name'), max_length=100, help_text=_("Example: 'flatpages/default.html'")) content = models.TextField(_('content'), blank=True) - sites = models.ManyToManyField(Site, verbose_name=_('sites'), blank=True, - null=True) + sites = models.ManyToManyField(Site, verbose_name=_('sites'), + blank=True, null=True) creation_date = models.DateTimeField(_('creation date'), default=datetime.now) last_changed = models.DateTimeField(_('last changed'), @@ -59,11 +60,24 @@ class Template(models.Model): self.last_changed = datetime.now() # If content is empty look for a template with the given name and # populate the template instance with its content. - if settings.AUTO_POPULATE_CONTENT and not self.content: + if settings.DBTEMPLATES_AUTO_POPULATE_CONTENT and not self.content: self.populate() super(Template, self).save(*args, **kwargs) +def add_default_site(instance, **kwargs): + """ + Called via Django's signals to cache the templates, if the template + in the database was added or changed, only if + DBTEMPLATES_ADD_DEFAULT_SITE setting is set. + """ + if not settings.DBTEMPLATES_ADD_DEFAULT_SITE: + return + current_site = Site.objects.get_current() + if current_site not in instance.sites.all(): + instance.sites.add(current_site) + + signals.post_save.connect(add_default_site, sender=Template) signals.post_save.connect(add_template_to_cache, sender=Template) signals.pre_delete.connect(remove_cached_template, sender=Template) diff --git a/dbtemplates/settings.py b/dbtemplates/settings.py deleted file mode 100644 index c1bef09..0000000 --- a/dbtemplates/settings.py +++ /dev/null @@ -1,33 +0,0 @@ -import posixpath -from django.conf import settings -from django.core.exceptions import ImproperlyConfigured - -if "dbtemplates" in getattr(settings, "CACHES", {}): - # If we are on Django 1.3 AND using the new CACHES setting.. - cache = "dbtemplates" -else: - # ..or fall back to the old CACHE_BACKEND setting - cache = getattr(settings, "DBTEMPLATES_CACHE_BACKEND", None) -if isinstance(cache, basestring) and cache.startswith("dbtemplates."): - raise ImproperlyConfigured("Please upgrade to one of the supported " - "backends as defined in the Django docs.") -CACHE_BACKEND = cache - -ADD_DEFAULT_SITE = getattr(settings, 'DBTEMPLATES_ADD_DEFAULT_SITE', True) - -AUTO_POPULATE_CONTENT = getattr( - settings, 'DBTEMPLATES_AUTO_POPULATE_CONTENT', True) - -base_url = getattr(settings, "STATIC_URL", None) -if base_url is None: - base_url = settings.MEDIA_URL -MEDIA_PREFIX = getattr(settings, 'DBTEMPLATES_MEDIA_PREFIX', - posixpath.join(base_url, "dbtemplates/")) - -USE_REVERSION = getattr(settings, 'DBTEMPLATES_USE_REVERSION', False) - -if USE_REVERSION and 'reversion' not in settings.INSTALLED_APPS: - raise ImproperlyConfigured("Please add reversion to your " - "INSTALLED_APPS setting to make use of it in dbtemplates.") - -USE_CODEMIRROR = getattr(settings, 'DBTEMPLATES_USE_CODEMIRROR', False) diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index 0ddd6d0..df95e54 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -1,65 +1,49 @@ -from django import VERSION +from __future__ import with_statement + from django.core.management import call_command from django.template import loader, Context from django.test import TestCase from django.contrib.sites.models import Site -from dbtemplates import settings -from dbtemplates.loader import load_template_source +from dbtemplates.conf import settings from dbtemplates.models import Template -from dbtemplates.utils import get_template_source +from dbtemplates.utils.template import get_template_source + class DbTemplatesTestCase(TestCase): def setUp(self): self.site1, created1 = Site.objects.get_or_create(domain="example.com", name="example.com") self.site2, created2 = Site.objects.get_or_create(domain="example.org", name="example.org") + self.t1, _ = Template.objects.get_or_create(name='base.html', content='base') + self.t2, _ = Template.objects.get_or_create(name='sub.html', content='sub') + self.t2.sites.add(self.site2) def test_basiscs(self): - t1 = Template(name='base.html', content='{% block content %}Welcome at {{ title }}{% endblock %}') - t1.save() - self.assertEqual(Site.objects.get_current(), t1.sites.all()[0]) - self.assertTrue("Welcome at" in t1.content) + self.assertEqual(list(self.t1.sites.all()), [self.site1]) + self.assertTrue("base" in self.t1.content) + self.assertEqual(list(Template.objects.filter(sites=self.site1)), [self.t1, self.t2]) + self.assertEqual(list(self.t2.sites.all()), [self.site1, self.site2]) - t2 = Template(name='sub.html', content='{% extends "base.html" %}{% block content %}This is {{ title }}{% endblock %}') - t2.save() - t2.sites.add(self.site2) - - self.assertEqual(list(Template.objects.filter(sites=self.site1)), [t1, t2]) - self.assertEqual(list(t2.sites.all()), [self.site1, self.site2]) + def test_empty_sites(self): + old_add_default_site = settings.DBTEMPLATES_ADD_DEFAULT_SITE + try: + settings.DBTEMPLATES_ADD_DEFAULT_SITE = False + self.t3 = Template.objects.create(name='footer.html', content='footer') + self.assertEqual(list(self.t3.sites.all()), []) + finally: + settings.DBTEMPLATES_ADD_DEFAULT_SITE = old_add_default_site def test_load_templates(self): - self.test_basiscs() - original_template_source_loaders = loader.template_source_loaders - loader.template_source_loaders = [load_template_source] - try: - result1 = loader.get_template("base.html").render(Context({'title':'MainPage'})) - self.assertEqual(result1, u'Welcome at MainPage') - result2 = loader.get_template("sub.html").render(Context({'title':'SubPage'})) - self.assertEqual(result2, u'This is SubPage') - - if VERSION[:2] >= (1, 2): - from dbtemplates.loader import Loader - dbloader = Loader() - loader.template_source_loaders = [dbloader.load_template_source] - result = loader.get_template("base.html").render(Context({'title':'MainPage'})) - self.assertEqual(result, u'Welcome at MainPage') - result2 = loader.get_template("sub.html").render(Context({'title':'SubPage'})) - self.assertEqual(result2, u'This is SubPage') - finally: - loader.template_source_loaders = original_template_source_loaders + result = loader.get_template("base.html").render(Context({})) + self.assertEqual(result, 'base') + result2 = loader.get_template("sub.html").render(Context({})) + self.assertEqual(result2, 'sub') def test_error_templates_creation(self): call_command('create_error_templates', force=True, verbosity=0) self.assertEqual(list(Template.objects.filter(sites=self.site1)), - list(Template.objects.filter())) - - def test_disabling_default_site(self): - old_add_default_site = settings.ADD_DEFAULT_SITE - settings.ADD_DEFAULT_SITE = False - t3 = Template.objects.create(name='footer.html', content='ohai') - self.assertEqual(list(t3.sites.all()), []) - settings.ADD_DEFAULT_SITE = old_add_default_site + list(Template.objects.filter())) def test_automatic_sync(self): admin_base_template = get_template_source('admin/base.html') diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py index 0dbe9d2..f93410f 100644 --- a/dbtemplates/utils/cache.py +++ b/dbtemplates/utils/cache.py @@ -16,7 +16,7 @@ def get_cache_key(name): return 'dbtemplates::%s::%s' % (name, current_site.pk) -def set_and_return(content): +def set_and_return(content, display_name): # Save in cache backend explicitly if manually deleted or invalidated if cache: cache.set(cache_key, content) diff --git a/dbtemplates/utils/settings.py b/dbtemplates/utils/settings.py new file mode 100644 index 0000000..221e58d --- /dev/null +++ b/dbtemplates/utils/settings.py @@ -0,0 +1,105 @@ +from inspect import getmembers +from django.conf import settings + + +class AppSettings(object): + """ + An app setting object to be used for handling app setting defaults + gracefully and providing a nice API for them. Say you have an app + called ``myapp`` and want to define a few defaults, and refer to the + defaults easily in the apps code. Add a ``settings.py`` to your app:: + + from path.to.utils import AppSettings + + class MyAppSettings(AppSettings): + SETTING_1 = "one" + SETTING_2 = ( + "two", + ) + + Then initialize the setting with the correct prefix in the location of + of your choice, e.g. ``conf.py`` of the app module:: + + settings = MyAppSettings(prefix="MYAPP") + + The ``MyAppSettings`` instance will automatically look at Django's + global setting to determine each of the settings and respect the + provided ``prefix``. E.g. adding this to your site's ``settings.py`` + will set the ``SETTING_1`` setting accordingly:: + + MYAPP_SETTING_1 = "uno" + + Usage + ----- + + Instead of using ``from django.conf import settings`` as you would + usually do, you can switch to using your apps own settings module + to access the app settings:: + + from myapp.conf import settings + + print myapp_settings.MYAPP_SETTING_1 + + ``AppSettings`` instances also work as pass-throughs for other + global settings that aren't related to the app. For example the + following code is perfectly valid:: + + from myapp.conf import settings + + if "myapp" in settings.INSTALLED_APPS: + print "yay, myapp is installed!" + + Custom handling + --------------- + + Each of the settings can be individually configured with callbacks. + For example, in case a value of a setting depends on other settings + or other dependencies. The following example sets one setting to a + different value depending on a global setting:: + + from django.conf import settings + + class MyCustomAppSettings(AppSettings): + ENABLED = True + + def configure_enabled(self, value): + return value and not self.DEBUG + + custom_settings = MyCustomAppSettings("MYAPP") + + The value of ``custom_settings.MYAPP_ENABLED`` will vary depending on the + value of the global ``DEBUG`` setting. + + Each of the app settings can be customized by providing + a method ``configure_`` that takes the default + value as defined in the class attributes as the only parameter. + The method needs to return the value to be use for the setting in + question. + """ + def __dir__(self): + return sorted(list(set(self.__dict__.keys() + dir(settings)))) + + __members__ = lambda self: self.__dir__() + + def __getattr__(self, name): + if name.startswith(self._prefix): + raise AttributeError("%r object has no attribute %r" % + (self.__class__.__name__, name)) + return getattr(settings, name) + + def __setattr__(self, name, value): + super(AppSettings, self).__setattr__(name, value) + if name in dir(settings): + setattr(settings, name, value) + + def __init__(self, prefix): + super(AppSettings, self).__setattr__('_prefix', prefix) + for setting, class_value in getmembers(self.__class__): + if setting == setting.upper(): + prefixed = "%s_%s" % (prefix.upper(), setting.upper()) + configured_value = getattr(settings, prefixed, class_value) + callback = getattr(self, "configure_%s" % setting.lower(), None) + if callable(callback): + configured_value = callback(configured_value) + delattr(self.__class__, setting) + setattr(self, prefixed, configured_value) diff --git a/runtests.py b/runtests.py index a9b1115..e0d6ef6 100644 --- a/runtests.py +++ b/runtests.py @@ -15,6 +15,11 @@ if not settings.configured: 'django.contrib.admin', 'dbtemplates', ], + TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.load_template_source', + 'django.template.loaders.app_directories.load_template_source', + 'dbtemplates.loader.Loader', + ) ) from django.test.simple import run_tests From 2804cd527fce114468aeb934a4e64f1fd2b17352 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 1 Jul 2011 15:44:23 +0200 Subject: [PATCH 011/103] Refactored loader to be class based only. --- dbtemplates/loader.py | 72 +++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index ca2d817..9a73c09 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -1,14 +1,13 @@ -import warnings -from django import VERSION -from django.conf import settings from django.contrib.sites.models import Site from django.template import TemplateDoesNotExist +from dbtemplates.conf import settings from dbtemplates.models import Template -from dbtemplates.utils import cache, get_cache_key +from dbtemplates.utils.cache import cache, get_cache_key, set_and_return +from django.template.loader import BaseLoader -def load_template_source(template_name, template_dirs=None, annoy=True): +class Loader(BaseLoader): """ A custom template loader to load templates from the database. @@ -17,43 +16,28 @@ def load_template_source(template_name, template_dirs=None, annoy=True): it falls back to query the database field ``name`` with the template path and ``sites`` with the current site. """ - if VERSION[:2] >= (1, 2) and annoy: - # For backward compatibility - warnings.warn( - "`dbtemplates.loader.load_template_source` is deprecated; " - "use `dbtemplates.loader.Loader` instead.", DeprecationWarning) - site = Site.objects.get_current() - display_name = 'db:%s:%s:%s' % (settings.DATABASE_ENGINE, - template_name, site.domain) - cache_key = get_cache_key(template_name) - if cache: - try: - backend_template = cache.get(cache_key) - if backend_template: - return backend_template, template_name - except: - pass - try: - template = Template.on_site.filter(name__exact=template_name)[0] - # Save in cache backend explicitly if manually deleted or invalidated + is_usable = True + + def load_template_source(self, template_name, template_dirs=None): + site = Site.objects.get_current() + display_name = 'dbtemplates:%s:%s:%s' % (settings.DATABASE_ENGINE, + template_name, site.domain) + cache_key = get_cache_key(template_name) if cache: - cache.set(cache_key, template.content) - return (template.content, display_name) - except: - pass - raise TemplateDoesNotExist(template_name) -load_template_source.is_usable = True - - -if VERSION[:2] >= (1, 2): - # providing a class based loader for Django >= 1.2, yay! - from django.template.loader import BaseLoader - - class Loader(BaseLoader): - __doc__ = load_template_source.__doc__ - - is_usable = True - - def load_template_source(self, template_name, template_dirs=None): - return load_template_source( - template_name, template_dirs, annoy=False) + try: + backend_template = cache.get(cache_key) + if backend_template: + return backend_template, template_name + except: + pass + try: + template = Template.objects.get(name__exact=template_name) + return set_and_return(template.content, display_name) + except (Template.MultipleObjectsReturned, Template.DoesNotExist): + try: + template = Template.objects.get( + name__exact=template_name, sites__in=[site.id]) + return set_and_return(template.content, display_name) + except Template.DoesNotExist: + pass + raise TemplateDoesNotExist(template_name) From e3986a3e0805466a6e5569c1b9d04d7ffd75ce1e Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 1 Jul 2011 15:45:09 +0200 Subject: [PATCH 012/103] Extended changelog. --- docs/changelog.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 841023e..f51bc8f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,6 +1,32 @@ Changelog ========= +1.1 (unreleased) +---------------- + +* Added South migrations. + +.. note:: + + If you are using South in your Django project, you can easily enable + dbtemplates' migrations, *faking* the first migration by using the + ``--fake`` option of South's ``migrate`` management command:: + + $ manage.py migrate --fake 0001 dbtemplates + + Then run the rest of the migrations:: + + $ manage.py migrate dbtemplates + +* Removed uniqueness on the ``name`` field of the ``Template`` model. This is + needed because there isn't a ``unique_together`` for M2M fields in Django + such as the ``sites`` field in the ``Template`` model. + +* Made the ``sites`` field optional to support a way to apply a template to + all sites. + +* Fixed issue with cache settings handling. + 1.0.1 (04-14-11) ---------------- From 05b109ec5ab232867dd9fb71aaec042ebd629fd7 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 1 Jul 2011 15:50:04 +0200 Subject: [PATCH 013/103] A bunch of flake8 fixees. --- dbtemplates/admin.py | 4 ++-- dbtemplates/conf.py | 5 +++-- dbtemplates/loader.py | 5 +++-- dbtemplates/models.py | 1 - dbtemplates/tests.py | 18 ++++++++++++------ dbtemplates/utils/cache.py | 3 ++- dbtemplates/utils/settings.py | 3 ++- 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 3109a41..e109003 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -22,8 +22,8 @@ class CodeMirrorTextArea(forms.Textarea): content field of the Template model. """ class Media: - css = dict(screen=[ - posixpath.join(settings.DBTEMPLATES_MEDIA_PREFIX, 'css/editor.css')]) + css = dict(screen=[posixpath.join( + settings.DBTEMPLATES_MEDIA_PREFIX, 'css/editor.css')]) js = [posixpath.join(settings.DBTEMPLATES_MEDIA_PREFIX, 'js/codemirror.js')] def render(self, name, value, attrs=None): diff --git a/dbtemplates/conf.py b/dbtemplates/conf.py index 34357d0..f245983 100644 --- a/dbtemplates/conf.py +++ b/dbtemplates/conf.py @@ -29,8 +29,9 @@ class DbTemplatesSettings(AppSettings): else: return "default" if isinstance(value, basestring) and value.startswith("dbtemplates."): - raise ImproperlyConfigured("Please upgrade to one of the supported " - "backends as defined in the Django docs.") + raise ImproperlyConfigured("Please upgrade to one of the " + "supported backends as defined " + "in the Django docs.") return value def configure_use_reversion(self, value): diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index 9a73c09..c5cc4a4 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -32,12 +32,13 @@ class Loader(BaseLoader): pass try: template = Template.objects.get(name__exact=template_name) - return set_and_return(template.content, display_name) + return set_and_return(cache_key, template.content, display_name) except (Template.MultipleObjectsReturned, Template.DoesNotExist): try: template = Template.objects.get( name__exact=template_name, sites__in=[site.id]) - return set_and_return(template.content, display_name) + return set_and_return( + cache_key, template.content, display_name) except Template.DoesNotExist: pass raise TemplateDoesNotExist(template_name) diff --git a/dbtemplates/models.py b/dbtemplates/models.py index 2cc4cf2..88eb386 100644 --- a/dbtemplates/models.py +++ b/dbtemplates/models.py @@ -14,7 +14,6 @@ from dbtemplates.utils.cache import add_template_to_cache, remove_cached_templat from dbtemplates.utils.template import get_template_source - class Template(models.Model): """ Defines a template model for use with the database template loader. diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index df95e54..fb2ca31 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -13,23 +13,29 @@ from dbtemplates.utils.template import get_template_source class DbTemplatesTestCase(TestCase): def setUp(self): - self.site1, created1 = Site.objects.get_or_create(domain="example.com", name="example.com") - self.site2, created2 = Site.objects.get_or_create(domain="example.org", name="example.org") - self.t1, _ = Template.objects.get_or_create(name='base.html', content='base') - self.t2, _ = Template.objects.get_or_create(name='sub.html', content='sub') + self.site1, created1 = Site.objects.get_or_create( + domain="example.com", name="example.com") + self.site2, created2 = Site.objects.get_or_create( + domain="example.org", name="example.org") + self.t1, _ = Template.objects.get_or_create( + name='base.html', content='base') + self.t2, _ = Template.objects.get_or_create( + name='sub.html', content='sub') self.t2.sites.add(self.site2) def test_basiscs(self): self.assertEqual(list(self.t1.sites.all()), [self.site1]) self.assertTrue("base" in self.t1.content) - self.assertEqual(list(Template.objects.filter(sites=self.site1)), [self.t1, self.t2]) + self.assertEqual(list(Template.objects.filter(sites=self.site1)), + [self.t1, self.t2]) self.assertEqual(list(self.t2.sites.all()), [self.site1, self.site2]) def test_empty_sites(self): old_add_default_site = settings.DBTEMPLATES_ADD_DEFAULT_SITE try: settings.DBTEMPLATES_ADD_DEFAULT_SITE = False - self.t3 = Template.objects.create(name='footer.html', content='footer') + self.t3 = Template.objects.create( + name='footer.html', content='footer') self.assertEqual(list(self.t3.sites.all()), []) finally: settings.DBTEMPLATES_ADD_DEFAULT_SITE = old_add_default_site diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py index f93410f..611a490 100644 --- a/dbtemplates/utils/cache.py +++ b/dbtemplates/utils/cache.py @@ -16,12 +16,13 @@ def get_cache_key(name): return 'dbtemplates::%s::%s' % (name, current_site.pk) -def set_and_return(content, display_name): +def set_and_return(cache_key, content, display_name): # Save in cache backend explicitly if manually deleted or invalidated if cache: cache.set(cache_key, content) return (content, display_name) + def add_template_to_cache(instance, **kwargs): """ Called via Django's signals to cache the templates, if the template diff --git a/dbtemplates/utils/settings.py b/dbtemplates/utils/settings.py index 221e58d..0431888 100644 --- a/dbtemplates/utils/settings.py +++ b/dbtemplates/utils/settings.py @@ -98,7 +98,8 @@ class AppSettings(object): if setting == setting.upper(): prefixed = "%s_%s" % (prefix.upper(), setting.upper()) configured_value = getattr(settings, prefixed, class_value) - callback = getattr(self, "configure_%s" % setting.lower(), None) + callback_name = "configure_%s" % setting.lower() + callback = getattr(self, callback_name, None) if callable(callback): configured_value = callback(configured_value) delattr(self.__class__, setting) From 7473b54bb1f732f34c88febfd7b1ebccd4721333 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 6 Jul 2011 15:40:56 +0200 Subject: [PATCH 014/103] Added tests for sync_templates command. --- .../management/commands/sync_templates.py | 11 ++++++----- .../templates/dbtemplates/tests/test.html | 1 + dbtemplates/tests.py | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 dbtemplates/templates/dbtemplates/tests/test.html diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 6288a7e..0fa5ddc 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -1,4 +1,5 @@ import os +import codecs from optparse import make_option from django.contrib.sites.models import Site @@ -53,8 +54,8 @@ class Command(NoArgsCommand): for templatedir in templatedirs: for dirpath, subdirs, filenames in os.walk(templatedir): - for f in [f for f in filenames if f.endswith(extension) - and not f.startswith(".")]: + for f in [f for f in filenames + if f.endswith(extension) and not f.startswith(".")]: path = os.path.join(dirpath, f) name = path.split(templatedir)[1][1:] try: @@ -67,7 +68,7 @@ class Command(NoArgsCommand): " (y/[n]): """ % (name, path)) if force or confirm.lower().startswith('y'): t = Template(name=name, - content=open(path, "r").read()) + content=codecs.open(path, "r").read()) t.save() t.sites.add(site) else: @@ -86,12 +87,12 @@ class Command(NoArgsCommand): if confirm == '' or confirm in ( FILES_TO_DATABASE, DATABASE_TO_FILES): if confirm == FILES_TO_DATABASE: - t.content = open(path, 'r').read() + t.content = codecs.open(path, 'r').read() t.save() t.sites.add(site) elif confirm == DATABASE_TO_FILES: try: - f = open(path, 'w') + f = codecs.open(path, 'w') f.write(t.content) finally: f.close() diff --git a/dbtemplates/templates/dbtemplates/tests/test.html b/dbtemplates/templates/dbtemplates/tests/test.html new file mode 100644 index 0000000..a96fb46 --- /dev/null +++ b/dbtemplates/templates/dbtemplates/tests/test.html @@ -0,0 +1 @@ +This is just a test template. \ No newline at end of file diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index fb2ca31..51cf797 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -1,4 +1,5 @@ from __future__ import with_statement +import os from django.core.management import call_command from django.template import loader, Context @@ -9,7 +10,7 @@ from django.contrib.sites.models import Site from dbtemplates.conf import settings from dbtemplates.models import Template from dbtemplates.utils.template import get_template_source - +from dbtemplates.management.commands.sync_templates import FILES_TO_DATABASE class DbTemplatesTestCase(TestCase): def setUp(self): @@ -50,8 +51,22 @@ class DbTemplatesTestCase(TestCase): call_command('create_error_templates', force=True, verbosity=0) self.assertEqual(list(Template.objects.filter(sites=self.site1)), list(Template.objects.filter())) + self.assertTrue(Template.objects.filter(name='404.html').exists()) def test_automatic_sync(self): admin_base_template = get_template_source('admin/base.html') template = Template.objects.create(name='admin/base.html') self.assertEqual(admin_base_template, template.content) + + def test_sync_templates(self): + old_template_dirs = settings.TEMPLATE_DIRS + try: + self.assertFalse(Template.objects.filter(name='dbtemplates/tests/test.html').exists()) + settings.TEMPLATE_DIRS = ( + os.path.join(os.path.dirname(__file__), 'templates'), + ) + call_command('sync_templates', + force=True, verbosity=0, overwrite=FILES_TO_DATABASE) + self.assertTrue(Template.objects.filter(name='dbtemplates/tests/test.html').exists()) + finally: + settings.TEMPLATE_DIRS = old_template_dirs From fb1fdcbd8448d9ca7f1e6f5415ec5df6f364e16a Mon Sep 17 00:00:00 2001 From: olivergeorge Date: Thu, 9 Jun 2011 22:24:09 +1000 Subject: [PATCH 015/103] Extended sync_templates command to make exporting changes out to file easier. --- .../management/commands/sync_templates.py | 16 +++++++-- .../templates/dbtemplates/tests/test.html | 1 - dbtemplates/tests.py | 33 +++++++++++++++---- 3 files changed, 40 insertions(+), 10 deletions(-) delete mode 100644 dbtemplates/templates/dbtemplates/tests/test.html diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 0fa5ddc..7c62134 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -25,13 +25,16 @@ class Command(NoArgsCommand): "files from database templates"), make_option("-a", "--app-first", action="store_true", dest="app_first", default=False, help="look for templates in applications " - "directories before project templates")) + "directories before project templates"), + make_option("-d", "--delete", action="store_true", dest="delete", + default=False, help="Delete templates after syncing")) def handle_noargs(self, **options): extension = options.get('ext') force = options.get('force') overwrite = options.get('overwrite') app_first = options.get('app_first') + delete = options.get('delete') if not extension.startswith("."): extension = ".%s" % extension @@ -84,16 +87,23 @@ class Command(NoArgsCommand): path, t.__repr__())) else: confirm = overwrite - if confirm == '' or confirm in ( - FILES_TO_DATABASE, DATABASE_TO_FILES): + if confirm in ('', FILES_TO_DATABASE, DATABASE_TO_FILES): if confirm == FILES_TO_DATABASE: t.content = codecs.open(path, 'r').read() t.save() t.sites.add(site) + if delete: + try: + os.remove(path) + except OSError: + raise CommandError( + u"Couldn't delete %s" % path) elif confirm == DATABASE_TO_FILES: try: f = codecs.open(path, 'w') f.write(t.content) finally: f.close() + if delete: + t.delete() break diff --git a/dbtemplates/templates/dbtemplates/tests/test.html b/dbtemplates/templates/dbtemplates/tests/test.html deleted file mode 100644 index a96fb46..0000000 --- a/dbtemplates/templates/dbtemplates/tests/test.html +++ /dev/null @@ -1 +0,0 @@ -This is just a test template. \ No newline at end of file diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index 51cf797..32a03ee 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -1,5 +1,8 @@ from __future__ import with_statement +import codecs import os +import shutil +import tempfile from django.core.management import call_command from django.template import loader, Context @@ -10,7 +13,8 @@ from django.contrib.sites.models import Site from dbtemplates.conf import settings from dbtemplates.models import Template from dbtemplates.utils.template import get_template_source -from dbtemplates.management.commands.sync_templates import FILES_TO_DATABASE +from dbtemplates.management.commands.sync_templates import (FILES_TO_DATABASE, + DATABASE_TO_FILES) class DbTemplatesTestCase(TestCase): def setUp(self): @@ -60,13 +64,30 @@ class DbTemplatesTestCase(TestCase): def test_sync_templates(self): old_template_dirs = settings.TEMPLATE_DIRS + temp_template_dir = tempfile.mkdtemp('dbtemplates') + last_path_part = temp_template_dir.split('/')[-1] + temp_template_path = os.path.join(temp_template_dir, 'temp_test.html') + temp_template = codecs.open(temp_template_path, 'w') try: - self.assertFalse(Template.objects.filter(name='dbtemplates/tests/test.html').exists()) - settings.TEMPLATE_DIRS = ( - os.path.join(os.path.dirname(__file__), 'templates'), - ) + temp_template.write('temp test') + settings.TEMPLATE_DIRS = (temp_template_dir,) + self.assertFalse(Template.objects.filter(name='temp_test.html').exists()) call_command('sync_templates', force=True, verbosity=0, overwrite=FILES_TO_DATABASE) - self.assertTrue(Template.objects.filter(name='dbtemplates/tests/test.html').exists()) + self.assertTrue(Template.objects.filter(name='temp_test.html').exists()) + + t = Template.objects.get(name='temp_test.html') + t.content = 'temp test modified' + t.save() + call_command('sync_templates', + force=True, verbosity=0, overwrite=DATABASE_TO_FILES) + self.assertTrue('modified' in codecs.open(temp_template_path).read()) + + call_command('sync_templates', + force=True, verbosity=0, delete=True, overwrite=DATABASE_TO_FILES) + self.assertTrue(os.path.exists(temp_template_path)) + self.assertFalse(Template.objects.filter(name='temp_test.html').exists()) finally: + temp_template.close() settings.TEMPLATE_DIRS = old_template_dirs + shutil.rmtree(temp_template_dir) From c588e51e83eb8fda489113bbd8bf1928079c3127 Mon Sep 17 00:00:00 2001 From: kmooney Date: Thu, 30 Jun 2011 12:26:50 -0500 Subject: [PATCH 016/103] Change to skip template loaders whose load method is not implemented. This happens with the Django cached template loader, in particular. --- dbtemplates/utils/template.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbtemplates/utils/template.py b/dbtemplates/utils/template.py index 6a52a95..f3b6f65 100644 --- a/dbtemplates/utils/template.py +++ b/dbtemplates/utils/template.py @@ -34,6 +34,8 @@ def get_template_source(name): source, origin = load_template_source(name) if source: return source + except NotImplementedError: + pass except TemplateDoesNotExist: pass if source is None and VERSION[:2] < (1, 2): From 8c5e1b95b3d6e5913ed2be5401d8ae6f984c1521 Mon Sep 17 00:00:00 2001 From: Alen Mujezinovic Date: Wed, 6 Jul 2011 18:11:05 +0100 Subject: [PATCH 017/103] Fixes template names being cut off when using sync_templates: http://cl.ly/0R092W1H3n3m19120j1x --- dbtemplates/management/commands/sync_templates.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 7c62134..92f412b 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -60,7 +60,9 @@ class Command(NoArgsCommand): for f in [f for f in filenames if f.endswith(extension) and not f.startswith(".")]: path = os.path.join(dirpath, f) - name = path.split(templatedir)[1][1:] + name = path.split(templatedir)[1] + if name.startswith('/'): + name = name[1:] try: t = Template.on_site.get(name__exact=name) except Template.DoesNotExist: From 19801a459228a478d433d09603282f36665a4943 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 6 Jul 2011 21:07:03 +0200 Subject: [PATCH 018/103] Removed unneeded requirement from example project. --- example/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/example/requirements.txt b/example/requirements.txt index f03dcca..0819cc5 100644 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -1,3 +1,2 @@ -django-staticfiles south django>=1.3 \ No newline at end of file From c2a21533fd7eb5f4fbc3d7827aa75e54fa9aba58 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 6 Jul 2011 21:15:08 +0200 Subject: [PATCH 019/103] Prepared changelog for release. --- docs/changelog.txt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index f51bc8f..d3ffa28 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,8 +1,13 @@ Changelog ========= -1.1 (unreleased) ----------------- +1.1 (07-06-11) +-------------- + +* **BACKWARDS-INCOMPATIBLE** Requires Django 1.2 or higher. + For previous Django versions use an older versions of dbtemplates, e.g.:: + + $ pip install django-dbtemplates<1.1 * Added South migrations. @@ -25,6 +30,14 @@ Changelog * Made the ``sites`` field optional to support a way to apply a template to all sites. +* Added ``--delete`` option to ``sync_templates`` managment command to delete + the file or database entry after syncing (depending on used ``--overwrite`` + mode). + +* Fixed issue with incorrectly splitting paths in ``sync_templates``. + +* Extended tests. + * Fixed issue with cache settings handling. 1.0.1 (04-14-11) From a3cc44c06906f870014d8aafd64616fe4eefde68 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 6 Jul 2011 21:16:09 +0200 Subject: [PATCH 020/103] Removed trailing whitespace. --- dbtemplates/management/commands/sync_templates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 92f412b..ca73d7f 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -61,7 +61,7 @@ class Command(NoArgsCommand): if f.endswith(extension) and not f.startswith(".")]: path = os.path.join(dirpath, f) name = path.split(templatedir)[1] - if name.startswith('/'): + if name.startswith('/'): name = name[1:] try: t = Template.on_site.get(name__exact=name) From e5cb4fd2d7c8cde6e57e008cb997aa62d76e9a88 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 6 Jul 2011 21:19:21 +0200 Subject: [PATCH 021/103] Fixed Transifex configuration. --- .tx/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tx/config b/.tx/config index 55ac0bd..931d09f 100644 --- a/.tx/config +++ b/.tx/config @@ -1,4 +1,4 @@ -[django-dbtemplates.django] +[django-dbtemplates.main] file_filter = dbtemplates/locale//LC_MESSAGES/django.po source_file = dbtemplates/locale/en/LC_MESSAGES/django.po source_lang = en From d5de8390aced904d3a4f45335531f1c1d0e7b185 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 6 Jul 2011 21:21:56 +0200 Subject: [PATCH 022/103] Updated translations. --- dbtemplates/locale/en/LC_MESSAGES/django.mo | Bin 367 -> 367 bytes dbtemplates/locale/en/LC_MESSAGES/django.po | 28 +++++------ dbtemplates/locale/fi/LC_MESSAGES/django.mo | Bin 1697 -> 1937 bytes dbtemplates/locale/fi/LC_MESSAGES/django.po | 44 +++++++++--------- .../locale/pt_BR/LC_MESSAGES/django.mo | Bin 1104 -> 1280 bytes .../locale/pt_BR/LC_MESSAGES/django.po | 18 +++---- .../locale/zh_CN/LC_MESSAGES/django.mo | Bin 1413 -> 1579 bytes .../locale/zh_CN/LC_MESSAGES/django.po | 4 +- docs/changelog.txt | 2 + 9 files changed, 51 insertions(+), 45 deletions(-) diff --git a/dbtemplates/locale/en/LC_MESSAGES/django.mo b/dbtemplates/locale/en/LC_MESSAGES/django.mo index b5e8316ca957e534748241d0d0c25036497589ff..503ba620ab7cb26cce37ed41bfb3d192d87280f4 100644 GIT binary patch delta 26 hcmaFQ^qy%#mw=(Jfw``MnSzm_m7%4!fziZSR{?IX2pIqX delta 26 hcmaFQ^qy%#mw\n" "Language-Team: LANGUAGE \n" @@ -16,28 +16,28 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: admin.py:53 +#: admin.py:55 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." msgstr "" -#: admin.py:77 +#: admin.py:81 msgid "Advanced" msgstr "" -#: admin.py:80 +#: admin.py:84 msgid "Date/time" msgstr "" -#: admin.py:98 +#: admin.py:100 #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "" msgstr[1] "" -#: admin.py:102 +#: admin.py:104 msgid "Invalidate cache of selected templates" msgstr "" @@ -52,34 +52,34 @@ msgstr[1] "" msgid "Repopulate cache with selected templates" msgstr "" -#: admin.py:119 models.py:29 +#: admin.py:120 models.py:25 msgid "sites" msgstr "" -#: models.py:26 +#: models.py:22 msgid "name" msgstr "" -#: models.py:27 +#: models.py:23 msgid "Example: 'flatpages/default.html'" msgstr "" -#: models.py:28 +#: models.py:24 msgid "content" msgstr "" -#: models.py:30 +#: models.py:27 msgid "creation date" msgstr "" -#: models.py:32 +#: models.py:29 msgid "last changed" msgstr "" -#: models.py:40 +#: models.py:37 msgid "template" msgstr "" -#: models.py:41 +#: models.py:38 msgid "templates" msgstr "" diff --git a/dbtemplates/locale/fi/LC_MESSAGES/django.mo b/dbtemplates/locale/fi/LC_MESSAGES/django.mo index 46ab68c26bd599b0ad00fbdc98901e693f9e997d..9b0d1921308e57b95661066187401d02cd084263 100644 GIT binary patch delta 970 zcma))&ubGw6vtm}Y9&&CK=Go&cqlZqo9ssL$7)ctdXR{rvV1!ciDf;w~5kjIv2RH)&l?8wi z^9J)ZbDvr4ubl)~VTQ~q^9A!g^AmHOd0`RY6!SiFiP>bHXFg+=nCi#(SIjc6N6gdA zcZ;xpaqi8D=j~pkJH~78kcWed-q(&dRrzGU7~>vYqbti*X>ky zOaJ=UtjYB-!HeGc$+doi$;4JTr3oIKL|Yknit#@ zK@isYoIg2NT3+7PsHGOS6I4pxwW*fQPVSW6j+^Y)MIBCkiRG4Z!$^4#%`mp1(1YpH zHtM&;ENrZ5ait-GN*S7H^DMHGT%TX?wA*I+I8q7+rprSRNuDW;9a=(RG(Va{r==`5 zDDC#7){@4QR$*mz*Emg;_MZff&o9#dS)1}KB}tV2>Y^yTeN5$_*8iH`$}{9PQ(KF$ zAHf5Qu^jfXZzmrYE{(TlJ?5E6B85bbJ3ed>d2wV!Rd{5q;7T!{@8ucW&9gky(@Eu7 z-{QL1nEqQrl10=aD#quOiiGB}N^zc1GU3V3ZecvThF(;trZkl+!fv73mwL9Ng=HhQ zxJ;Hf&{fzfPXDjzX(HtZpq$Z!gV{hJL5#0THZ5Z3ipe`*lL!_QXUPy8{wPO6g71DE BQwjh8 delta 727 zcmaKp&uddb5XYw`h8nOvDoABPN-b)dRy>$`uxRjCt)Ug~qun-}-M1UEvw>WUkb@Tw z$^%bcga@8H3H=B5FVKI+tFuYu6^g>!_t}~K&g{(Wr{%8~KYkf+F95u+04xDOtOD#a ze=+x%tLJBaVqRl=!dz#5V=Cs)xxHNjxWKk#vI`t@kr|kr3f|7`2{Y+FFzd|EHTZF5 z;oZ6A&d!5pJCEApReS&7$&0=Gd*xF8yRuThBQ`f%x3_LIxALpi%lT5ZcDHmjoAq7v zbnE2+tv5(+&=OA(wRYmMGoIu?-0RLZ_mx(;txm?Ut9&fbOA4BQaG-{v@47t{eWy5t zD2QP!jLHI={9yxDufK7@()ywBf7Sn!mnluUi)d749FtP^9~sZ8XW~vQ6qhve8>low z+pA0tv{o&#cEnxx@mTteLwSV3P@_wkS%XgM1;r4JqCjQYG%ib-H}_oW)UMFd62(F| zD`?d1#p0%T*h72lge0$&@R*^sD&xegIyDF$9eYM8m=98#SXkjDuhhOV@q|~=m`?t6 o(wr^pbX93Svq*|3V1lCnS#TQpX&@EAr^DdM(R4F?ymCkI2jkH6;{X5v diff --git a/dbtemplates/locale/fi/LC_MESSAGES/django.po b/dbtemplates/locale/fi/LC_MESSAGES/django.po index 42b66d6..40378a2 100644 --- a/dbtemplates/locale/fi/LC_MESSAGES/django.po +++ b/dbtemplates/locale/fi/LC_MESSAGES/django.po @@ -1,15 +1,15 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# +# +# Ville Säävuori , 2011. msgid "" msgstr "" "Project-Id-Version: django-dbtemplates\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: Jaakko Holster \n" -"POT-Creation-Date: 2011-01-31 11:10+0100\n" -"PO-Revision-Date: 2011-01-31 10:08+0000\n" +"Report-Msgid-Bugs-To: https://github.com/jezdez/django-dbtemplates/issues\n" +"POT-Creation-Date: 2010-11-07 00:02+0100\n" +"PO-Revision-Date: 2011-06-19 11:22+0000\n" +"Last-Translator: Uninen \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -22,8 +22,8 @@ msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." msgstr "" -"Mikäli kenttä on tyhjä, Django etsii samannimistä sivupohjaa ja täyttää " -"kentän sen sisällöllä." +"Jos tämä jätetään tyhjäksi, Django etsiin annetulla nimellä olevan " +"mallipohjan ja täyttää tähän kenttään sen sisällön." #: admin.py:77 msgid "Advanced" @@ -37,25 +37,25 @@ msgstr "Päiväys/aika" #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." -msgstr[0] "Sivupohja poistettu välimuistista." -msgstr[1] "%(count)d sivupohjaa poistettu välimuistista." +msgstr[0] "Yhden mallipohjan välimuisti on onnistuneesti tyhjennetty." +msgstr[1] "%(count)d mallipohjan välimusti on onnistuneesti tyhjennetty." #: admin.py:102 msgid "Invalidate cache of selected templates" -msgstr "Poista valitut sivupohjat välimuistista." +msgstr "Tyhjennä valittujen mallipohjien välimuisti." #: admin.py:111 #, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." -msgstr[0] "Sivupohja lisätty välimuistiin." -msgstr[1] "%(count)d sivupohjaa lisätty välimuistiin." +msgstr[0] "Yhden mallipohjan välimuisti on täytetty onnistuneesti." +msgstr[1] "%(count)d mallipohjan välimuisti on täytetty onnistuneesti." #: admin.py:115 msgid "Repopulate cache with selected templates" -msgstr "Lisää valitut sivupohjat välimuistiin." +msgstr "Täytä valittujen mallipohjien välimuisti." -#: admin.py:119 +#: admin.py:119 models.py:29 msgid "sites" msgstr "sivustot" @@ -65,24 +65,26 @@ msgstr "nimi" #: models.py:27 msgid "Example: 'flatpages/default.html'" -msgstr "Esimerkki: 'flatpages/default.html'" +msgstr "Esimerkiksi: 'flatpages/default.html'" #: models.py:28 msgid "content" -msgstr "sisältö" +msgstr "sisätö" #: models.py:30 msgid "creation date" -msgstr "luotu" +msgstr "luontipäivä" #: models.py:32 msgid "last changed" -msgstr "muokattu" +msgstr "viimeksi muutettu" #: models.py:40 msgid "template" -msgstr "sivupohja" +msgstr "mallipohja" #: models.py:41 msgid "templates" -msgstr "sivupohjat" +msgstr "mallipohjat" + + diff --git a/dbtemplates/locale/pt_BR/LC_MESSAGES/django.mo b/dbtemplates/locale/pt_BR/LC_MESSAGES/django.mo index 14e12f38c91d4fa89c2f91efa1bd8c654427f8eb..b01f0bc237aa2947bbe37821315158505026c43b 100644 GIT binary patch delta 699 zcmZvZF>ljA6vy49(AH3iqK*ugEg@Wd4hWE;6-^Nnh$xD>FraIEI2YMI<2yGfLJE9_ zh|j<$VD8YB0VGDmz`)X>LSm?jkoccN1_V!j{=K_<_kZu{KCHfSr(Z5Fzj0s};aA`< z;T!PJaBF1AaaO?^xCUMYYv2vA0QbNZ@IAN=egdu5S8y3T0ndRyK&x{GTAga8JexY} z2<*nM>YOXMRl|A%d<|X)?fE;&wR|RCv{GTbELS5jFxt!h zH>y6Qu{ij_dk>fU@+Eg+KgWA-Gm&cxHIB?98c85eh^grz%Nm0T zn1pjMgd1=a-oiNc+*395`W&!8^9?)MH`sz8U zj9uX!sWdGGzG%=w=m)eaJz|<8`0oriEOOCTjU57fW#7%pd zE`oo3S?XkI+9j@wKI){=x5olatBSRQCeu=Rq$qmam!$A;rvyA=b*3I}Bw23=tk=5v z6W)-Db(B2gb)AyR&tXX051G$tm9v&d3W{|_Q?NEE;~zpl, YEAR. -# +# +# Herson Hersonls , 2011. msgid "" msgstr "" "Project-Id-Version: django-dbtemplates\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: Diego Búrigo Zacarão \n" -"Language-Team: Brazilian Portuguese \n" -"POT-Creation-Date: 2011-01-31 11:10+0100\n" -"PO-Revision-Date: 2011-01-31 10:08+0000\n" +"Report-Msgid-Bugs-To: https://github.com/jezdez/django-dbtemplates/issues\n" +"POT-Creation-Date: 2010-11-07 00:02+0100\n" +"PO-Revision-Date: 2011-06-01 18:11+0000\n" +"Last-Translator: hersonls \n" +"Language-Team: Portuguese (Brazilian) (http://www.transifex.net/projects/p/django-dbtemplates/team/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -27,7 +27,7 @@ msgstr "" #: admin.py:77 msgid "Advanced" -msgstr "" +msgstr "Avançado" #: admin.py:80 msgid "Date/time" @@ -86,3 +86,5 @@ msgstr "modelo" #: models.py:41 msgid "templates" msgstr "modelos" + + diff --git a/dbtemplates/locale/zh_CN/LC_MESSAGES/django.mo b/dbtemplates/locale/zh_CN/LC_MESSAGES/django.mo index 88c9d3744d324cee2213833270ea093803cf30ea..0745c6f87831223a116aff43bed53960fe99b274 100644 GIT binary patch delta 452 zcmZwB&r1S96bJAbceOGjFc2Z4HOvf|m`Q?I@w62L{V>Q=plq#fitfs~d-0H`E*&Bm zI`lVm^w8fBbm$-GU+C7o@7hwA=JI*(&Aj*KcK$i_kRP`RAstFc7rw(eScwsmgZr=m zZ5Y6NScIxV$P8p~0q(#QG@uG=Fb?Z*7GA(`t_2%}WKaQsb6^IQEv&-7bEc|(uo z6U{IEb2oXVhcs<lbdKFHz$D7iZXtgRbE^oWNE10FU4+ zj33G&bsp}+_@JG5n#{e#AaRs9PDP3|i869l^?MEror|E`37wfK*QG|YQaz~b)!0d` zbzHX(m6j9u{g5{Xu6NFNhVFp3eTykgyUnY8rxSX9kMCmJVulbV*98|Q(+k#iQ4_{3 eU0KFJ=c35;l4TS$Q5GVa&gCPGj%V-Gmi_>_g+7D; diff --git a/dbtemplates/locale/zh_CN/LC_MESSAGES/django.po b/dbtemplates/locale/zh_CN/LC_MESSAGES/django.po index 1b9ec8e..4d5e93d 100644 --- a/dbtemplates/locale/zh_CN/LC_MESSAGES/django.po +++ b/dbtemplates/locale/zh_CN/LC_MESSAGES/django.po @@ -32,7 +32,7 @@ msgid "Date/time" msgstr "日期/时间" #: admin.py:98 -#, python-format +#, fuzzy, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "该模板的缓存已经成功撤销。" @@ -42,7 +42,7 @@ msgid "Invalidate cache of selected templates" msgstr "撤销选中模板的缓存" #: admin.py:111 -#, python-format +#, fuzzy, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "该模板的缓存已经成功启用。" diff --git a/docs/changelog.txt b/docs/changelog.txt index d3ffa28..7cd4a85 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -34,6 +34,8 @@ Changelog the file or database entry after syncing (depending on used ``--overwrite`` mode). +* Updated translations. + * Fixed issue with incorrectly splitting paths in ``sync_templates``. * Extended tests. From 99188bb92c899356906e15f6f78d4740a1e5e4fb Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 6 Jul 2011 21:25:17 +0200 Subject: [PATCH 023/103] Bumped version and copyright year. --- LICENSE | 2 +- dbtemplates/__init__.py | 2 +- docs/conf.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index 66200eb..0d17aff 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2007-2010, Jannis Leidel and contributors +Copyright (c) 2007-2011, Jannis Leidel and contributors All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index 7bba090..3d7f135 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,4 +1,4 @@ -VERSION = (1, 0, 1, "f", 0) # following PEP 386 +VERSION = (1, 1, 0, "f", 0) # following PEP 386 DEV_N = None diff --git a/docs/conf.py b/docs/conf.py index ee20d84..4b4c5c5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,16 +38,16 @@ master_doc = 'index' # General information about the project. project = u'django-dbtemplates' -copyright = u'2010, Jannis Leidel' +copyright = u'2007-2011, Jannis Leidel' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '1.0' +version = '1.1' # The full version, including alpha/beta/rc tags. -release = '1.0.1' +release = '1.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 0379c8cf39f93a53ea7cd93b0dcbc59418d7677a Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 8 Jul 2011 14:46:41 +0200 Subject: [PATCH 024/103] Fixed cache loading. Fixes #13. --- dbtemplates/tests.py | 5 +++++ dbtemplates/utils/cache.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index 32a03ee..8e0d7c2 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -4,6 +4,7 @@ import os import shutil import tempfile +from django.core.cache.backends.base import BaseCache from django.core.management import call_command from django.template import loader, Context from django.test import TestCase @@ -12,6 +13,7 @@ from django.contrib.sites.models import Site from dbtemplates.conf import settings from dbtemplates.models import Template +from dbtemplates.utils.cache import get_cache_backend from dbtemplates.utils.template import get_template_source from dbtemplates.management.commands.sync_templates import (FILES_TO_DATABASE, DATABASE_TO_FILES) @@ -91,3 +93,6 @@ class DbTemplatesTestCase(TestCase): temp_template.close() settings.TEMPLATE_DIRS = old_template_dirs shutil.rmtree(temp_template_dir) + + def test_get_cache(self): + self.assertTrue(isinstance(get_cache_backend(), BaseCache)) diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py index 611a490..65ac768 100644 --- a/dbtemplates/utils/cache.py +++ b/dbtemplates/utils/cache.py @@ -6,7 +6,7 @@ from dbtemplates.conf import settings def get_cache_backend(): - return get_cache(settings.CACHE_BACKEND) + return get_cache(settings.DBTEMPLATES_CACHE_BACKEND) cache = get_cache_backend() From 692a77725d43567cf0ba45b98d03b19aea8b86be Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 8 Jul 2011 14:52:58 +0200 Subject: [PATCH 025/103] Added links to the repo on Github. Fixes #10. --- README.rst | 4 ++++ docs/index.txt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.rst b/README.rst index f817195..3dd74ec 100644 --- a/README.rst +++ b/README.rst @@ -12,4 +12,8 @@ command, integrates with Django's caching system and the admin actions. Please see http://django-dbtemplates.readthedocs.org/ for more details. +The source code and issue tracker can be found on Github: + +https://github.com/jezdez/django-dbtemplates + .. _template loader: http://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types \ No newline at end of file diff --git a/docs/index.txt b/docs/index.txt index 06c5bb7..2b1336c 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -11,6 +11,10 @@ It also features optional support for :ref:`versioned storage ` and :ref:`django-admin command `, integrates with Django's :ref:`caching system ` and the :ref:`admin actions `. +Please see http://django-dbtemplates.readthedocs.org/ for more details. + +The source code and issue tracker can be found on Github: https://github.com/jezdez/django-dbtemplates + .. _template loader: http://docs.djangoproject.com/en/dev/ref/templates/api/#loading-templates Contents: From 7449de74830aea3045388cb9e289b4bd0401ed00 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 8 Jul 2011 14:56:24 +0200 Subject: [PATCH 026/103] Extended docs about using the Loader class instead of the previously available function. Fixes #11. --- docs/changelog.txt | 19 +++++++++++++++++-- docs/overview.txt | 4 ++-- runtests.py | 4 ++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 7cd4a85..5a78419 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,13 +1,28 @@ Changelog ========= +1.1.1 (07-08-11) +---------------- + +* Fixed bug in cache loading (again). + +* Fixed bugs in the documentation. + +.. note:: + + Since ``dbtemplates`` removed support for Django lower than 1.2 you + have to use the template loader class in the ``TEMPLATE_LOADERS`` + (``'dbtemplates.loader.Loader'``) and **not** the previosly included + function that ended with ``load_template_source``. + 1.1 (07-06-11) -------------- * **BACKWARDS-INCOMPATIBLE** Requires Django 1.2 or higher. - For previous Django versions use an older versions of dbtemplates, e.g.:: + For previous Django versions use an older versions of ``dbtemplates``, + e.g.:: - $ pip install django-dbtemplates<1.1 + $ pip install "django-dbtemplates<1.1" * Added South migrations. diff --git a/docs/overview.txt b/docs/overview.txt index 2465a3c..c1229f4 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -30,8 +30,8 @@ Setup It should look something like this:: TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', 'dbtemplates.loader.Loader', ) diff --git a/runtests.py b/runtests.py index e0d6ef6..68b0b6c 100644 --- a/runtests.py +++ b/runtests.py @@ -16,8 +16,8 @@ if not settings.configured: 'dbtemplates', ], TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', 'dbtemplates.loader.Loader', ) ) From 88f6c54c83505f5cbd723c842fad20269941bd70 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 8 Jul 2011 15:00:28 +0200 Subject: [PATCH 027/103] Bumped version up a bit. --- dbtemplates/__init__.py | 2 +- docs/conf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index 3d7f135..fcc819f 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,4 +1,4 @@ -VERSION = (1, 1, 0, "f", 0) # following PEP 386 +VERSION = (1, 1, 1, "f", 0) # following PEP 386 DEV_N = None diff --git a/docs/conf.py b/docs/conf.py index 4b4c5c5..9aa6f16 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,7 +47,7 @@ copyright = u'2007-2011, Jannis Leidel' # The short X.Y version. version = '1.1' # The full version, including alpha/beta/rc tags. -release = '1.1' +release = '1.1.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 6c25da5301941374f2ae5be422159931783c940d Mon Sep 17 00:00:00 2001 From: Matt Dorn Date: Tue, 2 Aug 2011 14:11:28 -0500 Subject: [PATCH 028/103] Added template syntax checker admin actions. --- dbtemplates/admin.py | 35 ++++++++++++++++--- .../commands/check_template_syntax.py | 20 +++++++++++ dbtemplates/tests.py | 11 +++++- dbtemplates/utils/template.py | 11 +++++- 4 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 dbtemplates/management/commands/check_template_syntax.py diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index e109003..69b826a 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -7,6 +7,7 @@ from django.utils.safestring import mark_safe from dbtemplates.conf import settings from dbtemplates.models import (Template, remove_cached_template, add_template_to_cache) +from dbtemplates.utils.template import check_template_syntax # Check if django-reversion is installed and use reversions' VersionAdmin # as the base admin class if yes @@ -91,30 +92,54 @@ class TemplateAdmin(TemplateModelAdmin): list_filter = ('sites',) save_as = True search_fields = ('name', 'content') - actions = ['invalidate_cache', 'repopulate_cache'] + actions = ['invalidate_cache', 'repopulate_cache', 'validate_syntax'] def invalidate_cache(self, request, queryset): for template in queryset: remove_cached_template(template) + count = queryset.count() message = ungettext( "Cache of one template successfully invalidated.", "Cache of %(count)d templates successfully invalidated.", - len(queryset)) - self.message_user(request, message % {'count': len(queryset)}) + count) + self.message_user(request, message % {'count': count}) invalidate_cache.short_description = _("Invalidate cache of " "selected templates") def repopulate_cache(self, request, queryset): for template in queryset: add_template_to_cache(template) + count = queryset.count() message = ungettext( "Cache successfully repopulated with one template.", "Cache successfully repopulated with %(count)d templates.", - len(queryset)) - self.message_user(request, message % {'count': len(queryset)}) + count) + self.message_user(request, message % {'count': count}) repopulate_cache.short_description = _("Repopulate cache with " "selected templates") + def validate_syntax(self, request, queryset): + errors = [] + for template in queryset: + valid, error = check_template_syntax(template) + if not valid: + errors.append('%s: %s' % (template.name, error)) + if errors: + count = len(errors) + message = ungettext( + "Template syntax check FAILED for %(names)s.", + "Template syntax check FAILED for %(count)d templates: %(names)s.", + count) + self.message_user(request, message % + {'count': count, 'names': ', '.join(errors)}) + else: + count = queryset.count() + message = ungettext( + "Template syntax OK.", + "Template syntax OK for %(count)d templates.", count) + self.message_user(request, message % {'count': count}) + validate_syntax.short_description = _("Check template syntax") + def site_list(self, template): return ", ".join([site.name for site in template.sites.all()]) site_list.short_description = _('sites') diff --git a/dbtemplates/management/commands/check_template_syntax.py b/dbtemplates/management/commands/check_template_syntax.py new file mode 100644 index 0000000..16d4ca2 --- /dev/null +++ b/dbtemplates/management/commands/check_template_syntax.py @@ -0,0 +1,20 @@ +from django.core.management.base import CommandError, NoArgsCommand + +from dbtemplates.models import Template +from dbtemplates.utils.template import check_template_syntax + +class Command(NoArgsCommand): + help = "Ensures templates stored in the database don't have syntax errors." + + def handle_noargs(self, **options): + errors = [] + for template in Template.objects.all(): + valid, error = check_template_syntax(template) + if not valid: + errors.append('%s: %s' % (template.name, error)) + if errors: + raise CommandError( + 'Some templates contained errors\n%s' % '\n'.join(errors)) + # NOTE: printing instead of using self.stdout.write to maintain + # Django 1.2 compatibility + print('OK') diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index 8e0d7c2..117b079 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -14,7 +14,8 @@ from django.contrib.sites.models import Site from dbtemplates.conf import settings from dbtemplates.models import Template from dbtemplates.utils.cache import get_cache_backend -from dbtemplates.utils.template import get_template_source +from dbtemplates.utils.template import (get_template_source, + check_template_syntax) from dbtemplates.management.commands.sync_templates import (FILES_TO_DATABASE, DATABASE_TO_FILES) @@ -96,3 +97,11 @@ class DbTemplatesTestCase(TestCase): def test_get_cache(self): self.assertTrue(isinstance(get_cache_backend(), BaseCache)) + + def test_check_template_syntax(self): + bad_template, _ = Template.objects.get_or_create( + name='bad.html', content='{% if foo %}Bar') + good_template, _ = Template.objects.get_or_create( + name='good.html', content='{% if foo %}Bar{% endif %}') + self.assertFalse(check_template_syntax(bad_template)) + self.assertTrue(check_template_syntax(good_template)) diff --git a/dbtemplates/utils/template.py b/dbtemplates/utils/template.py index f3b6f65..2113237 100644 --- a/dbtemplates/utils/template.py +++ b/dbtemplates/utils/template.py @@ -1,5 +1,6 @@ from django import VERSION -from django.template import TemplateDoesNotExist +from django.template import (Template, TemplateDoesNotExist, + TemplateSyntaxError) from django.utils.importlib import import_module @@ -48,3 +49,11 @@ def get_template_source(name): except (ImportError, TemplateDoesNotExist): pass return None + + +def check_template_syntax(template): + try: + Template(template.content) + except TemplateSyntaxError, e: + return (False, e) + return (True, None) From 2d46b418dac071833cf0480936285d9c8672568f Mon Sep 17 00:00:00 2001 From: Stephan Peijnik Date: Thu, 21 Jul 2011 15:19:20 +0200 Subject: [PATCH 029/103] Use the cache to remember which templates were not found in the database. Also reverse the logic of the database lookup. First check if there is site-specific template in the database and only if that fails try to load the global template. This should cut down the number of database queries that need to be executed, especially in a loop that includes a given template that does not exist in the database. Signed-off-by: Stephan Peijnik --- LICENSE | 29 ++++++++++++++++++++++++++++ dbtemplates/loader.py | 39 +++++++++++++++++++++++++++++++++++--- dbtemplates/utils/cache.py | 10 ++++++++++ 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 0d17aff..f06dc6f 100644 --- a/LICENSE +++ b/LICENSE @@ -28,6 +28,35 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Parts are (c) 2011 ANEXIA Internetdienstleistungs GmbH. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the author nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + This software includes CodeMirror released under the following license: diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index c5cc4a4..767a2e3 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -1,9 +1,13 @@ +# Parts of this file are (c) 2011 ANEXIA Internetdienstleistungs GmbH. +# For further copyrights and licensing information see the LICENSE +# file that was distributed with this file. from django.contrib.sites.models import Site from django.template import TemplateDoesNotExist from dbtemplates.conf import settings from dbtemplates.models import Template from dbtemplates.utils.cache import cache, get_cache_key, set_and_return +from dbtemplates.utils.cache import get_cache_notfound_key from django.template.loader import BaseLoader @@ -19,6 +23,18 @@ class Loader(BaseLoader): is_usable = True def load_template_source(self, template_name, template_dirs=None): + # The logic should work like this: + # * Try to find the template in the cache. If found, return it. + # * Now check the cache if a lookup for the given template + # has failed lately and hand over control to the next template + # loader waiting in line. + # * If this still did not fail we first try to find a site-specific + # template in the database. + # * On a failure from our last attempt we try to load the global + # template from the database. + # * If all of the above steps have failed we generate a new key + # in the cache indicating that queries failed, with the current + # timestamp. site = Site.objects.get_current() display_name = 'dbtemplates:%s:%s:%s' % (settings.DATABASE_ENGINE, template_name, site.domain) @@ -30,15 +46,32 @@ class Loader(BaseLoader): return backend_template, template_name except: pass + + # Not found in cache, move on. + cache_notfound_key = get_cache_notfound_key(template_name) + if cache: + try: + notfound = cache.get(cache_notfound_key) + if notfound: + raise TemplateDoesNotExist(template_name) + except: + raise TemplateDoesNotExist(template_name) + + # Not marked as not-found, move on... + try: - template = Template.objects.get(name__exact=template_name) + template = Template.objects.get(name__exact=template_name, + sites__in=[site.id]) return set_and_return(cache_key, template.content, display_name) - except (Template.MultipleObjectsReturned, Template.DoesNotExist): + except Template.DoesNotExist: try: template = Template.objects.get( - name__exact=template_name, sites__in=[site.id]) + name__exact=template_name) return set_and_return( cache_key, template.content, display_name) except Template.DoesNotExist: pass + + # Mark as not-found in cache. + cache.set(cache_notfound_key, '1') raise TemplateDoesNotExist(template_name) diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py index 65ac768..fa317ef 100644 --- a/dbtemplates/utils/cache.py +++ b/dbtemplates/utils/cache.py @@ -1,3 +1,6 @@ +# Parts of this file are (c) 2011 ANEXIA Internetdienstleistungs GmbH. +# For further copyrights and licensing information see the LICENSE +# file that was distributed with this file. from django.core.cache import get_cache from django.contrib.sites.models import Site @@ -15,6 +18,12 @@ def get_cache_key(name): current_site = Site.objects.get_current() return 'dbtemplates::%s::%s' % (name, current_site.pk) +def get_cache_notfound_key(name): + return get_cache_key(name)+'::notfound' + +def remove_notfound_key(instance): + # Remove notfound key as soon as we save the template. + cache.delete(get_cache_notfound_key(instance.name)) def set_and_return(cache_key, content, display_name): # Save in cache backend explicitly if manually deleted or invalidated @@ -29,6 +38,7 @@ def add_template_to_cache(instance, **kwargs): in the database was added or changed. """ remove_cached_template(instance) + remove_notfound_key(instance) cache.set(get_cache_key(instance.name), instance.content) From 7e93da6a94d6578b01867f4331a8f4416273d29e Mon Sep 17 00:00:00 2001 From: Stephan Peijnik Date: Mon, 25 Jul 2011 08:03:27 +0200 Subject: [PATCH 030/103] Removed license headers, reverted LICENSE file and added a CONTRIBUTORS file. --- CONTRIBUTORS | 3 +++ LICENSE | 29 ----------------------------- dbtemplates/loader.py | 3 --- dbtemplates/utils/cache.py | 3 --- 4 files changed, 3 insertions(+), 35 deletions(-) create mode 100644 CONTRIBUTORS diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..ead02c1 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,3 @@ +Author: Stephan Peijnik +ANEXIA Internetdienstleistungen GmbH +http://www.anexia.at/ diff --git a/LICENSE b/LICENSE index f06dc6f..0d17aff 100644 --- a/LICENSE +++ b/LICENSE @@ -28,35 +28,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Parts are (c) 2011 ANEXIA Internetdienstleistungs GmbH. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of the author nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - This software includes CodeMirror released under the following license: diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index 767a2e3..ae96036 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -1,6 +1,3 @@ -# Parts of this file are (c) 2011 ANEXIA Internetdienstleistungs GmbH. -# For further copyrights and licensing information see the LICENSE -# file that was distributed with this file. from django.contrib.sites.models import Site from django.template import TemplateDoesNotExist diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py index fa317ef..a97ad26 100644 --- a/dbtemplates/utils/cache.py +++ b/dbtemplates/utils/cache.py @@ -1,6 +1,3 @@ -# Parts of this file are (c) 2011 ANEXIA Internetdienstleistungs GmbH. -# For further copyrights and licensing information see the LICENSE -# file that was distributed with this file. from django.core.cache import get_cache from django.contrib.sites.models import Site From 49eb36775b25bb2b70a040a7f025b139161d06c4 Mon Sep 17 00:00:00 2001 From: Stephan Peijnik Date: Mon, 25 Jul 2011 08:07:25 +0200 Subject: [PATCH 031/103] Typo fix. Signed-off-by: Stephan Peijnik --- CONTRIBUTORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index ead02c1..615e70c 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,3 +1,3 @@ Author: Stephan Peijnik -ANEXIA Internetdienstleistungen GmbH +ANEXIA Internetdienstleistungs GmbH http://www.anexia.at/ From 09ece4a5e38dd46df4855bb081d6fd71e1c06114 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 15 Aug 2011 12:53:29 +0200 Subject: [PATCH 032/103] Some minor additions to the "performance speedup". Extends the list of authors, too. --- AUTHORS | 14 ++++++++++++++ CONTRIBUTORS | 3 --- dbtemplates/loader.py | 6 +++--- dbtemplates/utils/cache.py | 5 ++++- 4 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 AUTHORS delete mode 100644 CONTRIBUTORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..612aac1 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,14 @@ +Alen Mujezinovic +Alex Gaynor +Alex Kamedov +Alexander Artemenko +Arne Brodowski +David Paccoud +Diego Búrigo Zacarão +Jannis Leidel +Jason Mayfield +Kevin Mooney +Matt Dorn +Oliver George +Stephan Peijnik , ANEXIA Internetdienstleistungs GmbH, http://www.anexia.at/ +Zhang Kun diff --git a/CONTRIBUTORS b/CONTRIBUTORS deleted file mode 100644 index 615e70c..0000000 --- a/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -Author: Stephan Peijnik -ANEXIA Internetdienstleistungs GmbH -http://www.anexia.at/ diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index ae96036..a6070f2 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -23,7 +23,7 @@ class Loader(BaseLoader): # The logic should work like this: # * Try to find the template in the cache. If found, return it. # * Now check the cache if a lookup for the given template - # has failed lately and hand over control to the next template + # has failed lately and hand over control to the next template # loader waiting in line. # * If this still did not fail we first try to find a site-specific # template in the database. @@ -53,11 +53,11 @@ class Loader(BaseLoader): raise TemplateDoesNotExist(template_name) except: raise TemplateDoesNotExist(template_name) - + # Not marked as not-found, move on... try: - template = Template.objects.get(name__exact=template_name, + template = Template.objects.get(name__exact=template_name, sites__in=[site.id]) return set_and_return(cache_key, template.content, display_name) except Template.DoesNotExist: diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py index a97ad26..299647c 100644 --- a/dbtemplates/utils/cache.py +++ b/dbtemplates/utils/cache.py @@ -15,13 +15,16 @@ def get_cache_key(name): current_site = Site.objects.get_current() return 'dbtemplates::%s::%s' % (name, current_site.pk) + def get_cache_notfound_key(name): - return get_cache_key(name)+'::notfound' + return get_cache_key(name) + '::notfound' + def remove_notfound_key(instance): # Remove notfound key as soon as we save the template. cache.delete(get_cache_notfound_key(instance.name)) + def set_and_return(cache_key, content, display_name): # Save in cache backend explicitly if manually deleted or invalidated if cache: From ede4013fadd2987b179f373262c3aef734de2cb8 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 15 Aug 2011 13:05:26 +0200 Subject: [PATCH 033/103] Renamed admin action to be less ambiguous. --- dbtemplates/admin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 69b826a..efdfbcb 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -92,7 +92,7 @@ class TemplateAdmin(TemplateModelAdmin): list_filter = ('sites',) save_as = True search_fields = ('name', 'content') - actions = ['invalidate_cache', 'repopulate_cache', 'validate_syntax'] + actions = ['invalidate_cache', 'repopulate_cache', 'check_syntax'] def invalidate_cache(self, request, queryset): for template in queryset: @@ -118,7 +118,7 @@ class TemplateAdmin(TemplateModelAdmin): repopulate_cache.short_description = _("Repopulate cache with " "selected templates") - def validate_syntax(self, request, queryset): + def check_syntax(self, request, queryset): errors = [] for template in queryset: valid, error = check_template_syntax(template) @@ -138,7 +138,7 @@ class TemplateAdmin(TemplateModelAdmin): "Template syntax OK.", "Template syntax OK for %(count)d templates.", count) self.message_user(request, message % {'count': count}) - validate_syntax.short_description = _("Check template syntax") + check_syntax.short_description = _("Check template syntax") def site_list(self, template): return ", ".join([site.name for site in template.sites.all()]) From 52528648ba79ce7e1f350a1b2d6a8821cf7ce378 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 15 Aug 2011 13:05:34 +0200 Subject: [PATCH 034/103] Fixed tests. --- dbtemplates/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index 117b079..2e52587 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -103,5 +103,5 @@ class DbTemplatesTestCase(TestCase): name='bad.html', content='{% if foo %}Bar') good_template, _ = Template.objects.get_or_create( name='good.html', content='{% if foo %}Bar{% endif %}') - self.assertFalse(check_template_syntax(bad_template)) - self.assertTrue(check_template_syntax(good_template)) + self.assertFalse(check_template_syntax(bad_template)[0]) + self.assertTrue(check_template_syntax(good_template)[0]) From e55e52156f389b1c5c2d3f96e3fd767153beb0e8 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 15 Aug 2011 13:08:38 +0200 Subject: [PATCH 035/103] Slight corrections to loader. --- dbtemplates/loader.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index a6070f2..24e5010 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -3,8 +3,8 @@ from django.template import TemplateDoesNotExist from dbtemplates.conf import settings from dbtemplates.models import Template -from dbtemplates.utils.cache import cache, get_cache_key, set_and_return -from dbtemplates.utils.cache import get_cache_notfound_key +from dbtemplates.utils.cache import (cache, get_cache_key, + set_and_return, get_cache_notfound_key) from django.template.loader import BaseLoader @@ -60,12 +60,10 @@ class Loader(BaseLoader): template = Template.objects.get(name__exact=template_name, sites__in=[site.id]) return set_and_return(cache_key, template.content, display_name) - except Template.DoesNotExist: + except (Template.MultipleObjectsReturned, Template.DoesNotExist): try: - template = Template.objects.get( - name__exact=template_name) - return set_and_return( - cache_key, template.content, display_name) + template = Template.objects.get(name__exact=template_name) + return set_and_return(cache_key, template.content, display_name) except Template.DoesNotExist: pass From 6c08984118fa5c9d30d1a58981a73846ade45597 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 15 Aug 2011 13:08:46 +0200 Subject: [PATCH 036/103] Updated docs. --- docs/advanced.txt | 12 ++++++++++++ docs/changelog.txt | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/docs/advanced.txt b/docs/advanced.txt index bc30709..dc62866 100644 --- a/docs/advanced.txt +++ b/docs/advanced.txt @@ -82,6 +82,12 @@ Management commands Tries to add the two templates ``404.html`` and ``500.html`` that are used by Django when a error occurs. +* ``check_template_syntax`` + + .. versionadded:: 1.2 + + Checks the saved templates whether they are valid Django templates. + .. _Django management commands: http://docs.djangoproject.com/en/dev/ref/django-admin/ .. _admin_actions: @@ -101,4 +107,10 @@ Admin actions Repopulates the cache with selected templates by invalidating it first and filling then after that. +* ``check_syntax`` + + .. versionadded:: 1.2 + + Checks the selected tempaltes for syntax errors. + .. _admin actions: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/ diff --git a/docs/changelog.txt b/docs/changelog.txt index 5a78419..e71fc48 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,6 +1,14 @@ Changelog ========= +1.2 (08-15-11) +-------------- + +* Refactored the template loader to be even more cache effective. + +* Added ``check_template_syntax`` management command and admin action + to make sure the saved templates are valid Django templates. + 1.1.1 (07-08-11) ---------------- From bfcf68fe63e4c9cad2b9c62199ed5e8aff196ee3 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 15 Aug 2011 13:09:29 +0200 Subject: [PATCH 037/103] Bundle authors list. --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 4ce916b..8d620eb 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ include INSTALL include LICENSE +include AUTHORS include README.rst include MANIFEST.in recursive-include docs *.txt From f6ea762ed4bc1c97ea92e033821ef6f91668c4fa Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 15 Aug 2011 13:12:47 +0200 Subject: [PATCH 038/103] Bumped to 1.2 and extended Trove classifiers. --- dbtemplates/__init__.py | 2 +- docs/conf.py | 8 ++++---- setup.py | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index fcc819f..5a7cfda 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,4 +1,4 @@ -VERSION = (1, 1, 1, "f", 0) # following PEP 386 +VERSION = (1, 2, 0, "f", 0) # following PEP 386 DEV_N = None diff --git a/docs/conf.py b/docs/conf.py index 9aa6f16..0364d2b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,16 +38,16 @@ master_doc = 'index' # General information about the project. project = u'django-dbtemplates' -copyright = u'2007-2011, Jannis Leidel' +copyright = u'2007-2011, Jannis Leidel and contributors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '1.1' +version = '1.2' # The full version, including alpha/beta/rc tags. -release = '1.1.1' +release = '1.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -173,7 +173,7 @@ htmlhelp_basename = 'django-dbtemplatesdoc' # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'django-dbtemplates.tex', u'django-dbtemplates Documentation', - u'Jannis Leidel', 'manual'), + u'Jannis Leidel and contributors', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/setup.py b/setup.py index 6a82ee7..7ecb97b 100644 --- a/setup.py +++ b/setup.py @@ -18,12 +18,16 @@ setup( ], }, classifiers=[ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.5', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', 'Framework :: Django', ], ) From 362af384a6718ac1eff7fefd26fbd4973cd9040f Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 15 Aug 2011 13:13:37 +0200 Subject: [PATCH 039/103] Updated base translation files. --- dbtemplates/locale/en/LC_MESSAGES/django.mo | Bin 367 -> 378 bytes dbtemplates/locale/en/LC_MESSAGES/django.po | 37 +++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/dbtemplates/locale/en/LC_MESSAGES/django.mo b/dbtemplates/locale/en/LC_MESSAGES/django.mo index 503ba620ab7cb26cce37ed41bfb3d192d87280f4..da3c06a745ccb115a5e6a025199eeb10597427f9 100644 GIT binary patch delta 40 wcmaFQ^owbN3ZuhB)eJ5RT|-j^Lt`sL_#x3p2(5000UMC;$Ke delta 29 lcmeyx^qy&g3Zv;n)eJ6kT>~=(BSR}g%Zbx#C(AQN0|1C+2&4c2 diff --git a/dbtemplates/locale/en/LC_MESSAGES/django.po b/dbtemplates/locale/en/LC_MESSAGES/django.po index f06abb9..351a27a 100644 --- a/dbtemplates/locale/en/LC_MESSAGES/django.po +++ b/dbtemplates/locale/en/LC_MESSAGES/django.po @@ -8,51 +8,70 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-07-06 21:19+0200\n" +"POT-Creation-Date: 2011-08-15 13:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: admin.py:55 +#: admin.py:56 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." msgstr "" -#: admin.py:81 +#: admin.py:82 msgid "Advanced" msgstr "" -#: admin.py:84 +#: admin.py:85 msgid "Date/time" msgstr "" -#: admin.py:100 +#: admin.py:102 #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "" msgstr[1] "" -#: admin.py:104 +#: admin.py:106 msgid "Invalidate cache of selected templates" msgstr "" -#: admin.py:111 +#: admin.py:114 #, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "" msgstr[1] "" -#: admin.py:115 +#: admin.py:118 msgid "Repopulate cache with selected templates" msgstr "" -#: admin.py:120 models.py:25 +#: admin.py:130 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:138 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:141 +msgid "Check template syntax" +msgstr "" + +#: admin.py:145 models.py:25 msgid "sites" msgstr "" From e12c6e8ece2de2984362665e72fab031f10ec062 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 15 Aug 2011 13:23:48 +0200 Subject: [PATCH 040/103] Updated translations. --- dbtemplates/locale/da/LC_MESSAGES/django.mo | Bin 1060 -> 1171 bytes dbtemplates/locale/da/LC_MESSAGES/django.po | 66 +++++++++++------ dbtemplates/locale/de/LC_MESSAGES/django.mo | Bin 1883 -> 2439 bytes dbtemplates/locale/de/LC_MESSAGES/django.po | 70 ++++++++++++------ dbtemplates/locale/fi/LC_MESSAGES/django.mo | Bin 1937 -> 1940 bytes dbtemplates/locale/fi/LC_MESSAGES/django.po | 55 +++++++++----- dbtemplates/locale/fr/LC_MESSAGES/django.mo | Bin 789 -> 1742 bytes dbtemplates/locale/fr/LC_MESSAGES/django.po | 70 ++++++++++++------ dbtemplates/locale/he/LC_MESSAGES/django.mo | Bin 1009 -> 1163 bytes dbtemplates/locale/he/LC_MESSAGES/django.po | 64 ++++++++++------ dbtemplates/locale/it/LC_MESSAGES/django.mo | Bin 1030 -> 1106 bytes dbtemplates/locale/it/LC_MESSAGES/django.po | 65 +++++++++++----- .../locale/pt_BR/LC_MESSAGES/django.mo | Bin 1280 -> 1278 bytes .../locale/pt_BR/LC_MESSAGES/django.po | 55 +++++++++----- .../locale/zh_CN/LC_MESSAGES/django.mo | Bin 1579 -> 1283 bytes .../locale/zh_CN/LC_MESSAGES/django.po | 60 +++++++++------ 16 files changed, 336 insertions(+), 169 deletions(-) diff --git a/dbtemplates/locale/da/LC_MESSAGES/django.mo b/dbtemplates/locale/da/LC_MESSAGES/django.mo index 8acc5709e4503343b53914c11563e3ad037b7260..115a1f0040e90c8d9cb921b00dda99a8d4644daf 100644 GIT binary patch delta 360 zcmZY4KT88K6aetF6|4v1<{X_WCA~|lBGE$;anOpT*3BjD#cRqnx!%il=%S0@DBR>K zT^#)o4t^g;2cLhy!I0#a2QM!#^J=m5;4bGSLf&yz2_cUaLe|kI^bUPR7tzxNLRQcV zbQv9>ILQRJuY1#9Z%_~8`4)YjT&k8zp zE(PKHv3A3}-x%1jKT@+u&HVo*d<~E*C>rI}m~$5FFup~3OYl}bXa<4TIcHrp)u63m zNBE|o&EPMO3%*$oaCmJAj`cEW06VjppeNE84RjBiMh_CDBb79?xwge~`F6XFf5~Nx l^&;tYl01_MJGR*v1U2b*2w`)V{v5-ap=%-K8%3@1@d@L7V}Aeu delta 267 zcmbQtxrAdvNvJ6!1H%^}=3ro8&|+p_Py*7%K)Mx3hXHAJAbkf&^8@K8K$;gwe*w}g zK$;0ifb_9LX#pV31>{R^JZaBZAK>Wh?da~R5at>b?CI~v6_i?#UsR&&Tb!PmqU%(e zUaT9EZ>7K$;2)yvT$Gwvl9`{U>ylWKYNcRgU|^|hXrOCgsbFYqWn!vr02Bc#)D224 z%PdByi*$7i()IP%b#YYi@VD~y)Qy_0ad32T333e%p8SxhVe$;--v9!DJ;wk5 diff --git a/dbtemplates/locale/da/LC_MESSAGES/django.po b/dbtemplates/locale/da/LC_MESSAGES/django.po index e8e4e24..0a7cb9d 100644 --- a/dbtemplates/locale/da/LC_MESSAGES/django.po +++ b/dbtemplates/locale/da/LC_MESSAGES/django.po @@ -1,15 +1,14 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# Michael Lind Mortensen , 2009. -# +# msgid "" msgstr "" "Project-Id-Version: django-dbtemplates\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-10-09 13:45+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" +"Report-Msgid-Bugs-To: https://github.com/jezdez/django-dbtemplates/issues\n" +"POT-Creation-Date: 2011-08-15 13:13+0200\n" +"PO-Revision-Date: 2011-08-15 11:14+0000\n" +"Last-Translator: Jannis \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -17,72 +16,93 @@ msgstr "" "Language: da\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -#: admin.py:53 +#: admin.py:56 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." msgstr "" -"Hvis du efterlader dette felt tomt, så vil Django søge efter en template med " -"det givne navn og udfylde dette felt med dets indhold." +"Hvis du efterlader dette felt tomt, så vil Django søge efter en template med" +" det givne navn og udfylde dette felt med dets indhold." -#: admin.py:77 +#: admin.py:82 msgid "Advanced" msgstr "" -#: admin.py:80 +#: admin.py:85 msgid "Date/time" msgstr "Dato/tid" -#: admin.py:98 +#: admin.py:102 #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "" msgstr[1] "" -#: admin.py:102 +#: admin.py:106 msgid "Invalidate cache of selected templates" msgstr "" -#: admin.py:111 +#: admin.py:114 #, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "" msgstr[1] "" -#: admin.py:115 +#: admin.py:118 msgid "Repopulate cache with selected templates" msgstr "" -#: admin.py:119 models.py:29 +#: admin.py:130 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "" +"Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:138 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:141 +msgid "Check template syntax" +msgstr "" + +#: admin.py:145 models.py:25 msgid "sites" msgstr "websider" -#: models.py:26 +#: models.py:22 msgid "name" msgstr "navn" -#: models.py:27 +#: models.py:23 msgid "Example: 'flatpages/default.html'" msgstr "Eksempel: 'flatpages/default.html'" -#: models.py:28 +#: models.py:24 msgid "content" msgstr "indhold" -#: models.py:30 +#: models.py:27 msgid "creation date" msgstr "oprettelsesdato" -#: models.py:32 +#: models.py:29 msgid "last changed" msgstr "sidst ændret" -#: models.py:40 +#: models.py:37 msgid "template" msgstr "skabelon" -#: models.py:41 +#: models.py:38 msgid "templates" msgstr "skabeloner" + + diff --git a/dbtemplates/locale/de/LC_MESSAGES/django.mo b/dbtemplates/locale/de/LC_MESSAGES/django.mo index cfc7ba0438de61faf768f8a8817352a67c89c930..50f7fd5468833daffb14b5c4dbcd3a252391e43f 100644 GIT binary patch delta 1114 zcmZ{h&rcIU6vwAfK&zrc@JEDXYJ#?sZM)#FtfDl~g1P~OVl*)(+jiP6w6k?*mI%f) zp7iYE&3NMA89nx(a`Wa{gC6`3{0IC_g~~5q_RVK!=FRuLdGoFFMR#qZEBKngy5YU> z5AZ&?8NdMh2p#}Gfd%jjI1lPAg!F)Kz=Pl#7zXR$IdB8?z_wOGBH&Z-Cb$Zg!Cznp zAvJP0NXQW^JOB@aMGzm67}~%kP!&)ERic;RDvEdop2GY}J0Xw3Y0w8hgX$vppssWU zs0w-xszTm@E8tg9Lw-_#`ZyL=Kqd4Yga(;JHvEz~P$hnZ0XaztRQnZB?Mo0Jd4>UX zHBBW~T~(LZGIhc2);WUNAvn6#ur7=$35p{jIJ(pjKMJa3$KfjZF?hp#FYu#hw8U}? zRI*C7Y)MAN5|`E!f41fKh0M-1I&~*T_O8)_22)&C$y!Ou zsxad5qAg2aHkNZL@p-nKXUp-u2jaF69uuMIsf;$dsjiKoH3l6_=(?7;s_B=gK4j=a z1Bt;z0)g5LTeJnL*e6am^oxB130TOqgw!&w#RWR;xCXs#ac&F0KiJ=GCMU<|lH)0Q z-84tacFb{${zCBKWfS-DtRj-t8x1+MRaz;j8i`Oul!dHe)a+_@6ZB9l zz2pzr_SRbuy_>(Ge?t$29(waC-n{soRZAZ``?1z$qN>6`~K{-~g`TL)^xc5NATON%O!* z(^DZOkwIjM^k?mQ}h=l zHYVZKUBb#;LIvq>rc4HeB!;+~0_L6jFoT#s_<&`aFmn>-OZgH1Vvt>qMQIw=+HU;Q z`W2t|T*j5urdBg^xef0qXh!mVSl2cAx>XNlH7MG-^|h*8YI<&@179w?kyo^5m7}EN zNL8?vDk^81vm#M$cx@g2pQjcim$PU)g`#8f;!65SrtImOcNia}C-U!H-`Ami`@}Bo zC&!nENy3cw_k#F)di(JQxgK~m9m%rm*IRC#8Qyx$hU<6dGkL2U_T{a3HM@8NFN#}6 diff --git a/dbtemplates/locale/de/LC_MESSAGES/django.po b/dbtemplates/locale/de/LC_MESSAGES/django.po index f41a7d7..f146836 100644 --- a/dbtemplates/locale/de/LC_MESSAGES/django.po +++ b/dbtemplates/locale/de/LC_MESSAGES/django.po @@ -1,19 +1,23 @@ -# +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Jannis Leidel , 2011. msgid "" msgstr "" "Project-Id-Version: django-dbtemplates\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-11-07 00:01+0100\n" -"PO-Revision-Date: 2008-08-19 17:11+0100\n" -"Last-Translator: Jannis Leidel \n" -"Language-Team: Jannis Leidel \n" +"Report-Msgid-Bugs-To: https://github.com/jezdez/django-dbtemplates/issues\n" +"POT-Creation-Date: 2011-08-15 13:13+0200\n" +"PO-Revision-Date: 2011-08-15 11:14+0000\n" +"Last-Translator: Jannis \n" +"Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -#: admin.py:53 +#: admin.py:56 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." @@ -21,66 +25,86 @@ msgstr "" "Wenn Sie dieses Feld leer lassen, wird Django versuchen, das Template mit " "dem angegebenen Namen zu finden und mit dessen Inhalt das Feld zu füllen." -#: admin.py:77 +#: admin.py:82 msgid "Advanced" msgstr "Erweiterte Einstellungen" -#: admin.py:80 +#: admin.py:85 msgid "Date/time" msgstr "Datum/Uhrzeit" -#: admin.py:98 +#: admin.py:102 #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "Der Cache eines Templates wurde erfolgreich geleert." msgstr[1] "Der Cache von %(count)d Templates wurde erfolgreich geleert." -#: admin.py:102 +#: admin.py:106 msgid "Invalidate cache of selected templates" msgstr "Cache der ausgewählten Templates leeren" -#: admin.py:111 +#: admin.py:114 #, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." -msgstr[0] "" -"Der Cache eines Templates wurde erfolgreich geleert und neu gefüllt." +msgstr[0] "Der Cache eines Templates wurde erfolgreich geleert und neu gefüllt." msgstr[1] "" "Der Cache von %(count)d Templates wurde erfolgreich geleert und neu gefüllt." -#: admin.py:115 +#: admin.py:118 msgid "Repopulate cache with selected templates" msgstr "Cache der ausgewählten Templates neu füllen" -#: admin.py:119 models.py:29 +#: admin.py:130 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "" +"Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "Template-Syntax von %(names)s ist FEHLERHAFT." +msgstr[1] "Template-Syntax von %(count)d Templates (%(names)s) ist FEHLERHAFT." + +#: admin.py:138 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "Template-Syntax ist OK." +msgstr[1] "Template-Syntax von %(count)d Templates ist OK." + +#: admin.py:141 +msgid "Check template syntax" +msgstr "Template-Syntax überprüfen" + +#: admin.py:145 models.py:25 msgid "sites" msgstr "Seiten" -#: models.py:26 +#: models.py:22 msgid "name" msgstr "Name" -#: models.py:27 +#: models.py:23 msgid "Example: 'flatpages/default.html'" msgstr "Zum Beispiel: 'flatpages/default.html'" -#: models.py:28 +#: models.py:24 msgid "content" msgstr "Inhalt" -#: models.py:30 +#: models.py:27 msgid "creation date" msgstr "Erstellt" -#: models.py:32 +#: models.py:29 msgid "last changed" msgstr "Geändert" -#: models.py:40 +#: models.py:37 msgid "template" msgstr "Template" -#: models.py:41 +#: models.py:38 msgid "templates" msgstr "Templates" + + diff --git a/dbtemplates/locale/fi/LC_MESSAGES/django.mo b/dbtemplates/locale/fi/LC_MESSAGES/django.mo index 9b0d1921308e57b95661066187401d02cd084263..cf23e9aa7a184032f31e3b96b5e75a8af10066cb 100644 GIT binary patch delta 225 zcmbQpKZSq7ocbk<3=Hke3=Dh>3=BG~3=CC3+8Rig1L-k(4M_6>X@4Ls2&7|yGz*Z=&C-mY znFI`V4J>pGO%)7{tqhH|4U8tsu}E7(L=3GAO|%VwfXgSbxI{OkC^4@%C$S{I$V$O0 fF)uH(SivR>OgrSHW~QX(=w;@m%zQD6oDnSmy0 delta 222 zcmXZRI}gE790l-ywH~Q>Ef$H~#UOR%UV}$tkXSpim~^P5Nppo;gvEprVYK)R{b;^` zBXO2r&NxpW-v-geBq|b7Gfi}WeYk@O{OwMLr~zHrhI4p^SJ;BpEKv@QVF7xu z0%y>I(f?mT8~p(D@RX&bW_(g*!KLJ)$AoZ2#}V>Tw`%<^mjfoH+rfg^p08s*S^G*y ee!N_}Y^p*PC^p=NQ51~yUIiQ7UW7?(G4l%uG$ktl diff --git a/dbtemplates/locale/fi/LC_MESSAGES/django.po b/dbtemplates/locale/fi/LC_MESSAGES/django.po index 40378a2..2a486b4 100644 --- a/dbtemplates/locale/fi/LC_MESSAGES/django.po +++ b/dbtemplates/locale/fi/LC_MESSAGES/django.po @@ -7,9 +7,9 @@ msgid "" msgstr "" "Project-Id-Version: django-dbtemplates\n" "Report-Msgid-Bugs-To: https://github.com/jezdez/django-dbtemplates/issues\n" -"POT-Creation-Date: 2010-11-07 00:02+0100\n" -"PO-Revision-Date: 2011-06-19 11:22+0000\n" -"Last-Translator: Uninen \n" +"POT-Creation-Date: 2011-08-15 13:13+0200\n" +"PO-Revision-Date: 2011-08-15 11:14+0000\n" +"Last-Translator: Jannis \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -17,7 +17,7 @@ msgstr "" "Language: fi\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -#: admin.py:53 +#: admin.py:56 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." @@ -25,65 +25,84 @@ msgstr "" "Jos tämä jätetään tyhjäksi, Django etsiin annetulla nimellä olevan " "mallipohjan ja täyttää tähän kenttään sen sisällön." -#: admin.py:77 +#: admin.py:82 msgid "Advanced" msgstr "Lisäasetukset" -#: admin.py:80 +#: admin.py:85 msgid "Date/time" msgstr "Päiväys/aika" -#: admin.py:98 +#: admin.py:102 #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "Yhden mallipohjan välimuisti on onnistuneesti tyhjennetty." msgstr[1] "%(count)d mallipohjan välimusti on onnistuneesti tyhjennetty." -#: admin.py:102 +#: admin.py:106 msgid "Invalidate cache of selected templates" msgstr "Tyhjennä valittujen mallipohjien välimuisti." -#: admin.py:111 +#: admin.py:114 #, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "Yhden mallipohjan välimuisti on täytetty onnistuneesti." msgstr[1] "%(count)d mallipohjan välimuisti on täytetty onnistuneesti." -#: admin.py:115 +#: admin.py:118 msgid "Repopulate cache with selected templates" msgstr "Täytä valittujen mallipohjien välimuisti." -#: admin.py:119 models.py:29 +#: admin.py:130 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "" +"Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:138 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:141 +msgid "Check template syntax" +msgstr "" + +#: admin.py:145 models.py:25 msgid "sites" msgstr "sivustot" -#: models.py:26 +#: models.py:22 msgid "name" msgstr "nimi" -#: models.py:27 +#: models.py:23 msgid "Example: 'flatpages/default.html'" msgstr "Esimerkiksi: 'flatpages/default.html'" -#: models.py:28 +#: models.py:24 msgid "content" msgstr "sisätö" -#: models.py:30 +#: models.py:27 msgid "creation date" msgstr "luontipäivä" -#: models.py:32 +#: models.py:29 msgid "last changed" msgstr "viimeksi muutettu" -#: models.py:40 +#: models.py:37 msgid "template" msgstr "mallipohja" -#: models.py:41 +#: models.py:38 msgid "templates" msgstr "mallipohjat" diff --git a/dbtemplates/locale/fr/LC_MESSAGES/django.mo b/dbtemplates/locale/fr/LC_MESSAGES/django.mo index 5b975da8c1af834fb385f6f88da144149ecf3de8..c52b05e266a223f014f9fd0fd5b3176a266f1530 100644 GIT binary patch literal 1742 zcma)+&u`pB6vqb$zm@_b7cLwgNRU*;yX%yq$Z4XMbXx^&AS#<)I60oT-U;^1YG%AN zIdS5G)Dzs1xO6XEIB?>$;?7@y_*3|f*WOSyq8-WmvAu8Je7|qz`S10$p9IF+xZcC{ zBd&LGU3mdN7!z;|D)1Ei3w#~ic~OY>!2$RYn1dDg2;2nMUJ~L}FaqBMZ-7_8eQ*st z0$&D?!PmgA!H`#izhDgwev0RH1O*;|9q>Ew1Mmkh27d(|_)qgZdS$up_uxBt{|H_onp^ohczJn*E zhVe9;FqttK&E&b97O7`)RhF@H09L|Pbg>?`u`c1Xy}SN$k_9$WHES{!Vf33F~%~}G-ub7JWi{^cPG9qHpIco z8f9%E92cAgQEfGx7;-vOIwwC-j!+|ihVaUYJ+> zYtm`Slxj(>@nyoX;-V>m@{Tg2J!{_;_g4jK#MM>0L|!vPWR_E}jHa+xqDY;mYyy2O zMOa!m<=KhW*6PNIBWq6KIXaNh1GWw+5|XvENS?Iut`h`VA04_}$>_5xchSfsH1U4w zl3p*z9#$va%#^)TK9_vndpbo=Iajgk9DO;8_8YZP*sz4Q`f(ifx1;z5#n+Sg`nCR6 zzmLG^KF?H;bV*#C#GhR2V|0cv8;xwL9d_E-gg#HT#%A4w3-DIKN^;RvdTjO(tn&(| zAsTU7CN#YL#l7R(_Xc!xIJ{M;uCe)E=kVZga8Zo7+wbfz_az#gO(ECwL*GNQD7_Pk zY#saEgd%;&Fk~M2op!%-bHtT{`2eZp6i7*A>s0W;tljpPp7X(S$1- zx+r`Vn4YJN>cdyHLeU?MPJ9{`^UziZ(2KbfUn!cI$`K0a9G_Fh8Qx%z=;OAhf;P6{ zO6k9jgFnd8rX*QsBlcv2Muo@>WtyPvn>wHwmfcZ>eyYuKiS8o#JSv;1BJ>kMTV@yY Zy2FHIs}rbTOB{0p0F2rU2r literal 789 zcma)4%Wl*#6m?;Eg@Q!ccHwU5qH>zFMVbi@A<9&$#E8)-AQo)g_)aD$u}8LNRDOXy zJ3fFe`G(oRnk5oHfLQSZ9M40;4z6-?V*B3X`^b;2)&~Z=4r~K&fSbTaAlMgR2lxtH z1AYRxfZxC-u(82d3w#?KH12|LfVaW#fqTFX)}Jpe;=h6KVErAu1^xxT3=XfL-vS4n zO)x^|dso51!hSG>%q`p-Vy}c%_gpsPnlipStfe2zlH9(cp`6q{9{Hx;Wrfk6v}c7S z=_{kTlAc&Co#(|!>XH=GvLWUPLg8rj;aK0Aw^Vp>s>Ca@4#62u;-hFlV`IJOxw2B? z>7;ZbHyMxmFLH6byhS{NRK^dIq$AQqBpsd}W=Hq;670ZH3}{*f!L?soBzQXfAk7Xt zdr1nv=SWiIR%(aDjLrDK)KV*cVrLg>c44c6KO9<8gs<4n&z>yGoD#~Ok}XLW6ra&! zXz6l-_K2Khll?8R6#Z|d-f6G9?nfFY(ea|iB7ZkV&7RKvK3ZAn2cg5(k$?0uKN0P< zUnprvR&;e?RHe&|x6djcy%v2#s`6r$Y{(N8j3UfAjOX8Tp0F@pu80?C(tO|y{m~WK U<+z*hGicMW#;Dn+npW)CA7EJ6vj6}9 diff --git a/dbtemplates/locale/fr/LC_MESSAGES/django.po b/dbtemplates/locale/fr/LC_MESSAGES/django.po index b2b23f7..d177520 100644 --- a/dbtemplates/locale/fr/LC_MESSAGES/django.po +++ b/dbtemplates/locale/fr/LC_MESSAGES/django.po @@ -1,21 +1,22 @@ -# Roland Frédéric , 2009. -# +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. # msgid "" msgstr "" "Project-Id-Version: django-dbtemplates\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: David Paccoud \n" -"Language-Team: French\n" -"POT-Creation-Date: 2011-01-31 11:10+0100\n" -"PO-Revision-Date: 2011-01-31 10:08+0000\n" +"Report-Msgid-Bugs-To: https://github.com/jezdez/django-dbtemplates/issues\n" +"POT-Creation-Date: 2011-08-15 13:13+0200\n" +"PO-Revision-Date: 2011-08-15 11:14+0000\n" +"Last-Translator: Jannis \n" +"Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1)\n" -#: admin.py:53 +#: admin.py:56 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." @@ -23,64 +24,85 @@ msgstr "" "Si vous laissez ceci vide , Django recherchera un modèle avec le nom donné " "et remplira ce champ avec son contenu." -#: admin.py:77 +#: admin.py:82 msgid "Advanced" msgstr "" -#: admin.py:80 +#: admin.py:85 msgid "Date/time" msgstr "Date/heure" -#: admin.py:98 -#, python-format +#: admin.py:102 +#, fuzzy, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "Le cache d'un modèle a été invalidé avec succès." msgstr[1] "" -#: admin.py:102 +#: admin.py:106 msgid "Invalidate cache of selected templates" msgstr "Invalidation du cache des modèles sélectionnés" -#: admin.py:111 -#, python-format +#: admin.py:114 +#, fuzzy, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "Le cache d'un modèle a été rechargé avec succès." msgstr[1] "" -#: admin.py:115 +#: admin.py:118 msgid "Repopulate cache with selected templates" msgstr "Rechargement du cache des modèles sélectionnés" -#: admin.py:119 models.py:29 +#: admin.py:130 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "" +"Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:138 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:141 +msgid "Check template syntax" +msgstr "" + +#: admin.py:145 models.py:25 msgid "sites" msgstr "sites" -#: models.py:26 +#: models.py:22 msgid "name" msgstr "nom" -#: models.py:27 +#: models.py:23 msgid "Example: 'flatpages/default.html'" msgstr "Exemple : 'flatpages/default.html'" -#: models.py:28 +#: models.py:24 msgid "content" msgstr "contenu" -#: models.py:30 +#: models.py:27 msgid "creation date" msgstr "date de création" -#: models.py:32 +#: models.py:29 msgid "last changed" msgstr "dernier changement" -#: models.py:40 +#: models.py:37 msgid "template" msgstr "modèle" -#: models.py:41 +#: models.py:38 msgid "templates" msgstr "modèles" + + diff --git a/dbtemplates/locale/he/LC_MESSAGES/django.mo b/dbtemplates/locale/he/LC_MESSAGES/django.mo index 857a7df0d3b5c2c05321c1f8316394eb4dfcb39d..7bf392cf0672ac310451d5c0ccc96b1ef979abb0 100644 GIT binary patch delta 399 zcmZY4F-rq66bJCM7SvNG!8wA1QgU}`Rpe|-ThxM{T1wSHm$VnJDR;?n$vJe;58xtn za@N(sui@x75xNRKwBle$^2>ui$;-#={rrPDf6gH^fwhbfdYnOM4SWF=_zup2%>qIT z;L+3z5GLxwW`TpL8eD|>w($B^%UuOSCPPJnp5bv4F~hah;fYEOIo6>FNHYsH=_(Ho zj7hZTIH53utY`OC>H3-WvV<9J9 z&SDSyjg!_{qqVe;E52WkgssxBHh#)qZvO`1PuyxpS;``Epwd`-SSH`4u9kN3&#}5L N@oE**jqzuG@&#vuZ_)q& delta 262 zcmeC?{K!6`B#euZf#C}f3o|e<{AXfdPyy1y%nS_qK-vOGa{%cTK$;s!Z-ml&fiw${ ze-cP@0qJv4`X-R(0rHsy?jnWF1d znqI6Ml5eHJ72qGD>s*wYSdy8ar|Xhfl4_-3WME*aYiOWrV5wkeY-M7qZ2%MjD%1^1 zEz2xMQD>oRV4-Vds9eCwkJJ; diff --git a/dbtemplates/locale/he/LC_MESSAGES/django.po b/dbtemplates/locale/he/LC_MESSAGES/django.po index 273a20d..cfab377 100644 --- a/dbtemplates/locale/he/LC_MESSAGES/django.po +++ b/dbtemplates/locale/he/LC_MESSAGES/django.po @@ -1,86 +1,106 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# +# msgid "" msgstr "" "Project-Id-Version: django-dbtemplates\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" -"Language-Team: \n" -"POT-Creation-Date: 2011-01-31 11:10+0100\n" -"PO-Revision-Date: 2011-01-31 10:08+0000\n" +"Report-Msgid-Bugs-To: https://github.com/jezdez/django-dbtemplates/issues\n" +"POT-Creation-Date: 2011-08-15 13:13+0200\n" +"PO-Revision-Date: 2011-08-15 11:14+0000\n" +"Last-Translator: Jannis \n" +"Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: he\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -#: admin.py:53 +#: admin.py:56 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." msgstr "אם זה ריק אז ג'נגו מחפש תבנית עם שם סיפק וממלא את השדה עם תוכנו" -#: admin.py:77 +#: admin.py:82 msgid "Advanced" msgstr "" -#: admin.py:80 +#: admin.py:85 msgid "Date/time" msgstr "תאריך / זמן" -#: admin.py:98 +#: admin.py:102 #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "" msgstr[1] "" -#: admin.py:102 +#: admin.py:106 msgid "Invalidate cache of selected templates" msgstr "" -#: admin.py:111 +#: admin.py:114 #, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "" msgstr[1] "" -#: admin.py:115 +#: admin.py:118 msgid "Repopulate cache with selected templates" msgstr "" -#: admin.py:119 models.py:29 +#: admin.py:130 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "" +"Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:138 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:141 +msgid "Check template syntax" +msgstr "" + +#: admin.py:145 models.py:25 msgid "sites" msgstr "אתרים" -#: models.py:26 +#: models.py:22 msgid "name" msgstr "שם" -#: models.py:27 +#: models.py:23 msgid "Example: 'flatpages/default.html'" msgstr "דוגמא: 'flatpages/default.html'" -#: models.py:28 +#: models.py:24 msgid "content" msgstr "תוכן" -#: models.py:30 +#: models.py:27 msgid "creation date" msgstr "נוצר ב" -#: models.py:32 +#: models.py:29 msgid "last changed" msgstr "שונה ב" -#: models.py:40 +#: models.py:37 msgid "template" msgstr "תבנית" -#: models.py:41 +#: models.py:38 msgid "templates" msgstr "תבניות" + + diff --git a/dbtemplates/locale/it/LC_MESSAGES/django.mo b/dbtemplates/locale/it/LC_MESSAGES/django.mo index 407043464c2e8e4e6f3f8c5d92be9c08cc314765..a3534ee71e8475008aa1d82700defdf67d2a0ba2 100644 GIT binary patch delta 384 zcmZwCJxc>I7zgn5WvJCf5l2b4N=+|mRV00(^`%8QwUjytE>|yJQ|^-El5?non{%Py zCvb8T{3L!I7ax3?6q5WB`19w zl8&o4I&!9B=8Kv0x5AOeq|h|D7?Hz7cvfmfj-Z_58fA>oeZqDzt8=zpuh1H$kR(HK zC(Zvs#@SAV(gn+|w@*E#q`^&?8|;Ka`Xa1Kb*tM&7ygoZfgmH{MI5``^ZsSGe~g>1 y+X-b=C&A(=d%gD?<5=3_AWRc4Bt4x(hGP|fJx#0Dz~9$aS>aL(v#rH)?&A}p#%nJC delta 323 zcmZ9@u}T9$5C-6lXAuJy+S$ljhdKAoh-3*8q9{m0LO3vm&6rz{mAhTp-Pqb$2l5tn zf)8M0V`=R>*w~5S5VWxvzWIlL-s<=Dd44jfG4@2W!x&qS7@L#37^@rW0t|eibLh38X0(iA)cgBB5R%eSplN@g)Z9Bp=|=O)c*!r+KGB+AnGC z78U9;p4#e=UQ98=LP4gmlKc#f(Vq8}&Q-}f*UQ)~moe7n$}V13F198xvMSdB{=OwY MRjxv_IFG)50FKXDQ~&?~ diff --git a/dbtemplates/locale/it/LC_MESSAGES/django.po b/dbtemplates/locale/it/LC_MESSAGES/django.po index fb58eaf..37effcb 100644 --- a/dbtemplates/locale/it/LC_MESSAGES/django.po +++ b/dbtemplates/locale/it/LC_MESSAGES/django.po @@ -1,18 +1,22 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# msgid "" msgstr "" "Project-Id-Version: django-dbtemplates\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: Marco Beri \n" -"Language-Team: Jannis Leidel \n" -"POT-Creation-Date: 2011-01-31 11:10+0100\n" -"PO-Revision-Date: 2011-01-31 10:08+0000\n" +"Report-Msgid-Bugs-To: https://github.com/jezdez/django-dbtemplates/issues\n" +"POT-Creation-Date: 2011-08-15 13:13+0200\n" +"PO-Revision-Date: 2011-08-15 11:14+0000\n" +"Last-Translator: Jannis \n" +"Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: it\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -#: admin.py:53 +#: admin.py:56 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." @@ -20,64 +24,85 @@ msgstr "" "Lasciandolo vuoto, Django cercherà un template con lo stesso nome che avete " "indicato sopra e userà il suo contenuto per riempire questo campo." -#: admin.py:77 +#: admin.py:82 msgid "Advanced" msgstr "" -#: admin.py:80 +#: admin.py:85 msgid "Date/time" msgstr "" -#: admin.py:98 +#: admin.py:102 #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "" msgstr[1] "" -#: admin.py:102 +#: admin.py:106 msgid "Invalidate cache of selected templates" msgstr "" -#: admin.py:111 +#: admin.py:114 #, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "" msgstr[1] "" -#: admin.py:115 +#: admin.py:118 msgid "Repopulate cache with selected templates" msgstr "" -#: admin.py:119 models.py:29 +#: admin.py:130 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "" +"Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:138 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:141 +msgid "Check template syntax" +msgstr "" + +#: admin.py:145 models.py:25 msgid "sites" msgstr "" -#: models.py:26 +#: models.py:22 msgid "name" msgstr "nome" -#: models.py:27 +#: models.py:23 msgid "Example: 'flatpages/default.html'" msgstr "Esempio: 'flatpages/default.html'" -#: models.py:28 +#: models.py:24 msgid "content" msgstr "contenuto" -#: models.py:30 +#: models.py:27 msgid "creation date" msgstr "data di creazione" -#: models.py:32 +#: models.py:29 msgid "last changed" msgstr "ultimo cambiamento" -#: models.py:40 +#: models.py:37 msgid "template" msgstr "template" -#: models.py:41 +#: models.py:38 msgid "templates" msgstr "template" + + diff --git a/dbtemplates/locale/pt_BR/LC_MESSAGES/django.mo b/dbtemplates/locale/pt_BR/LC_MESSAGES/django.mo index b01f0bc237aa2947bbe37821315158505026c43b..335fbb6df6230ee4733f494e1118e6859b16d804 100644 GIT binary patch delta 212 zcmZqR`o}q;CiX2O0|PG;0|O@m1H*4-2+hjEz@P}^^8@KdAZ-YwLGqh{v>=e)3#3JW z^m!l+L<~=W1S^n!38dM8^m`!94y3# YvcR-MPHJXKYK~rJURwU=e)52Qta z^hF>IL=4Y>1S^n!4W!wC^hY4g4y1om#LOJM\n" +"POT-Creation-Date: 2011-08-15 13:13+0200\n" +"PO-Revision-Date: 2011-08-15 11:14+0000\n" +"Last-Translator: Jannis \n" "Language-Team: Portuguese (Brazilian) (http://www.transifex.net/projects/p/django-dbtemplates/team/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -17,7 +17,7 @@ msgstr "" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1)\n" -#: admin.py:53 +#: admin.py:56 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." @@ -25,65 +25,84 @@ msgstr "" "Manter isto vazio faz com que o Django procure por um modelo (template) com " "o dado nome e preencha este campo com o seu conteúdo" -#: admin.py:77 +#: admin.py:82 msgid "Advanced" msgstr "Avançado" -#: admin.py:80 +#: admin.py:85 msgid "Date/time" msgstr "Data/hora" -#: admin.py:98 +#: admin.py:102 #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "" msgstr[1] "" -#: admin.py:102 +#: admin.py:106 msgid "Invalidate cache of selected templates" msgstr "" -#: admin.py:111 +#: admin.py:114 #, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "" msgstr[1] "" -#: admin.py:115 +#: admin.py:118 msgid "Repopulate cache with selected templates" msgstr "" -#: admin.py:119 models.py:29 +#: admin.py:130 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "" +"Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:138 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:141 +msgid "Check template syntax" +msgstr "" + +#: admin.py:145 models.py:25 msgid "sites" msgstr "sites" -#: models.py:26 +#: models.py:22 msgid "name" msgstr "Name" -#: models.py:27 +#: models.py:23 msgid "Example: 'flatpages/default.html'" msgstr "Exemplo: 'flatpages/default.html'" -#: models.py:28 +#: models.py:24 msgid "content" msgstr "conteúdo" -#: models.py:30 +#: models.py:27 msgid "creation date" msgstr "Data de criação" -#: models.py:32 +#: models.py:29 msgid "last changed" msgstr "ultima modificação" -#: models.py:40 +#: models.py:37 msgid "template" msgstr "modelo" -#: models.py:41 +#: models.py:38 msgid "templates" msgstr "modelos" diff --git a/dbtemplates/locale/zh_CN/LC_MESSAGES/django.mo b/dbtemplates/locale/zh_CN/LC_MESSAGES/django.mo index 0745c6f87831223a116aff43bed53960fe99b274..e510bcc4bbd089990be6d030c5ae89ac1b1eb0f5 100644 GIT binary patch delta 479 zcmXZXzfZzI6bJBvtv@Ob;)p}h#2A~SJy4^S7!!?ynka^e#G%*|N}$Ewv9K`6Um$UJ zaC78;aPuE!{QN_Jt&9JaC!wU!5rL% z6?h5r@Ci=C7bqLNCcY*6ABkUy--*8vZ62OxTJd+pcP{tHe zzF_R6Z&S6V5MAzAR>K#~UcGP~cB~fbd#rDHEjMU{#H$O|>9$?LxaD)+V_d&Duad)v zxxx_S YMlX2KX1>ST1wXh6_eUG*cto_ne|79j$^ZZW delta 778 zcmajb&ubGw6bJB0y7fnl20ZAY3e%#s5;p88il$Nut+zs|Bqu>wcPGi(bT(#pE%uUP zODP^~X;KJ6X$vhBL<;8Mp#}c|5B>vsk=^LUTTeaccVZF|N_;T$**s?6dz1Od+i3ag zd1Z|tVpx~3s#q7Xq9JUEJj_B1K82s*X*e7vq#xdggD?j@_!J%I4$kPX<0~x18^Aj!N>3coP~0rPw)i%31!2> zmSH4iKGyO=(=s8KTZtW1I7Yn*u=G5^FgF8;vD->Q(OFY*LmZ`hkO#HoYb;z(i;a)e}*SPcF zYyXrj@uFSy(2tvR#&YwW5k_RL-KqPPV}?l7wa~LrCNiNru9`0C!a+H^l%)Q_W>8zC z_h$3D$W3`-bcR2<%WfwOdwL`?nM$i;C9b=cE!1)JPtqG2W2(l~n~XA+WLjKfm7{Q9 z>`z8ZYIouqqVlk(p8CGG6YOpU>mM6$78(Z?|6R@h@V>FX94xK)uQr0!?H|>-Z*wn6 R_jCTrUZc8;a}`DT^&2AMzu^D? diff --git a/dbtemplates/locale/zh_CN/LC_MESSAGES/django.po b/dbtemplates/locale/zh_CN/LC_MESSAGES/django.po index 4d5e93d..f46a6d2 100644 --- a/dbtemplates/locale/zh_CN/LC_MESSAGES/django.po +++ b/dbtemplates/locale/zh_CN/LC_MESSAGES/django.po @@ -1,15 +1,14 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# +# msgid "" msgstr "" "Project-Id-Version: django-dbtemplates\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: 张昆 \n" -"POT-Creation-Date: 2011-01-31 11:10+0100\n" -"PO-Revision-Date: 2011-01-31 10:08+0000\n" +"Report-Msgid-Bugs-To: https://github.com/jezdez/django-dbtemplates/issues\n" +"POT-Creation-Date: 2011-08-15 13:13+0200\n" +"PO-Revision-Date: 2011-08-15 11:14+0000\n" +"Last-Translator: Jannis \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -17,68 +16,87 @@ msgstr "" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0\n" -#: admin.py:53 +#: admin.py:56 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." msgstr "此项目留空将使系统用指定的名称寻找模板并应用到该项目。" -#: admin.py:77 +#: admin.py:82 msgid "Advanced" msgstr "" -#: admin.py:80 +#: admin.py:85 msgid "Date/time" msgstr "日期/时间" -#: admin.py:98 +#: admin.py:102 #, fuzzy, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "该模板的缓存已经成功撤销。" -#: admin.py:102 +#: admin.py:106 msgid "Invalidate cache of selected templates" msgstr "撤销选中模板的缓存" -#: admin.py:111 +#: admin.py:114 #, fuzzy, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "该模板的缓存已经成功启用。" -#: admin.py:115 +#: admin.py:118 msgid "Repopulate cache with selected templates" msgstr "重新启用选中模板的缓存" -#: admin.py:119 models.py:29 +#: admin.py:130 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "" +"Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "" + +#: admin.py:138 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "" + +#: admin.py:141 +msgid "Check template syntax" +msgstr "" + +#: admin.py:145 models.py:25 msgid "sites" msgstr "站点" -#: models.py:26 +#: models.py:22 msgid "name" msgstr "名称" -#: models.py:27 +#: models.py:23 msgid "Example: 'flatpages/default.html'" msgstr "例如: 'flatpages/default.html'" -#: models.py:28 +#: models.py:24 msgid "content" msgstr "内容" -#: models.py:30 +#: models.py:27 msgid "creation date" msgstr "创建日期" -#: models.py:32 +#: models.py:29 msgid "last changed" msgstr "最新变更" -#: models.py:40 +#: models.py:37 msgid "template" msgstr "模板" -#: models.py:41 +#: models.py:38 msgid "templates" msgstr "模板" + + From 9e81e53099abeef499d0fe38e713803a5a269cba Mon Sep 17 00:00:00 2001 From: dfalk Date: Fri, 26 Aug 2011 01:28:49 +0400 Subject: [PATCH 041/103] using ugettext --- dbtemplates/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbtemplates/models.py b/dbtemplates/models.py index 88eb386..c8bb3d6 100644 --- a/dbtemplates/models.py +++ b/dbtemplates/models.py @@ -4,7 +4,7 @@ from datetime import datetime from django.db import models from django.db.models import signals from django.template import TemplateDoesNotExist -from django.utils.translation import gettext_lazy as _ +from django.utils.translation import ugettext_lazy as _ from django.contrib.sites.models import Site from django.contrib.sites.managers import CurrentSiteManager @@ -22,7 +22,7 @@ class Template(models.Model): name = models.CharField(_('name'), max_length=100, help_text=_("Example: 'flatpages/default.html'")) content = models.TextField(_('content'), blank=True) - sites = models.ManyToManyField(Site, verbose_name=_('sites'), + sites = models.ManyToManyField(Site, verbose_name=_(u'sites'), blank=True, null=True) creation_date = models.DateTimeField(_('creation date'), default=datetime.now) From fcc90458290b032ccd2bde792154b15c7adb1e19 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 5 Sep 2011 11:02:55 +0200 Subject: [PATCH 042/103] Fixed changelog and added bugfix to it. --- docs/changelog.txt | 125 ++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index e71fc48..e503f9a 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,16 +1,23 @@ Changelog ========= -1.2 (08-15-11) --------------- +v1.2.1 (2011-09-05) +------------------- + +* Fixed a wrong use of the non-lazy localization tools. + +* Fixed bugs in the documentation. + +v1.2 (2011-08-15) +----------------- * Refactored the template loader to be even more cache effective. * Added ``check_template_syntax`` management command and admin action to make sure the saved templates are valid Django templates. -1.1.1 (07-08-11) ----------------- +v1.1.1 (2011-07-08) +------------------- * Fixed bug in cache loading (again). @@ -23,8 +30,8 @@ Changelog (``'dbtemplates.loader.Loader'``) and **not** the previosly included function that ended with ``load_template_source``. -1.1 (07-06-11) --------------- +v1.1 (2011-07-06) +----------------- * **BACKWARDS-INCOMPATIBLE** Requires Django 1.2 or higher. For previous Django versions use an older versions of ``dbtemplates``, @@ -65,13 +72,13 @@ Changelog * Fixed issue with cache settings handling. -1.0.1 (04-14-11) ----------------- +v1.0.1 (2011-04-14) +------------------- * Minor bugfixes with regard to the new cache handling. -1.0 (04-11-11) --------------- +v1.0 (2011-04-11) +----------------- .. warning:: This is the first stable release of django-dbtemplates which comes with a @@ -94,33 +101,33 @@ Changelog * Use ReadTheDocs for documentation hosting. -0.8.0 (11-07-10) ----------------- +v0.8.0 (2010-11-07) +------------------- * Added Finnish translation (by jholster) * Added --overwrite and --app-first options to sync_templates command (by Alex Kamedov). -0.7.4 (09-23-10) ----------------- +v0.7.4 (2010-09-23) +------------------- * Fixed tests. -0.7.3 (09-21-10) ----------------- +v0.7.3 (2010-09-21) +------------------- * Added ``DBTEMPLATES_AUTO_POPULATE_CONTENT`` setting to be able to disable to auto-populating of template content. * Fixed cosmetic issue in admin with collapsable fields. -0.7.2 (09-04-10) ----------------- +v0.7.2 (2010-09-04) +------------------- * Moved to Github again. Sigh. -0.7.1 (07-07-10) ----------------- +v0.7.1 (2010-07-07) +------------------- * Fixed problem with the CodeMirror textarea, which wasn't completely disabled before. @@ -132,8 +139,8 @@ Changelog and have the CodeMirror textarea enabled, dbtemplates will look in a subdirectory of your site's ``MEDIA_ROOT`` for the CodeMirror media files. -0.7.0 (06-24-10) ----------------- +v0.7.0 (2010-06-24) +------------------- * Added CodeMirror_-based syntax highlighting textarea, based on the amaxing work_ by `Nic Pottier`_. Set the ``DBTEMPLATES_USE_CODEMIRROR`` setting @@ -154,14 +161,14 @@ Changelog .. _work: https://gist.github.com/368758/86bcafe53c438e2e2a0e3442c3b30f2c6011fbba .. _`Nic Pottier`: http://github.com/nicpottier -0.6.1 (10-19-09): ------------------ +v0.6.1 (2009-10-19) +------------------- * Fixed issue with default site of a template, added ability to disable default site (``DBTEMPLATES_ADD_DEFAULT_SITE``). -0.6.0 (10-09-09): ------------------ +v0.6.0 (2009-10-09) +------------------- * Updated and added locales (Danish, Brazilian Portuguese) @@ -171,8 +178,8 @@ Changelog * Added Sphinx documentation -0.5.7 ------ +v0.5.7 +------ * Updates to the docs @@ -186,8 +193,8 @@ Changelog * fixed bug in ``create_error_template`` command. -0.5.4 ------ +v0.5.4 +------ * Made loader and cache backends site-aware. @@ -199,16 +206,16 @@ Changelog * Template is now saved explicitly to backend if not existent in cache (e.g. if deleted manually or invalidated). -0.5.3 ------ +v0.5.3 +------ -* Removed automatic creation of 404.html and 500.html templates and added a +* Removed automatic creation of 404.html and 50v0.html templates and added a new management command for those cases called ``create_error_templates`` * Also reverted move to Bitbucket -0.5.2 ------ +v0.5.2 +------ * Fixed a problem with ``django.contrib.sites`` when its table hasn't been populated yet on initialization of dbtemplates. Thanks for the report, @@ -216,8 +223,8 @@ Changelog * Added an example Django project and docs for it -0.5.1 ------ +v0.5.1 +------ * Removed unneeded code that registered the model with reversion. @@ -228,8 +235,8 @@ Changelog * Removed legacy ``sync_templates.py`` script, use ``django-admin.py sync_templates`` from now on. -0.5.0 ------ +v0.5.0 +------ * Added support for `django-reversion`_ @@ -246,60 +253,60 @@ Changelog .. _django-reversion: http://code.google.com/p/django-reversion/ .. _blog post: http://jannisleidel.com/2008/11/updates-to-django-dbtemplates-and-half-assed-promise/ -0.4.7 ------ +v0.4.7 +------ * Minor bugfix -0.4.6 ------ +v0.4.6 +------ * Minor doc change and PyPI support -0.4.5 ------ +v0.4.5 +------ * fixed the --force option of the sync_templates command -0.4.4 ------ +v0.4.4 +------ * fixed error in custom model save() after changes in Django `r8670`_. .. _r8670: http://code.djangoproject.com/changeset/8670 -0.4.3 ------ +v0.4.3 +------ * removed oldforms code -0.4.2 ------ +v0.4.2 +------ * added Hebrew translation (by mkriheli) -0.4.1 ------ +v0.4.1 +------ * added French (by Roland Frederic) and German locale -0.4.0 ------ +v0.4.0 +------ * adds better support for newforms-admin * don't forget to load the dbtemplates.admin, e.g. by using django.contrib.admin.autodiscover() in you urls.py -0.3.1 ------ +v0.3.1 +------ * adds a new management command *sync_templates* for bidirectional syncing between filesystem and database (backwards-compatible) and FilesystemCaching (thanks, Arne Brodowski!) -0.2.5 ------ +v0.2.5 +------ * adds support for newforms-admin From d5be3e42d5ea5e2ea97e8b490a70996abe45ad34 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Tue, 6 Sep 2011 12:31:28 +0200 Subject: [PATCH 043/103] Use django-appconf. --- dbtemplates/__init__.py | 18 +----- dbtemplates/conf.py | 17 +++--- dbtemplates/utils/settings.py | 106 ---------------------------------- setup.py | 1 + 4 files changed, 11 insertions(+), 131 deletions(-) delete mode 100644 dbtemplates/utils/settings.py diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index 5a7cfda..458270e 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,16 +1,2 @@ -VERSION = (1, 2, 0, "f", 0) # following PEP 386 -DEV_N = None - - -def get_version(): - version = "%s.%s" % (VERSION[0], VERSION[1]) - if VERSION[2]: - version = "%s.%s" % (version, VERSION[2]) - if VERSION[3] != "f": - version = "%s%s%s" % (version, VERSION[3], VERSION[4]) - if DEV_N: - version = "%s.dev%s" % (version, DEV_N) - return version - - -__version__ = get_version() +# following PEP 386, versiontools will pick it up +__version__ = (1, 2, 1, "final", 0) \ No newline at end of file diff --git a/dbtemplates/conf.py b/dbtemplates/conf.py index f245983..e1075a2 100644 --- a/dbtemplates/conf.py +++ b/dbtemplates/conf.py @@ -1,11 +1,12 @@ import posixpath from django.core.exceptions import ImproperlyConfigured +from django.conf import settings -from dbtemplates.utils.settings import AppSettings +from appconf import AppConf -class DbTemplatesSettings(AppSettings): +class DbTemplatesConf(AppConf): USE_CODEMIRROR = False USE_REVERSION = False ADD_DEFAULT_SITE = True @@ -15,16 +16,16 @@ class DbTemplatesSettings(AppSettings): def configure_media_prefix(self, value): if value is None: - base_url = getattr(self, "STATIC_URL", None) + base_url = getattr(settings, "STATIC_URL", None) if base_url is None: - base_url = self.MEDIA_URL + base_url = settings.MEDIA_URL value = posixpath.join(base_url, "dbtemplates/") return value def configure_cache_backend(self, value): # If we are on Django 1.3 AND using the new CACHES setting.. - if hasattr(self, "CACHES"): - if "dbtemplates" in self.CACHES: + if hasattr(settings, "CACHES"): + if "dbtemplates" in settings.CACHES: return "dbtemplates" else: return "default" @@ -35,9 +36,7 @@ class DbTemplatesSettings(AppSettings): return value def configure_use_reversion(self, value): - if value and 'reversion' not in self.INSTALLED_APPS: + if value and 'reversion' not in settings.INSTALLED_APPS: raise ImproperlyConfigured("Please add 'reversion' to your " "INSTALLED_APPS setting to make use of it in dbtemplates.") return value - -settings = DbTemplatesSettings("DBTEMPLATES") diff --git a/dbtemplates/utils/settings.py b/dbtemplates/utils/settings.py deleted file mode 100644 index 0431888..0000000 --- a/dbtemplates/utils/settings.py +++ /dev/null @@ -1,106 +0,0 @@ -from inspect import getmembers -from django.conf import settings - - -class AppSettings(object): - """ - An app setting object to be used for handling app setting defaults - gracefully and providing a nice API for them. Say you have an app - called ``myapp`` and want to define a few defaults, and refer to the - defaults easily in the apps code. Add a ``settings.py`` to your app:: - - from path.to.utils import AppSettings - - class MyAppSettings(AppSettings): - SETTING_1 = "one" - SETTING_2 = ( - "two", - ) - - Then initialize the setting with the correct prefix in the location of - of your choice, e.g. ``conf.py`` of the app module:: - - settings = MyAppSettings(prefix="MYAPP") - - The ``MyAppSettings`` instance will automatically look at Django's - global setting to determine each of the settings and respect the - provided ``prefix``. E.g. adding this to your site's ``settings.py`` - will set the ``SETTING_1`` setting accordingly:: - - MYAPP_SETTING_1 = "uno" - - Usage - ----- - - Instead of using ``from django.conf import settings`` as you would - usually do, you can switch to using your apps own settings module - to access the app settings:: - - from myapp.conf import settings - - print myapp_settings.MYAPP_SETTING_1 - - ``AppSettings`` instances also work as pass-throughs for other - global settings that aren't related to the app. For example the - following code is perfectly valid:: - - from myapp.conf import settings - - if "myapp" in settings.INSTALLED_APPS: - print "yay, myapp is installed!" - - Custom handling - --------------- - - Each of the settings can be individually configured with callbacks. - For example, in case a value of a setting depends on other settings - or other dependencies. The following example sets one setting to a - different value depending on a global setting:: - - from django.conf import settings - - class MyCustomAppSettings(AppSettings): - ENABLED = True - - def configure_enabled(self, value): - return value and not self.DEBUG - - custom_settings = MyCustomAppSettings("MYAPP") - - The value of ``custom_settings.MYAPP_ENABLED`` will vary depending on the - value of the global ``DEBUG`` setting. - - Each of the app settings can be customized by providing - a method ``configure_`` that takes the default - value as defined in the class attributes as the only parameter. - The method needs to return the value to be use for the setting in - question. - """ - def __dir__(self): - return sorted(list(set(self.__dict__.keys() + dir(settings)))) - - __members__ = lambda self: self.__dir__() - - def __getattr__(self, name): - if name.startswith(self._prefix): - raise AttributeError("%r object has no attribute %r" % - (self.__class__.__name__, name)) - return getattr(settings, name) - - def __setattr__(self, name, value): - super(AppSettings, self).__setattr__(name, value) - if name in dir(settings): - setattr(settings, name, value) - - def __init__(self, prefix): - super(AppSettings, self).__setattr__('_prefix', prefix) - for setting, class_value in getmembers(self.__class__): - if setting == setting.upper(): - prefixed = "%s_%s" % (prefix.upper(), setting.upper()) - configured_value = getattr(settings, prefixed, class_value) - callback_name = "configure_%s" % setting.lower() - callback = getattr(self, callback_name, None) - if callable(callback): - configured_value = callback(configured_value) - delattr(self.__class__, setting) - setattr(self, prefixed, configured_value) diff --git a/setup.py b/setup.py index 7ecb97b..37bb161 100644 --- a/setup.py +++ b/setup.py @@ -30,4 +30,5 @@ setup( 'Programming Language :: Python :: 2.7', 'Framework :: Django', ], + install_requires=['django-appconf >= 0.4'], ) From 1224ab4005a4dd6833a177dcf7b2a87df5bb718b Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Tue, 6 Sep 2011 12:31:56 +0200 Subject: [PATCH 044/103] Added versiontools requirement to setup.py. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 37bb161..00e15f7 100644 --- a/setup.py +++ b/setup.py @@ -31,4 +31,5 @@ setup( 'Framework :: Django', ], install_requires=['django-appconf >= 0.4'], + setup_requires=['versiontools >= 1.5'], ) From b6d5bfa2269be62a394c45605e0bfe4504b4a0a3 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Tue, 6 Sep 2011 12:32:24 +0200 Subject: [PATCH 045/103] Use better testrunner. --- .gitignore | 5 ++++- dbtemplates/__init__.py | 2 +- dbtemplates/test_settings.py | 18 ++++++++++++++++++ runtests.py | 37 ------------------------------------ setup.py | 8 ++++++-- tox.ini | 16 +++++++++++++--- 6 files changed, 42 insertions(+), 44 deletions(-) create mode 100644 dbtemplates/test_settings.py delete mode 100644 runtests.py diff --git a/.gitignore b/.gitignore index 341cafe..cb3f83e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,7 @@ dist example/example.db docs/_build .tox/ -*.egg/ \ No newline at end of file +*.egg/ +pep8.txt +coverage.xml +.coverage \ No newline at end of file diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index 458270e..e16f115 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,2 +1,2 @@ # following PEP 386, versiontools will pick it up -__version__ = (1, 2, 1, "final", 0) \ No newline at end of file +__version__ = (1, 2, 1, "final", 0) diff --git a/dbtemplates/test_settings.py b/dbtemplates/test_settings.py new file mode 100644 index 0000000..4b46789 --- /dev/null +++ b/dbtemplates/test_settings.py @@ -0,0 +1,18 @@ +DBTEMPLATES_CACHE_BACKEND = 'dummy://' + +DATABASE_ENGINE = 'sqlite3' + +SITE_ID = 1 + +INSTALLED_APPS = [ + 'django.contrib.contenttypes', + 'django.contrib.sites', + 'django.contrib.admin', + 'dbtemplates', +] + +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + 'dbtemplates.loader.Loader', +) diff --git a/runtests.py b/runtests.py deleted file mode 100644 index 68b0b6c..0000000 --- a/runtests.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -import os -import sys - -from django.conf import settings - -if not settings.configured: - settings.configure( - DBTEMPLATES_CACHE_BACKEND = 'dummy://', - DATABASE_ENGINE='sqlite3', - SITE_ID=1, - INSTALLED_APPS=[ - 'django.contrib.contenttypes', - 'django.contrib.sites', - 'django.contrib.admin', - 'dbtemplates', - ], - TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - 'dbtemplates.loader.Loader', - ) - ) - -from django.test.simple import run_tests - - -def runtests(*test_args): - if not test_args: - test_args = ['dbtemplates'] - sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'dbtemplates')) - failures = run_tests(test_args, verbosity=1, interactive=True) - sys.exit(failures) - - -if __name__ == '__main__': - runtests(*sys.argv[1:]) diff --git a/setup.py b/setup.py index 00e15f7..be12e1f 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,14 @@ +import codecs +from os import path from setuptools import setup, find_packages +read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read() + setup( name='django-dbtemplates', - version=__import__('dbtemplates').__version__, + version=':versiontools:dbtemplates:', description='Template loader for templates stored in the database', - long_description=open('README.rst').read(), + long_description=read(path.join(path.dirname(__file__), 'README.rst')), author='Jannis Leidel', author_email='jannis@leidel.info', url='http://django-dbtemplates.readthedocs.org/', diff --git a/tox.ini b/tox.ini index 5ab7af1..66f3dc6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,41 +1,51 @@ [tox] -downloadcache = .tox/_download/ -distribute = False +distribute = false envlist = py25-1.2.X, py26-1.2.X, py27-1.2.X, py25-1.3.X, py26-1.3.X, py27-1.3.X [testenv] +downloadcache = {toxworkdir}/_download/ commands = - python runtests.py + {envbindir}/coverage erase + {envbindir}/coverage run --branch --source=dbtemplates {envbindir}/django-admin.py test {posargs:dbtemplates} --settings=dbtemplates.test_settings + {envbindir}/coverage report --omit=*test* + {envbindir}/coverage html --omit=*test* -d {envtmpdir} + echo "Type the following to open the coverage report: python -m webbrowser -t file://{envtmpdir}/index.html" [testenv:py25-1.2.X] basepython = python2.5 deps = + coverage django==1.2.5 [testenv:py26-1.2.X] basepython = python2.6 deps = + coverage django==1.2.5 [testenv:py27-1.2.X] basepython = python2.7 deps = + coverage django==1.2.5 [testenv:py25-1.3.X] basepython = python2.5 deps = + coverage django==1.3 [testenv:py26-1.3.X] basepython = python2.6 deps = + coverage django==1.3 [testenv:py27-1.3.X] basepython = python2.7 deps = + coverage django==1.3 From 41842de12d69b225fba25189bfb05abaae6bc3d4 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 7 Sep 2011 12:05:09 +0200 Subject: [PATCH 046/103] Bumped version to 1.2.1. --- docs/changelog.txt | 4 +++- docs/conf.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index e503f9a..9271c6e 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,13 +1,15 @@ Changelog ========= -v1.2.1 (2011-09-05) +v1.2.1 (2011-09-07) ------------------- * Fixed a wrong use of the non-lazy localization tools. * Fixed bugs in the documentation. +* Make use of django-appconf and versiontools. + v1.2 (2011-08-15) ----------------- diff --git a/docs/conf.py b/docs/conf.py index 0364d2b..98092ec 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,7 +47,7 @@ copyright = u'2007-2011, Jannis Leidel and contributors' # The short X.Y version. version = '1.2' # The full version, including alpha/beta/rc tags. -release = '1.2' +release = '1.2.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From fcca3742e0af15b78eb0db72a46575cf739c5f46 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sun, 8 Jan 2012 23:59:34 +0100 Subject: [PATCH 047/103] Minor cleanup in docs. --- docs/settings.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/settings.txt b/docs/settings.txt index 3494c14..c541d2c 100644 --- a/docs/settings.txt +++ b/docs/settings.txt @@ -4,8 +4,8 @@ Settings ``DBTEMPLATES_ADD_DEFAULT_SITE`` -------------------------------- -``dbtemplates`` adds the current site (``settings.SITE_ID``) to the database -template when it is created by default. You can disable this feature by +``dbtemplates`` adds the current site (``settings.SITE_ID``) to the database +template when it is created by default. You can disable this feature by setting ``DBTEMPLATES_ADD_DEFAULT_SITE`` to ``False``. ``DBTEMPLATES_AUTO_POPULATE_CONTENT`` From 65684c1243282b80debcb87ab6a7f71de08854ba Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sun, 8 Jan 2012 23:59:52 +0100 Subject: [PATCH 048/103] Use latest versiontools. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index be12e1f..34f9e8d 100644 --- a/setup.py +++ b/setup.py @@ -35,5 +35,5 @@ setup( 'Framework :: Django', ], install_requires=['django-appconf >= 0.4'], - setup_requires=['versiontools >= 1.5'], + setup_requires=['versiontools >= 1.8.2'], ) From 9cc07437ee9f06f2d663c916d2aa21af3881c418 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 9 Jan 2012 00:00:10 +0100 Subject: [PATCH 049/103] Updated year. --- LICENSE | 2 +- docs/conf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 0d17aff..00c83fd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2007-2011, Jannis Leidel and contributors +Copyright (c) 2007-2012, Jannis Leidel and contributors All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/docs/conf.py b/docs/conf.py index 98092ec..3c8990a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,7 +38,7 @@ master_doc = 'index' # General information about the project. project = u'django-dbtemplates' -copyright = u'2007-2011, Jannis Leidel and contributors' +copyright = u'2007-2012, Jannis Leidel and contributors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the From 4ae9392e087b984a90471183a46680ad5989d084 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 9 Jan 2012 00:01:17 +0100 Subject: [PATCH 050/103] Use django-jenkins for tests and prepare it for ci.enn.io. --- dbtemplates/test_settings.py | 8 ++++++ dbtemplates/tests.py | 26 +++++++++++++----- tox.ini | 53 ++++++++++++++++++++++-------------- 3 files changed, 60 insertions(+), 27 deletions(-) diff --git a/dbtemplates/test_settings.py b/dbtemplates/test_settings.py index 4b46789..8fbdf1d 100644 --- a/dbtemplates/test_settings.py +++ b/dbtemplates/test_settings.py @@ -9,6 +9,7 @@ INSTALLED_APPS = [ 'django.contrib.sites', 'django.contrib.admin', 'dbtemplates', + 'django_jenkins', ] TEMPLATE_LOADERS = ( @@ -16,3 +17,10 @@ TEMPLATE_LOADERS = ( 'django.template.loaders.app_directories.Loader', 'dbtemplates.loader.Loader', ) + +JENKINS_TASKS = ( + 'django_jenkins.tasks.run_pyflakes', + 'django_jenkins.tasks.run_pep8', + 'django_jenkins.tasks.with_coverage', + 'django_jenkins.tasks.django_tests', +) diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index 2e52587..2d2eb6b 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -19,8 +19,14 @@ from dbtemplates.utils.template import (get_template_source, from dbtemplates.management.commands.sync_templates import (FILES_TO_DATABASE, DATABASE_TO_FILES) + class DbTemplatesTestCase(TestCase): def setUp(self): + self.old_template_loaders = settings.TEMPLATE_LOADERS + if 'dbtemplates.loader.Loader' not in settings.TEMPLATE_LOADERS: + settings.TEMPLATE_LOADERS = (list(settings.TEMPLATE_LOADERS) + + ['dbtemplates.loader.Loader']) + self.site1, created1 = Site.objects.get_or_create( domain="example.com", name="example.com") self.site2, created2 = Site.objects.get_or_create( @@ -31,6 +37,9 @@ class DbTemplatesTestCase(TestCase): name='sub.html', content='sub') self.t2.sites.add(self.site2) + def tearDown(self): + settings.TEMPLATE_LOADERS = self.old_template_loaders + def test_basiscs(self): self.assertEqual(list(self.t1.sites.all()), [self.site1]) self.assertTrue("base" in self.t1.content) @@ -68,28 +77,31 @@ class DbTemplatesTestCase(TestCase): def test_sync_templates(self): old_template_dirs = settings.TEMPLATE_DIRS temp_template_dir = tempfile.mkdtemp('dbtemplates') - last_path_part = temp_template_dir.split('/')[-1] temp_template_path = os.path.join(temp_template_dir, 'temp_test.html') temp_template = codecs.open(temp_template_path, 'w') try: temp_template.write('temp test') settings.TEMPLATE_DIRS = (temp_template_dir,) - self.assertFalse(Template.objects.filter(name='temp_test.html').exists()) + self.assertFalse( + Template.objects.filter(name='temp_test.html').exists()) call_command('sync_templates', force=True, verbosity=0, overwrite=FILES_TO_DATABASE) - self.assertTrue(Template.objects.filter(name='temp_test.html').exists()) + self.assertTrue( + Template.objects.filter(name='temp_test.html').exists()) t = Template.objects.get(name='temp_test.html') t.content = 'temp test modified' t.save() call_command('sync_templates', force=True, verbosity=0, overwrite=DATABASE_TO_FILES) - self.assertTrue('modified' in codecs.open(temp_template_path).read()) + self.assertTrue( + 'modified' in codecs.open(temp_template_path).read()) - call_command('sync_templates', - force=True, verbosity=0, delete=True, overwrite=DATABASE_TO_FILES) + call_command('sync_templates', force=True, verbosity=0, + delete=True, overwrite=DATABASE_TO_FILES) self.assertTrue(os.path.exists(temp_template_path)) - self.assertFalse(Template.objects.filter(name='temp_test.html').exists()) + self.assertFalse( + Template.objects.filter(name='temp_test.html').exists()) finally: temp_template.close() settings.TEMPLATE_DIRS = old_template_dirs diff --git a/tox.ini b/tox.ini index 66f3dc6..570b4f1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,51 +1,64 @@ -[tox] -distribute = false -envlist = - py25-1.2.X, py26-1.2.X, py27-1.2.X, - py25-1.3.X, py26-1.3.X, py27-1.3.X - [testenv] downloadcache = {toxworkdir}/_download/ +setenv = + DJANGO_SETTINGS_MODULE = dbtemplates.test_settings commands = - {envbindir}/coverage erase - {envbindir}/coverage run --branch --source=dbtemplates {envbindir}/django-admin.py test {posargs:dbtemplates} --settings=dbtemplates.test_settings - {envbindir}/coverage report --omit=*test* - {envbindir}/coverage html --omit=*test* -d {envtmpdir} - echo "Type the following to open the coverage report: python -m webbrowser -t file://{envtmpdir}/index.html" + {envbindir}/python {envbindir}/django-admin.py jenkins {posargs:dbtemplates} + +[testenv:docs] +basepython = python2.7 +deps = + Sphinx==1.0.7 + Django==1.3.1 +commands = + rm -rf docs/_build + {envbindir}/sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html [testenv:py25-1.2.X] basepython = python2.5 deps = - coverage django==1.2.5 + pep8 + pyflakes + django-jenkins [testenv:py26-1.2.X] basepython = python2.6 deps = - coverage django==1.2.5 + pep8 + pyflakes + django-jenkins [testenv:py27-1.2.X] basepython = python2.7 deps = - coverage django==1.2.5 + pep8 + pyflakes + django-jenkins -[testenv:py25-1.3.X] +[testenv:py25] basepython = python2.5 deps = - coverage django==1.3 + pep8 + pyflakes + django-jenkins -[testenv:py26-1.3.X] +[testenv:py26] basepython = python2.6 deps = - coverage django==1.3 + pep8 + pyflakes + django-jenkins -[testenv:py27-1.3.X] +[testenv:py27] basepython = python2.7 deps = - coverage django==1.3 + pep8 + pyflakes + django-jenkins From 1c1046852993ab2e2a7105c3157dba94c56bd5cb Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 9 Jan 2012 00:01:31 +0100 Subject: [PATCH 051/103] Fixed ignore files. --- .gitignore | 2 +- .hgignore | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 .hgignore diff --git a/.gitignore b/.gitignore index cb3f83e..993468d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ docs/_build *.egg/ pep8.txt coverage.xml -.coverage \ No newline at end of file +reports/ \ No newline at end of file diff --git a/.hgignore b/.hgignore deleted file mode 100644 index 508637e..0000000 --- a/.hgignore +++ /dev/null @@ -1,9 +0,0 @@ -syntax: glob -*.pyc -.*.swp -MANIFEST -build -dist -django_dbtemplates.egg-info/ -example/example.db -docs/_build \ No newline at end of file From 5a6053fef05f60e39a64f6fc61c8be74a2b98872 Mon Sep 17 00:00:00 2001 From: bmihelac Date: Mon, 9 Jan 2012 12:37:26 +0100 Subject: [PATCH 052/103] Fix typo in docs. --- docs/overview.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/overview.txt b/docs/overview.txt index c1229f4..a6fde1d 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -2,7 +2,7 @@ Setup ===== 1. Get the source from the `Git repository`_ or install it from the - Python Package Index by running ``pip django-dbtemplates``. + Python Package Index by running ``pip install django-dbtemplates``. 2. Follow the instructions in the INSTALL file 3. Edit the settings.py of your Django site: From cb3fe58a6e80a2be926c5aedce26bb4585600c53 Mon Sep 17 00:00:00 2001 From: bmihelac Date: Mon, 9 Jan 2012 12:56:09 +0100 Subject: [PATCH 053/103] Fix typo in docs - ``dbtemplates.loader.Loader`` should be first in ``TEMPLATE_LOADERS``. --- docs/overview.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/overview.txt b/docs/overview.txt index a6fde1d..2d1f623 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -30,9 +30,9 @@ Setup It should look something like this:: TEMPLATE_LOADERS = ( + 'dbtemplates.loader.Loader', 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', - 'dbtemplates.loader.Loader', ) 4. Sync your database ``python manage.py syncdb`` From 3e18bc9784cd5e1a5a9defc41225f682a2f0cf79 Mon Sep 17 00:00:00 2001 From: bmihelac Date: Mon, 9 Jan 2012 13:12:19 +0100 Subject: [PATCH 054/103] Update docs/overview.txt --- docs/overview.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/overview.txt b/docs/overview.txt index 2d1f623..8d67121 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -30,11 +30,16 @@ Setup It should look something like this:: TEMPLATE_LOADERS = ( - 'dbtemplates.loader.Loader', 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', + 'dbtemplates.loader.Loader', ) + Order of TEMPLATE_LOADERS is important. In the former example, templates from database + will be used as a fallback (ie. when template does not exists in other locations). + If you want template from database to be used to override templates in other locations, + put ``dbtemplates.loader.Loader`` at beginning of ``TEMPLATE_LOADERS`` settting. + 4. Sync your database ``python manage.py syncdb`` 5. Restart your Django server From 02aaad635a6e86e4301c78a88c8535f520cecd5b Mon Sep 17 00:00:00 2001 From: Mark Stahler Date: Tue, 17 Jan 2012 21:22:22 -0500 Subject: [PATCH 055/103] Added TinyMCE support via django-tinymce --- dbtemplates/admin.py | 9 +++++++++ dbtemplates/conf.py | 7 +++++++ dbtemplates/urls.py | 4 ++++ 3 files changed, 20 insertions(+) create mode 100644 dbtemplates/urls.py diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index efdfbcb..3089747 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -1,6 +1,7 @@ import posixpath from django import forms from django.contrib import admin +from django.core.exceptions import ImproperlyConfigured from django.utils.translation import ungettext, ugettext_lazy as _ from django.utils.safestring import mark_safe @@ -59,6 +60,14 @@ if settings.DBTEMPLATES_AUTO_POPULATE_CONTENT: else: content_help_text = "" +if settings.DBTEMPLATES_USE_CODEMIRROR and settings.DBTEMPLATES_USE_TINYMCE: + raise ImproperlyConfigured("You may use either CodeMirror or TinyMCE with dbtemplates, not both. Please disable one of them.") + +if settings.DBTEMPLATES_USE_TINYMCE: + TemplateContentTextArea = TinyMce +else: + TemplateContentTextArea = forms.Textarea + class TemplateAdminForm(forms.ModelForm): """ diff --git a/dbtemplates/conf.py b/dbtemplates/conf.py index e1075a2..0bcf4ec 100644 --- a/dbtemplates/conf.py +++ b/dbtemplates/conf.py @@ -9,6 +9,7 @@ from appconf import AppConf class DbTemplatesConf(AppConf): USE_CODEMIRROR = False USE_REVERSION = False + USE_TINYMCE = False ADD_DEFAULT_SITE = True AUTO_POPULATE_CONTENT = True MEDIA_PREFIX = None @@ -40,3 +41,9 @@ class DbTemplatesConf(AppConf): raise ImproperlyConfigured("Please add 'reversion' to your " "INSTALLED_APPS setting to make use of it in dbtemplates.") return value + + def configure_use_tinymce(self, value): + if value and 'tinymce' not in settings.INSTALLED_APPS: + raise ImproperlyConfigured("Please add 'tinymce' to your " + "INSTALLED_APPS setting to make use of it in dbtemplates.") + return value diff --git a/dbtemplates/urls.py b/dbtemplates/urls.py new file mode 100644 index 0000000..62d9494 --- /dev/null +++ b/dbtemplates/urls.py @@ -0,0 +1,4 @@ +from django.conf.urls.defaults import * + +if 'tinymce' in settings.INSTALLED_APPS: + urlpatterns += patterns('', url(r'^tinymce/', include('tinymce.urls'))) From e866e52074f0dee8ab92dd4f3e4beafffb648c11 Mon Sep 17 00:00:00 2001 From: Mark Stahler Date: Tue, 17 Jan 2012 21:58:47 -0500 Subject: [PATCH 056/103] fixed tinyMce not appearing in admin area --- dbtemplates/admin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 3089747..67ac90b 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -63,8 +63,9 @@ else: if settings.DBTEMPLATES_USE_CODEMIRROR and settings.DBTEMPLATES_USE_TINYMCE: raise ImproperlyConfigured("You may use either CodeMirror or TinyMCE with dbtemplates, not both. Please disable one of them.") -if settings.DBTEMPLATES_USE_TINYMCE: - TemplateContentTextArea = TinyMce +if settings.DBTEMPLATES_USE_TINYMCE and'tinymce' in settings.INSTALLED_APPS: + from tinymce.widgets import AdminTinyMCE + TemplateContentTextArea = AdminTinyMCE else: TemplateContentTextArea = forms.Textarea From edaf6ea2585b1936a870d7c7aed3a06a063f2115 Mon Sep 17 00:00:00 2001 From: Mark Stahler Date: Tue, 17 Jan 2012 22:11:08 -0500 Subject: [PATCH 057/103] respect column widths --- dbtemplates/admin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 67ac90b..3f966fc 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -61,9 +61,10 @@ else: content_help_text = "" if settings.DBTEMPLATES_USE_CODEMIRROR and settings.DBTEMPLATES_USE_TINYMCE: - raise ImproperlyConfigured("You may use either CodeMirror or TinyMCE with dbtemplates, not both. Please disable one of them.") + raise ImproperlyConfigured("You may use either CodeMirror or TinyMCE " + "with dbtemplates, not both. Please disable one of them.") -if settings.DBTEMPLATES_USE_TINYMCE and'tinymce' in settings.INSTALLED_APPS: +if settings.DBTEMPLATES_USE_TINYMCE: from tinymce.widgets import AdminTinyMCE TemplateContentTextArea = AdminTinyMCE else: From 68d4342df403eeb23509bca4d2eef4d0d8e1d574 Mon Sep 17 00:00:00 2001 From: Mark Stahler Date: Wed, 18 Jan 2012 08:33:13 -0500 Subject: [PATCH 058/103] removed urls.py which is not required if django-tinymce is installed properly. fixed new bug relating to codemirror introduced by tinymce --- dbtemplates/admin.py | 2 -- dbtemplates/urls.py | 4 ---- 2 files changed, 6 deletions(-) delete mode 100644 dbtemplates/urls.py diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 3f966fc..7e4dae8 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -67,8 +67,6 @@ if settings.DBTEMPLATES_USE_CODEMIRROR and settings.DBTEMPLATES_USE_TINYMCE: if settings.DBTEMPLATES_USE_TINYMCE: from tinymce.widgets import AdminTinyMCE TemplateContentTextArea = AdminTinyMCE -else: - TemplateContentTextArea = forms.Textarea class TemplateAdminForm(forms.ModelForm): diff --git a/dbtemplates/urls.py b/dbtemplates/urls.py deleted file mode 100644 index 62d9494..0000000 --- a/dbtemplates/urls.py +++ /dev/null @@ -1,4 +0,0 @@ -from django.conf.urls.defaults import * - -if 'tinymce' in settings.INSTALLED_APPS: - urlpatterns += patterns('', url(r'^tinymce/', include('tinymce.urls'))) From ad7b258308e2fe977a05fd03f772503e0fede137 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 24 Feb 2012 23:35:51 +0100 Subject: [PATCH 059/103] Force an encoding when writing the content to the file. --- dbtemplates/management/commands/sync_templates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index ca73d7f..8c1be09 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -101,8 +101,8 @@ class Command(NoArgsCommand): raise CommandError( u"Couldn't delete %s" % path) elif confirm == DATABASE_TO_FILES: + f = codecs.open(path, 'w', 'utf-8') try: - f = codecs.open(path, 'w') f.write(t.content) finally: f.close() From 0cfd927938c36bab4276a2f1cfff057ce333fa7f Mon Sep 17 00:00:00 2001 From: Jure Cuhalev Date: Sat, 25 Feb 2012 22:47:05 +0100 Subject: [PATCH 060/103] fix for tests when dbtemplates template loader is not in main settings.py --- dbtemplates/tests.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index 2d2eb6b..9f68021 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -24,6 +24,7 @@ class DbTemplatesTestCase(TestCase): def setUp(self): self.old_template_loaders = settings.TEMPLATE_LOADERS if 'dbtemplates.loader.Loader' not in settings.TEMPLATE_LOADERS: + loader.template_source_loaders = None settings.TEMPLATE_LOADERS = (list(settings.TEMPLATE_LOADERS) + ['dbtemplates.loader.Loader']) @@ -38,6 +39,7 @@ class DbTemplatesTestCase(TestCase): self.t2.sites.add(self.site2) def tearDown(self): + loader.template_source_loaders = None settings.TEMPLATE_LOADERS = self.old_template_loaders def test_basiscs(self): From f503013b0f4c14bd7b5b8f95b6c0a167b62da1bf Mon Sep 17 00:00:00 2001 From: Bojan Mihelac Date: Fri, 30 Mar 2012 15:11:57 +0200 Subject: [PATCH 061/103] Add failing tests for #27. Raises MultipleObjectsReturned with sites --- dbtemplates/tests.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index 9f68021..f5741d7 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -4,9 +4,10 @@ import os import shutil import tempfile +from django.conf import settings as django_settings from django.core.cache.backends.base import BaseCache from django.core.management import call_command -from django.template import loader, Context +from django.template import loader, Context, TemplateDoesNotExist from django.test import TestCase from django.contrib.sites.models import Site @@ -59,6 +60,28 @@ class DbTemplatesTestCase(TestCase): finally: settings.DBTEMPLATES_ADD_DEFAULT_SITE = old_add_default_site + def test_load_templates_sites(self): + old_add_default_site = settings.DBTEMPLATES_ADD_DEFAULT_SITE + old_site_id = django_settings.SITE_ID + try: + settings.DBTEMPLATES_ADD_DEFAULT_SITE = False + t_site1 = Template.objects.create( + name='copyright.html', content='(c) example.com') + t_site1.sites.add(self.site1) + t_site2 = Template.objects.create( + name='copyright.html', content='(c) example.org') + t_site2.sites.add(self.site2) + + django_settings.SITE_ID = Site.objects.create( + domain="example.net", name="example.net").id + Site.objects.clear_cache() + + with self.assertRaises(TemplateDoesNotExist): + loader.get_template("copyright.html") + finally: + django_settings.SITE_ID = old_site_id + settings.DBTEMPLATES_ADD_DEFAULT_SITE = old_add_default_site + def test_load_templates(self): result = loader.get_template("base.html").render(Context({})) self.assertEqual(result, 'base') From 29f08281d7b1e67b3696c40d64e988f9f54906ad Mon Sep 17 00:00:00 2001 From: Bojan Mihelac Date: Fri, 30 Mar 2012 15:14:21 +0200 Subject: [PATCH 062/103] Fix #27. dbtemplates tries to find template from database which is associated with current site, and if that fails then template from database which is not associated with any site. --- dbtemplates/loader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index 24e5010..a2c744d 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -62,7 +62,8 @@ class Loader(BaseLoader): return set_and_return(cache_key, template.content, display_name) except (Template.MultipleObjectsReturned, Template.DoesNotExist): try: - template = Template.objects.get(name__exact=template_name) + template = Template.objects.get(name__exact=template_name, + sites__in=[]) return set_and_return(cache_key, template.content, display_name) except Template.DoesNotExist: pass From 3aa313225572465f5a837d1632063e99c2d4f3f0 Mon Sep 17 00:00:00 2001 From: Bojan Mihelac Date: Fri, 30 Mar 2012 15:25:45 +0200 Subject: [PATCH 063/103] Fix for #28 --- dbtemplates/test_settings.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dbtemplates/test_settings.py b/dbtemplates/test_settings.py index 8fbdf1d..55c5e87 100644 --- a/dbtemplates/test_settings.py +++ b/dbtemplates/test_settings.py @@ -1,9 +1,12 @@ DBTEMPLATES_CACHE_BACKEND = 'dummy://' DATABASE_ENGINE = 'sqlite3' +# SQLite does not support removing unique constraints (see #28) +SOUTH_TESTS_MIGRATE = False SITE_ID = 1 + INSTALLED_APPS = [ 'django.contrib.contenttypes', 'django.contrib.sites', From bb4e7ce36fd2f32105cc957c884447a67ddfc73a Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Sun, 6 May 2012 20:52:17 +0700 Subject: [PATCH 064/103] Fixed an issue where ``get_cache_key`` may produce invalid memcached keys. --- dbtemplates/tests.py | 6 +++++- dbtemplates/utils/cache.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index f5741d7..fc44a84 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -14,7 +14,7 @@ from django.contrib.sites.models import Site from dbtemplates.conf import settings from dbtemplates.models import Template -from dbtemplates.utils.cache import get_cache_backend +from dbtemplates.utils.cache import get_cache_backend, get_cache_key from dbtemplates.utils.template import (get_template_source, check_template_syntax) from dbtemplates.management.commands.sync_templates import (FILES_TO_DATABASE, @@ -142,3 +142,7 @@ class DbTemplatesTestCase(TestCase): name='good.html', content='{% if foo %}Bar{% endif %}') self.assertFalse(check_template_syntax(bad_template)[0]) self.assertTrue(check_template_syntax(good_template)[0]) + + def test_get_cache_name(self): + name = 'name with spaces' + self.assertEqual(get_cache_key(name), 'dbtemplates::name-with-spaces::1') \ No newline at end of file diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py index 299647c..13a48d7 100644 --- a/dbtemplates/utils/cache.py +++ b/dbtemplates/utils/cache.py @@ -1,6 +1,7 @@ from django.core.cache import get_cache from django.contrib.sites.models import Site +from django.template.defaultfilters import slugify from dbtemplates.conf import settings @@ -13,7 +14,7 @@ cache = get_cache_backend() def get_cache_key(name): current_site = Site.objects.get_current() - return 'dbtemplates::%s::%s' % (name, current_site.pk) + return 'dbtemplates::%s::%s' % (slugify(name), current_site.pk) def get_cache_notfound_key(name): From 45700c7e1ceb764de80435b0981a8bf4f484a135 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 08:35:36 +0200 Subject: [PATCH 065/103] Moved CI to Travis. --- .travis.yml | 16 ++++++++++ README.rst | 2 ++ requirements/default.txt | 3 ++ tox.ini | 64 ---------------------------------------- 4 files changed, 21 insertions(+), 64 deletions(-) create mode 100644 .travis.yml create mode 100644 requirements/default.txt delete mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cb99b0f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: python +python: +# - "2.5" + - "2.6" + - "2.7" +install: + - pip install -q -r requirements/default.txt Django==$DJANGO --use-mirrors +script: + - django-admin.py jenkins +branches: + only: + - develop +env: + - DJANGO=1.2.7 + - DJANGO=1.3.1 + - DJANGO=1.4 diff --git a/README.rst b/README.rst index 3dd74ec..806c678 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,8 @@ django-dbtemplates ================== +.. image:: https://secure.travis-ci.org/jezdez/django-dbtemplates.png?branch=develop + ``dbtemplates`` is a Django app that consists of two parts: 1. It allows you to store templates in your database diff --git a/requirements/default.txt b/requirements/default.txt new file mode 100644 index 0000000..bb4b708 --- /dev/null +++ b/requirements/default.txt @@ -0,0 +1,3 @@ +pep8 +pyflakes +django-jenkins diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 570b4f1..0000000 --- a/tox.ini +++ /dev/null @@ -1,64 +0,0 @@ -[testenv] -downloadcache = {toxworkdir}/_download/ -setenv = - DJANGO_SETTINGS_MODULE = dbtemplates.test_settings -commands = - {envbindir}/python {envbindir}/django-admin.py jenkins {posargs:dbtemplates} - -[testenv:docs] -basepython = python2.7 -deps = - Sphinx==1.0.7 - Django==1.3.1 -commands = - rm -rf docs/_build - {envbindir}/sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html - -[testenv:py25-1.2.X] -basepython = python2.5 -deps = - django==1.2.5 - pep8 - pyflakes - django-jenkins - -[testenv:py26-1.2.X] -basepython = python2.6 -deps = - django==1.2.5 - pep8 - pyflakes - django-jenkins - -[testenv:py27-1.2.X] -basepython = python2.7 -deps = - django==1.2.5 - pep8 - pyflakes - django-jenkins - - -[testenv:py25] -basepython = python2.5 -deps = - django==1.3 - pep8 - pyflakes - django-jenkins - -[testenv:py26] -basepython = python2.6 -deps = - django==1.3 - pep8 - pyflakes - django-jenkins - -[testenv:py27] -basepython = python2.7 -deps = - django==1.3 - pep8 - pyflakes - django-jenkins From 3c67628a63411ae7acf6966a9c2a3263dc44909e Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 08:36:01 +0200 Subject: [PATCH 066/103] Removed dependency on versiontools. --- dbtemplates/__init__.py | 4 ++-- setup.py | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index e16f115..66b4ea1 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,2 +1,2 @@ -# following PEP 386, versiontools will pick it up -__version__ = (1, 2, 1, "final", 0) +# following PEP 386 +__version__ = "1.2a1" diff --git a/setup.py b/setup.py index 34f9e8d..778878f 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,33 @@ +import os +import re import codecs -from os import path from setuptools import setup, find_packages -read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read() + +def read(*parts): + return codecs.open(os.path.join(os.path.dirname(__file__), *parts)).read() + + +def find_version(*file_paths): + version_file = read(*file_paths) + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", + version_file, re.M) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") + setup( name='django-dbtemplates', - version=':versiontools:dbtemplates:', + version=find_version('dbtemplates', '__init__.py'), description='Template loader for templates stored in the database', - long_description=read(path.join(path.dirname(__file__), 'README.rst')), + long_description=read('README.rst'), author='Jannis Leidel', author_email='jannis@leidel.info', url='http://django-dbtemplates.readthedocs.org/', packages=find_packages(exclude=['example']), zip_safe=False, - package_data = { + package_data={ 'dbtemplates': [ 'locale/*/LC_MESSAGES/*', 'static/dbtemplates/css/*.css', @@ -35,5 +48,4 @@ setup( 'Framework :: Django', ], install_requires=['django-appconf >= 0.4'], - setup_requires=['versiontools >= 1.8.2'], ) From 20a5d9fc662d69e81d232aba57195291e05c7f9a Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 08:41:02 +0200 Subject: [PATCH 067/103] Forgot to set the DJANGO_SETTINGS_MODULE var. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cb99b0f..2d27f97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ python: install: - pip install -q -r requirements/default.txt Django==$DJANGO --use-mirrors script: - - django-admin.py jenkins + - DJANGO_SETTINGS_MODULE=dbtemplates.test_settings django-admin.py jenkins branches: only: - develop From 0ff18227f98c9b4f5deba4f0e9d50bfad788f7b8 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 08:43:48 +0200 Subject: [PATCH 068/103] Hrm, setting the variable in the env block? --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2d27f97..ac95dec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,11 @@ python: install: - pip install -q -r requirements/default.txt Django==$DJANGO --use-mirrors script: - - DJANGO_SETTINGS_MODULE=dbtemplates.test_settings django-admin.py jenkins + - django-admin.py jenkins branches: only: - develop env: - - DJANGO=1.2.7 - - DJANGO=1.3.1 - - DJANGO=1.4 + - DJANGO_SETTINGS_MODULE=dbtemplates.test_settings DJANGO=1.2.7 + - DJANGO_SETTINGS_MODULE=dbtemplates.test_settings DJANGO=1.3.1 + - DJANGO_SETTINGS_MODULE=dbtemplates.test_settings DJANGO=1.4 From 87c5c469995fe85fbd8b2945ef96badb8ba10eb9 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 08:55:27 +0200 Subject: [PATCH 069/103] Further fiddling with the travis config. --- .travis.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ac95dec..dde2d32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,17 @@ python: - "2.6" - "2.7" install: - - pip install -q -r requirements/default.txt Django==$DJANGO --use-mirrors + - pip install . + - pip install -r requirements/default.txt Django==$DJANGO +before_script: + - export PIP_USE_MIRRORS=true + - export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings script: - django-admin.py jenkins +env: + - DJANGO=1.2.7 + - DJANGO=1.3.1 + - DJANGO=1.4 branches: only: - develop -env: - - DJANGO_SETTINGS_MODULE=dbtemplates.test_settings DJANGO=1.2.7 - - DJANGO_SETTINGS_MODULE=dbtemplates.test_settings DJANGO=1.3.1 - - DJANGO_SETTINGS_MODULE=dbtemplates.test_settings DJANGO=1.4 From abc2fe5cd28a9a7467e60550509a24e05e1c0bc9 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 08:57:45 +0200 Subject: [PATCH 070/103] Added a few more test requirements. --- requirements/default.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements/default.txt b/requirements/default.txt index bb4b708..1a70548 100644 --- a/requirements/default.txt +++ b/requirements/default.txt @@ -1,3 +1,5 @@ pep8 pyflakes django-jenkins +coverage +pylint \ No newline at end of file From bea453548febc09b9b6435d697c09159b1018793 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 08:58:36 +0200 Subject: [PATCH 071/103] Renamed test requirements file to correct name. --- .travis.yml | 2 +- requirements/{default.txt => tests.txt} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename requirements/{default.txt => tests.txt} (100%) diff --git a/.travis.yml b/.travis.yml index dde2d32..13cddb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ python: - "2.7" install: - pip install . - - pip install -r requirements/default.txt Django==$DJANGO + - pip install -r requirements/tests.txt Django==$DJANGO before_script: - export PIP_USE_MIRRORS=true - export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings diff --git a/requirements/default.txt b/requirements/tests.txt similarity index 100% rename from requirements/default.txt rename to requirements/tests.txt From 222c7947d2f086df8c21167ae6c82729d64ff13a Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 09:04:05 +0200 Subject: [PATCH 072/103] Added auth app to list of installed apps during tests. --- dbtemplates/test_settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dbtemplates/test_settings.py b/dbtemplates/test_settings.py index 55c5e87..9fb2096 100644 --- a/dbtemplates/test_settings.py +++ b/dbtemplates/test_settings.py @@ -11,6 +11,7 @@ INSTALLED_APPS = [ 'django.contrib.contenttypes', 'django.contrib.sites', 'django.contrib.admin', + 'django.contrib.auth', 'dbtemplates', 'django_jenkins', ] From d3ccb0c42a85f2541b311b826b6c100bb28979ca Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 09:04:31 +0200 Subject: [PATCH 073/103] Stop using a context manager when we don't need it really. --- dbtemplates/tests.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dbtemplates/tests.py b/dbtemplates/tests.py index f5741d7..05ac2db 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/tests.py @@ -1,4 +1,3 @@ -from __future__ import with_statement import codecs import os import shutil @@ -76,8 +75,8 @@ class DbTemplatesTestCase(TestCase): domain="example.net", name="example.net").id Site.objects.clear_cache() - with self.assertRaises(TemplateDoesNotExist): - loader.get_template("copyright.html") + self.assertRaises(TemplateDoesNotExist, + loader.get_template, "copyright.html") finally: django_settings.SITE_ID = old_site_id settings.DBTEMPLATES_ADD_DEFAULT_SITE = old_add_default_site From 20aebf894dc2fff4c89f2043fa41752fb642a5b8 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 09:48:01 +0200 Subject: [PATCH 074/103] Limit the tests to dbtemplates. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 13cddb0..30333f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ before_script: - export PIP_USE_MIRRORS=true - export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings script: - - django-admin.py jenkins + - django-admin.py jenkins dbtemplates env: - DJANGO=1.2.7 - DJANGO=1.3.1 From f3fc408385491563e1d92003be5e088b1969707b Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 10:31:24 +0200 Subject: [PATCH 075/103] Get the database name from the routers and dropped support for 1.2.X. --- .travis.yml | 1 - dbtemplates/loader.py | 22 ++++++++++++---------- dbtemplates/test_settings.py | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30333f5..1803e05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ before_script: script: - django-admin.py jenkins dbtemplates env: - - DJANGO=1.2.7 - DJANGO=1.3.1 - DJANGO=1.4 branches: diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index a2c744d..a467305 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -1,7 +1,7 @@ from django.contrib.sites.models import Site +from django.db import router from django.template import TemplateDoesNotExist -from dbtemplates.conf import settings from dbtemplates.models import Template from dbtemplates.utils.cache import (cache, get_cache_key, set_and_return, get_cache_notfound_key) @@ -19,6 +19,12 @@ class Loader(BaseLoader): """ is_usable = True + def load_and_store_template(self, template_name, cache_key, site, **params): + template = Template.objects.get(name__exact=template_name, **params) + db = router.db_for_read(Template, instance=template) + display_name = 'dbtemplates:%s:%s:%s' % (db, template_name, site.domain) + return set_and_return(cache_key, template.content, display_name) + def load_template_source(self, template_name, template_dirs=None): # The logic should work like this: # * Try to find the template in the cache. If found, return it. @@ -33,8 +39,6 @@ class Loader(BaseLoader): # in the cache indicating that queries failed, with the current # timestamp. site = Site.objects.get_current() - display_name = 'dbtemplates:%s:%s:%s' % (settings.DATABASE_ENGINE, - template_name, site.domain) cache_key = get_cache_key(template_name) if cache: try: @@ -57,15 +61,13 @@ class Loader(BaseLoader): # Not marked as not-found, move on... try: - template = Template.objects.get(name__exact=template_name, - sites__in=[site.id]) - return set_and_return(cache_key, template.content, display_name) + return self.load_and_store_template(template_name, cache_key, + site, sites__in=[site.id]) except (Template.MultipleObjectsReturned, Template.DoesNotExist): try: - template = Template.objects.get(name__exact=template_name, - sites__in=[]) - return set_and_return(cache_key, template.content, display_name) - except Template.DoesNotExist: + return self.load_and_store_template(template_name, cache_key, + site, sites__in=[]) + except (Template.MultipleObjectsReturned, Template.DoesNotExist): pass # Mark as not-found in cache. diff --git a/dbtemplates/test_settings.py b/dbtemplates/test_settings.py index 9fb2096..587ebb2 100644 --- a/dbtemplates/test_settings.py +++ b/dbtemplates/test_settings.py @@ -6,6 +6,7 @@ SOUTH_TESTS_MIGRATE = False SITE_ID = 1 +SECRET_KEY = 'something-something' INSTALLED_APPS = [ 'django.contrib.contenttypes', From 0e43258b5b5a20e88a69dbc21019b9c1ac2e7259 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 10:35:23 +0200 Subject: [PATCH 076/103] Added DATABASES setting to please Django 1.4. --- dbtemplates/test_settings.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dbtemplates/test_settings.py b/dbtemplates/test_settings.py index 587ebb2..b382f07 100644 --- a/dbtemplates/test_settings.py +++ b/dbtemplates/test_settings.py @@ -8,6 +8,13 @@ SITE_ID = 1 SECRET_KEY = 'something-something' +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': ':memory:', + } +} + INSTALLED_APPS = [ 'django.contrib.contenttypes', 'django.contrib.sites', From f1e680aa3148ff127d5ba14279cd50135ddccd15 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 10:54:26 +0200 Subject: [PATCH 077/103] Added link to Travic build. --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 806c678..e0e9977 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,8 @@ django-dbtemplates ================== .. image:: https://secure.travis-ci.org/jezdez/django-dbtemplates.png?branch=develop + :alt: Build Status + :target: http://travis-ci.org/jezdez/django-dbtemplates ``dbtemplates`` is a Django app that consists of two parts: From 2f27327bebe7f2e7b33e5cfb0db517f53a1b9701 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 10:57:23 +0200 Subject: [PATCH 078/103] Handle timezone on 1.4 correctly. --- dbtemplates/models.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dbtemplates/models.py b/dbtemplates/models.py index c8bb3d6..02e8081 100644 --- a/dbtemplates/models.py +++ b/dbtemplates/models.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from datetime import datetime - from django.db import models from django.db.models import signals from django.template import TemplateDoesNotExist @@ -13,6 +11,12 @@ from dbtemplates.conf import settings from dbtemplates.utils.cache import add_template_to_cache, remove_cached_template from dbtemplates.utils.template import get_template_source +try: + from django.utils.timezone import now +except ImportError: + from datetime import datetime + now = datetime.now + class Template(models.Model): """ @@ -25,9 +29,9 @@ class Template(models.Model): sites = models.ManyToManyField(Site, verbose_name=_(u'sites'), blank=True, null=True) creation_date = models.DateTimeField(_('creation date'), - default=datetime.now) + default=now) last_changed = models.DateTimeField(_('last changed'), - default=datetime.now) + default=now) objects = models.Manager() on_site = CurrentSiteManager('sites') @@ -56,7 +60,7 @@ class Template(models.Model): pass def save(self, *args, **kwargs): - self.last_changed = datetime.now() + self.last_changed = now() # If content is empty look for a template with the given name and # populate the template instance with its content. if settings.DBTEMPLATES_AUTO_POPULATE_CONTENT and not self.content: From 2e430d53709feaa0e0ebd7f5074e4a5e8af09b83 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 10:57:36 +0200 Subject: [PATCH 079/103] Minor code cleanup of the migrations. --- dbtemplates/migrations/0001_initial.py | 6 ++---- .../migrations/0002_auto__del_unique_template_name.py | 7 +------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/dbtemplates/migrations/0001_initial.py b/dbtemplates/migrations/0001_initial.py index a5192af..0e08603 100644 --- a/dbtemplates/migrations/0001_initial.py +++ b/dbtemplates/migrations/0001_initial.py @@ -4,10 +4,11 @@ from south.db import db from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'Template' db.create_table('django_template', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -26,16 +27,13 @@ class Migration(SchemaMigration): )) db.create_unique('django_template_sites', ['template_id', 'site_id']) - def backwards(self, orm): - # Deleting model 'Template' db.delete_table('django_template') # Removing M2M table for field sites on 'Template' db.delete_table('django_template_sites') - models = { 'dbtemplates.template': { 'Meta': {'ordering': "('name',)", 'object_name': 'Template', 'db_table': "'django_template'"}, diff --git a/dbtemplates/migrations/0002_auto__del_unique_template_name.py b/dbtemplates/migrations/0002_auto__del_unique_template_name.py index 17a8a6e..418a3ab 100644 --- a/dbtemplates/migrations/0002_auto__del_unique_template_name.py +++ b/dbtemplates/migrations/0002_auto__del_unique_template_name.py @@ -1,23 +1,18 @@ # encoding: utf-8 -import datetime from south.db import db from south.v2 import SchemaMigration -from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - # Removing unique constraint on 'Template', fields ['name'] db.delete_unique('django_template', ['name']) - def backwards(self, orm): - # Adding unique constraint on 'Template', fields ['name'] db.create_unique('django_template', ['name']) - models = { 'dbtemplates.template': { 'Meta': {'ordering': "('name',)", 'object_name': 'Template', 'db_table': "'django_template'"}, From 842e08cf2e89b66180892ce38b24fa72ffda39c2 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 14:06:54 +0200 Subject: [PATCH 080/103] Switched to using nose and django-nose for easy test running. --- .gitignore | 4 +--- .travis.yml | 3 ++- INSTALL | 17 ----------------- dbtemplates/admin.py | 2 +- .../commands/check_template_syntax.py | 1 + .../management/commands/sync_templates.py | 4 +++- dbtemplates/{tests.py => test_cases.py} | 4 ++-- dbtemplates/test_settings.py | 9 ++------- dbtemplates/utils/template.py | 8 +++----- requirements/tests.txt | 6 ++---- setup.cfg | 4 ++++ 11 files changed, 21 insertions(+), 41 deletions(-) delete mode 100644 INSTALL rename dbtemplates/{tests.py => test_cases.py} (98%) diff --git a/.gitignore b/.gitignore index 993468d..9d5809f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,4 @@ example/example.db docs/_build .tox/ *.egg/ -pep8.txt -coverage.xml -reports/ \ No newline at end of file +.coverage diff --git a/.travis.yml b/.travis.yml index 1803e05..6ffd9af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,9 @@ install: before_script: - export PIP_USE_MIRRORS=true - export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings + - flake8 script: - - django-admin.py jenkins dbtemplates + - django-admin.py test dbtemplates env: - DJANGO=1.3.1 - DJANGO=1.4 diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 2e5bc7d..0000000 --- a/INSTALL +++ /dev/null @@ -1,17 +0,0 @@ -To install it, run the following command inside this directory: - - python setup.py install - -Or if you'd prefer you can simply place the included ``dbtemplates`` -directory somewhere on your Python path, or symlink to it from -somewhere on your Python path; this is useful if you're working from a -Subversion checkout. Since ``dbtemplates`` is registered in the -Python Package Index you can also run ``easy_install django-dbtemplates`` -or ``pip install django-dbtemplates`` optionally. - -Note that this application requires Python 2.3 or later, and a recent -Subversion checkout of Django. You can obtain Python from -http://www.python.org/ and Django from http://www.djangoproject.com/. - -This install notice was bluntly stolen from James Bennett's registration -package, http://www.bitbucket.org/ubernostrum/django-registration/ \ No newline at end of file diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 7e4dae8..9505d26 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -15,7 +15,7 @@ from dbtemplates.utils.template import check_template_syntax if settings.DBTEMPLATES_USE_REVERSION: from reversion.admin import VersionAdmin as TemplateModelAdmin else: - from django.contrib.admin import ModelAdmin as TemplateModelAdmin + from django.contrib.admin import ModelAdmin as TemplateModelAdmin # noqa class CodeMirrorTextArea(forms.Textarea): diff --git a/dbtemplates/management/commands/check_template_syntax.py b/dbtemplates/management/commands/check_template_syntax.py index 16d4ca2..214f531 100644 --- a/dbtemplates/management/commands/check_template_syntax.py +++ b/dbtemplates/management/commands/check_template_syntax.py @@ -3,6 +3,7 @@ from django.core.management.base import CommandError, NoArgsCommand from dbtemplates.models import Template from dbtemplates.utils.template import check_template_syntax + class Command(NoArgsCommand): help = "Ensures templates stored in the database don't have syntax errors." diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 8c1be09..cffa7db 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -11,6 +11,7 @@ from dbtemplates.models import Template ALWAYS_ASK, FILES_TO_DATABASE, DATABASE_TO_FILES = ('0', '1', '2') + class Command(NoArgsCommand): help = "Syncs file system templates with the database bidirectionally." option_list = NoArgsCommand.option_list + ( @@ -89,7 +90,8 @@ class Command(NoArgsCommand): path, t.__repr__())) else: confirm = overwrite - if confirm in ('', FILES_TO_DATABASE, DATABASE_TO_FILES): + if confirm in ('', FILES_TO_DATABASE, + DATABASE_TO_FILES): if confirm == FILES_TO_DATABASE: t.content = codecs.open(path, 'r').read() t.save() diff --git a/dbtemplates/tests.py b/dbtemplates/test_cases.py similarity index 98% rename from dbtemplates/tests.py rename to dbtemplates/test_cases.py index 7747291..42b2a31 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/test_cases.py @@ -143,5 +143,5 @@ class DbTemplatesTestCase(TestCase): self.assertTrue(check_template_syntax(good_template)[0]) def test_get_cache_name(self): - name = 'name with spaces' - self.assertEqual(get_cache_key(name), 'dbtemplates::name-with-spaces::1') + self.assertEqual(get_cache_key('name with spaces'), + 'dbtemplates::name-with-spaces::1') diff --git a/dbtemplates/test_settings.py b/dbtemplates/test_settings.py index b382f07..6ce4617 100644 --- a/dbtemplates/test_settings.py +++ b/dbtemplates/test_settings.py @@ -21,7 +21,7 @@ INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'dbtemplates', - 'django_jenkins', + 'django_nose', ] TEMPLATE_LOADERS = ( @@ -30,9 +30,4 @@ TEMPLATE_LOADERS = ( 'dbtemplates.loader.Loader', ) -JENKINS_TASKS = ( - 'django_jenkins.tasks.run_pyflakes', - 'django_jenkins.tasks.run_pep8', - 'django_jenkins.tasks.with_coverage', - 'django_jenkins.tasks.django_tests', -) +TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' diff --git a/dbtemplates/utils/template.py b/dbtemplates/utils/template.py index 2113237..679a7d9 100644 --- a/dbtemplates/utils/template.py +++ b/dbtemplates/utils/template.py @@ -8,13 +8,11 @@ def get_loaders(): from django.template.loader import template_source_loaders if template_source_loaders is None: try: - from django.template.loader import ( - find_template as finder_func) + from django.template.loader import find_template as finder except ImportError: - from django.template.loader import ( - find_template_source as finder_func) + from django.template.loader import find_template_source as finder # noqa try: - source, name = finder_func('test') + source, name = finder('test') except TemplateDoesNotExist: pass from django.template.loader import template_source_loaders diff --git a/requirements/tests.txt b/requirements/tests.txt index 1a70548..06f0477 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,5 +1,3 @@ -pep8 -pyflakes -django-jenkins +flake8 +dajngo-nose coverage -pylint \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index cf6fb59..78ce9b8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,3 +11,7 @@ upload-dir = docs/_build/html [upload_sphinx] upload-dir = docs/_build/html + +[nosetests] +with-coverage=1 +cover-package=dbtemplates From 07fe3cc7eedb6bddfc06930ae69db8e346500145 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 14:08:08 +0200 Subject: [PATCH 081/103] Fixed typo. --- requirements/tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/tests.txt b/requirements/tests.txt index 06f0477..68eba17 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,3 +1,3 @@ flake8 -dajngo-nose +django-nose coverage From d018f826da4b414723258645aa0ffe7c18b25264 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 14:10:12 +0200 Subject: [PATCH 082/103] Forgotten dirname for flake8. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6ffd9af..59589b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ install: before_script: - export PIP_USE_MIRRORS=true - export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings - - flake8 + - flake8 dbtemplates script: - django-admin.py test dbtemplates env: From e7b6b8ce00167d6dddf1f5e9c633c047ed6ef3c0 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 14:12:07 +0200 Subject: [PATCH 083/103] Ignore long lines, stupid. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 59589b5..29545e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ install: before_script: - export PIP_USE_MIRRORS=true - export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings - - flake8 dbtemplates + - flake8 dbtemplates --ignore=E501 script: - django-admin.py test dbtemplates env: From a1cec65e293cb8fd0f36d65825156a386a9d399c Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 14:15:52 +0200 Subject: [PATCH 084/103] Removed INSTALL file from manifest template. --- MANIFEST.in | 1 - 1 file changed, 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 8d620eb..9852006 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ -include INSTALL include LICENSE include AUTHORS include README.rst From 60215fe947cc0a5a0d7f694c3e6d987e610632cd Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 23:47:15 +0200 Subject: [PATCH 085/103] Updated AUTHORS file. --- AUTHORS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AUTHORS b/AUTHORS index 612aac1..9dd4105 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,10 +5,14 @@ Alexander Artemenko Arne Brodowski David Paccoud Diego Búrigo Zacarão +Dmitry Falk Jannis Leidel +Jure Cuhalev Jason Mayfield Kevin Mooney +Mark Stahler Matt Dorn Oliver George +Selwin Ong Stephan Peijnik , ANEXIA Internetdienstleistungs GmbH, http://www.anexia.at/ Zhang Kun From 4c3c459e82a5d93bc41f2b98482bd6c283fa565e Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 23:47:30 +0200 Subject: [PATCH 086/103] Updated changelog. --- docs/changelog.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 9271c6e..b324766 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,6 +1,28 @@ Changelog ========= +v1.3 (2012-05-07) +----------------- + +* Dropped support for Django < 1.3 **backwards incompatible** + +* Dropped using versiontools in favor of home made solution. + +* Added optional support for TinyMCE editor instead of the CodeMirror + editor (just enable ``DBTEMPLATES_USE_TINYMCE``). + +* Fixed compatibility to Django 1.4's handling of the ``DATABASES`` + setting. Should also respect database routers now. + +* Fixed an issue of the cache key generation in combination with + memcache's inability to stomach spaces. + +* Moved test runner to use nose_ and a hosted CI project at Travis_: + http://travis-ci.org/jezdez/django-dbtemplates + +.. _nose: http://nose.rtfd.org/ +.. _Travis: http://travis-ci.org + v1.2.1 (2011-09-07) ------------------- From ee29bbe46ee2529a233e2c570c44b6a77d6f198e Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 23:48:07 +0200 Subject: [PATCH 087/103] Updated settings docs. --- docs/settings.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/settings.txt b/docs/settings.txt index c541d2c..45b5bbe 100644 --- a/docs/settings.txt +++ b/docs/settings.txt @@ -28,6 +28,14 @@ The dotted Python path to the cache backend class. See A boolean, if enabled triggers the use of the CodeMirror based editor. Set to ``False`` by default. +``DBTEMPLATES_USE_TINYMCE`` +--------------------------- + +.. versionadded:: 1.3 + +A boolean, if enabled triggers the use of the TinyMCE based editor. +Set to ``False`` by default. + ``DBTEMPLATES_USE_REVERSION`` ----------------------------- From c59de762f96b6cc108bd591a9754459b3bb62818 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 23:48:21 +0200 Subject: [PATCH 088/103] Correct version. --- dbtemplates/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index 66b4ea1..622f112 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,2 +1,2 @@ # following PEP 386 -__version__ = "1.2a1" +__version__ = "1.3a1" From ca9d2fc468f1a43c3a771a3fba0441b4a6529820 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 23:50:01 +0200 Subject: [PATCH 089/103] Removed old hg tags. --- .hgtags | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 .hgtags diff --git a/.hgtags b/.hgtags deleted file mode 100644 index c9e6f4c..0000000 --- a/.hgtags +++ /dev/null @@ -1,24 +0,0 @@ -bd537cd8beba30f1a26328e02126d3d1b14ebf8f 0.2.5 -1b426859f05b8a003411964883ed5d42ec6c1b01 0.3.0 -97da228cc698bfae05f60a68ec978030722b0777 0.3.1 -50c69325d3758d2e82541b13be2794ebbe9ee449 0.4.0 -d35a41ea96d3604a3c2654590c5c76b8865c4251 0.4.1 -a4bd56a7c2ea4c6f16a726e47bb185101934fe08 0.4.2 -447247c1ce1fbc77ac79c5855630af306f4f8c42 0.4.3 -5b2e4f7fc267daf71325991e913f98e6f96259bb 0.4.4 -ea4d636f3459ddbb51d87e921cf23f87e41d658d 0.4.5 -9a30f34bc5b07376ed6752eed94d9d58e791fbac 0.4.6 -9dc2a0e48494d6a354f5ca25db31638cede4bae4 0.4.7 -a3be97628ed8633e2fe232e6680474e7fd3e9fea 0.5.0 -bf3db2fe192d4a02bf531e61e23df342c36d6b1b 0.5.1 -67a86cf9f7c8ac8d9da855c13abbef2547033cce 0.5.2 -6967bbbee378f470e4b1df02b57112dd050d424b 0.5.3 -5965315c03c1a8c1cfb34752cca3802d68156e27 0.5.4 -4109e0db4340042cb85ea8a7d2b6ce37245738c6 0.5.5 -ade167225d06cb6888ea8bfa84e7d020590171c6 0.5.6 -dff01be9c8af328f8fcbc2fc97edcbe8d97840e2 0.5.7 -f8f7eaf275c5e8ac52174642265af55691abef7c 0.5.8 -4b36382cdfd756f45f81b0d042aaf331c3eabe30 0.6.0 -0ac352fec2c2a03ac801ff0c40f0649ef16e1f64 0.6.1 -34a0511928629872ce8cc5f94c6bed65f82ac343 0.7.0 -74c22fa8c4a64ea37f9b6b2515a4162b8b8b1a2a 0.7.1 From 25d92837580500c00d08c14a27e8dec74a12c31f Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 23:52:50 +0200 Subject: [PATCH 090/103] Use version from __version__. --- docs/conf.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3c8990a..0bccac6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,7 +16,7 @@ import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.append(os.path.abspath('.')) +sys.path.append(os.path.abspath('.')) # -- General configuration ----------------------------------------------------- @@ -45,9 +45,14 @@ copyright = u'2007-2012, Jannis Leidel and contributors' # built documents. # # The short X.Y version. -version = '1.2' -# The full version, including alpha/beta/rc tags. -release = '1.2.1' +try: + from dbtemplates import __version__ + # The short X.Y version. + version = '.'.join(__version__.split('.')[:2]) + # The full version, including alpha/beta/rc tags. + release = __version__ +except ImportError: + version = release = 'dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 8844180d6caadef560242d6ecffb9c994b93daff Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 23:52:59 +0200 Subject: [PATCH 091/103] Bumped version to 1.3. --- dbtemplates/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index 622f112..6524f6c 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,2 +1,2 @@ # following PEP 386 -__version__ = "1.3a1" +__version__ = "1.3" From 0672fa42bf289fb540fc543ea59571f3e4e36a68 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 19 May 2012 13:08:02 +0200 Subject: [PATCH 092/103] Set env vars before installing and use crate. --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 29545e8..5a802ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,14 @@ python: # - "2.5" - "2.6" - "2.7" +before_install: + - export PIP_USE_MIRRORS=true + - export PIP_INDEX_URL=https://simple.crate.io/ + - export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings install: - - pip install . + - pip install -e . - pip install -r requirements/tests.txt Django==$DJANGO before_script: - - export PIP_USE_MIRRORS=true - - export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings - flake8 dbtemplates --ignore=E501 script: - django-admin.py test dbtemplates From 6d356db2ef070b32fc35566d4804cf4091d5abc4 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 19 May 2012 13:10:03 +0200 Subject: [PATCH 093/103] Trying 2.5 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5a802ee..603b8ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python python: -# - "2.5" + - "2.5" - "2.6" - "2.7" before_install: From c36d649e4d0412a3cfc38e4c25d21364d4878e54 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 19 May 2012 13:27:09 +0200 Subject: [PATCH 094/103] Disabled Python 2.5 again as flake8 doesn't support it at the moment :( --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 603b8ae..8860170 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python python: - - "2.5" + # - "2.5" - "2.6" - "2.7" before_install: From 1c520b0fad303519a5c7cee989e2481124207c97 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 19 May 2012 19:24:17 +0200 Subject: [PATCH 095/103] Re-enabled 2.5 now that flake8 works on it again. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8860170..603b8ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python python: - # - "2.5" + - "2.5" - "2.6" - "2.7" before_install: From f7378df802140983dc3011a66ef4351e4283dc1d Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 19 May 2012 21:40:35 +0200 Subject: [PATCH 096/103] Use __isnull for querying a non-site specific template. Refs #33. --- dbtemplates/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index a467305..118de33 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -66,7 +66,7 @@ class Loader(BaseLoader): except (Template.MultipleObjectsReturned, Template.DoesNotExist): try: return self.load_and_store_template(template_name, cache_key, - site, sites__in=[]) + site, sites__isnull=True) except (Template.MultipleObjectsReturned, Template.DoesNotExist): pass From d2f595ce821264acad1ed8f81688533d276338e9 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 23 May 2012 23:50:32 +0200 Subject: [PATCH 097/103] Moved to django-discover-runner. --- .travis.yml | 3 ++- dbtemplates/test_settings.py | 3 +-- docs/changelog.txt | 8 ++++++++ requirements/tests.txt | 2 +- setup.cfg | 4 ---- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 603b8ae..69dfce6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,8 @@ install: before_script: - flake8 dbtemplates --ignore=E501 script: - - django-admin.py test dbtemplates + - coverage run --branch --source=dbtemplates `which django-admin.py` test dbtemplates + - coverage report --omit="dbtemplates/test*,dbtemplates/migrations*" env: - DJANGO=1.3.1 - DJANGO=1.4 diff --git a/dbtemplates/test_settings.py b/dbtemplates/test_settings.py index 6ce4617..a948cba 100644 --- a/dbtemplates/test_settings.py +++ b/dbtemplates/test_settings.py @@ -21,7 +21,6 @@ INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'dbtemplates', - 'django_nose', ] TEMPLATE_LOADERS = ( @@ -30,4 +29,4 @@ TEMPLATE_LOADERS = ( 'dbtemplates.loader.Loader', ) -TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' +TEST_RUNNER = 'discover_runner.DiscoverRunner' diff --git a/docs/changelog.txt b/docs/changelog.txt index b324766..43a9f28 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,6 +1,14 @@ Changelog ========= +v1.3.1 (2012-05-23) +------------------- + +* Minor release to move away from nose again and use own + `django-discover-runner`_. + +.. _`django-discover-runner`: http://pypi.python.org/pypi/django-discover-runner + v1.3 (2012-05-07) ----------------- diff --git a/requirements/tests.txt b/requirements/tests.txt index 68eba17..b29024e 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,3 +1,3 @@ flake8 -django-nose +django-discover-runner coverage diff --git a/setup.cfg b/setup.cfg index 78ce9b8..cf6fb59 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,7 +11,3 @@ upload-dir = docs/_build/html [upload_sphinx] upload-dir = docs/_build/html - -[nosetests] -with-coverage=1 -cover-package=dbtemplates From 4b024de9650f47e8d9a511054c8385f6771ab0d1 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Thu, 4 Apr 2013 11:33:00 +0200 Subject: [PATCH 098/103] Minor cosmetic changes to please flake8. --- dbtemplates/admin.py | 11 ++-- dbtemplates/conf.py | 6 ++- .../commands/create_error_templates.py | 3 +- .../management/commands/sync_templates.py | 52 ++++++++++--------- dbtemplates/test_cases.py | 8 +-- dbtemplates/utils/template.py | 2 +- 6 files changed, 44 insertions(+), 38 deletions(-) diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 9505d26..4b12095 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -6,8 +6,8 @@ from django.utils.translation import ungettext, ugettext_lazy as _ from django.utils.safestring import mark_safe from dbtemplates.conf import settings -from dbtemplates.models import (Template, - remove_cached_template, add_template_to_cache) +from dbtemplates.models import (Template, remove_cached_template, + add_template_to_cache) from dbtemplates.utils.template import check_template_syntax # Check if django-reversion is installed and use reversions' VersionAdmin @@ -55,14 +55,15 @@ else: if settings.DBTEMPLATES_AUTO_POPULATE_CONTENT: content_help_text = _("Leaving this empty causes Django to look for a " - "template with the given name and populate this field with its " - "content.") + "template with the given name and populate this " + "field with its content.") else: content_help_text = "" if settings.DBTEMPLATES_USE_CODEMIRROR and settings.DBTEMPLATES_USE_TINYMCE: raise ImproperlyConfigured("You may use either CodeMirror or TinyMCE " - "with dbtemplates, not both. Please disable one of them.") + "with dbtemplates, not both. Please disable " + "one of them.") if settings.DBTEMPLATES_USE_TINYMCE: from tinymce.widgets import AdminTinyMCE diff --git a/dbtemplates/conf.py b/dbtemplates/conf.py index 0bcf4ec..eb401fb 100644 --- a/dbtemplates/conf.py +++ b/dbtemplates/conf.py @@ -39,11 +39,13 @@ class DbTemplatesConf(AppConf): def configure_use_reversion(self, value): if value and 'reversion' not in settings.INSTALLED_APPS: raise ImproperlyConfigured("Please add 'reversion' to your " - "INSTALLED_APPS setting to make use of it in dbtemplates.") + "INSTALLED_APPS setting to make " + "use of it in dbtemplates.") return value def configure_use_tinymce(self, value): if value and 'tinymce' not in settings.INSTALLED_APPS: raise ImproperlyConfigured("Please add 'tinymce' to your " - "INSTALLED_APPS setting to make use of it in dbtemplates.") + "INSTALLED_APPS setting to make " + "use of it in dbtemplates.") return value diff --git a/dbtemplates/management/commands/create_error_templates.py b/dbtemplates/management/commands/create_error_templates.py index 37c6167..cbaa1d5 100644 --- a/dbtemplates/management/commands/create_error_templates.py +++ b/dbtemplates/management/commands/create_error_templates.py @@ -30,7 +30,8 @@ class Command(NoArgsCommand): help = "Creates the default error templates as database template objects." option_list = NoArgsCommand.option_list + ( make_option("-f", "--force", action="store_true", dest="force", - default=False, help="overwrite existing database templates"),) + default=False, + help="overwrite existing database templates"),) def handle_noargs(self, **options): force = options.get('force') diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index cffa7db..33feb52 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -15,20 +15,25 @@ ALWAYS_ASK, FILES_TO_DATABASE, DATABASE_TO_FILES = ('0', '1', '2') class Command(NoArgsCommand): help = "Syncs file system templates with the database bidirectionally." option_list = NoArgsCommand.option_list + ( - make_option("-e", "--ext", dest="ext", action="store", default="html", - help="extension of the files you want to sync with the database " - "[default: %default]"), - make_option("-f", "--force", action="store_true", dest="force", - default=False, help="overwrite existing database templates"), - make_option("-o", "--overwrite", action="store", dest="overwrite", - default='0', help="'0' - ask always, '1' - overwrite database " - "templates from template files, '2' - overwrite template " - "files from database templates"), - make_option("-a", "--app-first", action="store_true", dest="app_first", - default=False, help="look for templates in applications " - "directories before project templates"), - make_option("-d", "--delete", action="store_true", dest="delete", - default=False, help="Delete templates after syncing")) + make_option("-e", "--ext", + dest="ext", action="store", default="html", + help="extension of the files you want to " + "sync with the database [default: %default]"), + make_option("-f", "--force", + action="store_true", dest="force", default=False, + help="overwrite existing database templates"), + make_option("-o", "--overwrite", + action="store", dest="overwrite", default='0', + help="'0' - ask always, '1' - overwrite database " + "templates from template files, '2' - overwrite " + "template files from database templates"), + make_option("-a", "--app-first", + action="store_true", dest="app_first", default=False, + help="look for templates in applications " + "directories before project templates"), + make_option("-d", "--delete", + action="store_true", dest="delete", default=False, + help="Delete templates after syncing")) def handle_noargs(self, **options): extension = options.get('ext') @@ -71,23 +76,21 @@ class Command(NoArgsCommand): confirm = raw_input( "\nA '%s' template doesn't exist in the " "database.\nCreate it with '%s'?" - " (y/[n]): """ % (name, path)) + " (y/[n]): """ % (name, path)) if force or confirm.lower().startswith('y'): t = Template(name=name, - content=codecs.open(path, "r").read()) + content=codecs.open(path, "r").read()) t.save() t.sites.add(site) else: while 1: if overwrite == ALWAYS_ASK: confirm = raw_input( - "\n%s exists in the database.\n" - "(1) Overwrite %s with '%s'\n" - "(2) Overwrite '%s' with %s\n" - "Type 1 or 2 or press to skip: " - % (t.__repr__(), - t.__repr__(), path, - path, t.__repr__())) + "\n%(template)s exists in the database.\n" + "(1) Overwrite %(template)s with '%(path)s'\n" + "(2) Overwrite '%(path)s' with %(template)s\n" + "Type 1 or 2 or press to skip: " % + {'template': t.__repr__(), 'path': path}) else: confirm = overwrite if confirm in ('', FILES_TO_DATABASE, @@ -100,8 +103,7 @@ class Command(NoArgsCommand): try: os.remove(path) except OSError: - raise CommandError( - u"Couldn't delete %s" % path) + raise CommandError(u"Couldn't delete %s" % path) elif confirm == DATABASE_TO_FILES: f = codecs.open(path, 'w', 'utf-8') try: diff --git a/dbtemplates/test_cases.py b/dbtemplates/test_cases.py index 42b2a31..1878b29 100644 --- a/dbtemplates/test_cases.py +++ b/dbtemplates/test_cases.py @@ -108,16 +108,16 @@ class DbTemplatesTestCase(TestCase): settings.TEMPLATE_DIRS = (temp_template_dir,) self.assertFalse( Template.objects.filter(name='temp_test.html').exists()) - call_command('sync_templates', - force=True, verbosity=0, overwrite=FILES_TO_DATABASE) + call_command('sync_templates', force=True, + verbosity=0, overwrite=FILES_TO_DATABASE) self.assertTrue( Template.objects.filter(name='temp_test.html').exists()) t = Template.objects.get(name='temp_test.html') t.content = 'temp test modified' t.save() - call_command('sync_templates', - force=True, verbosity=0, overwrite=DATABASE_TO_FILES) + call_command('sync_templates', force=True, + verbosity=0, overwrite=DATABASE_TO_FILES) self.assertTrue( 'modified' in codecs.open(temp_template_path).read()) diff --git a/dbtemplates/utils/template.py b/dbtemplates/utils/template.py index 679a7d9..93bc1fd 100644 --- a/dbtemplates/utils/template.py +++ b/dbtemplates/utils/template.py @@ -1,6 +1,6 @@ from django import VERSION from django.template import (Template, TemplateDoesNotExist, - TemplateSyntaxError) + TemplateSyntaxError) from django.utils.importlib import import_module From b051161aea5097280a05a45627cfaedfe49bb3ee Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Thu, 4 Apr 2013 11:34:18 +0200 Subject: [PATCH 099/103] Test on Django 1.5.X, too. --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69dfce6..743312d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,6 @@ python: - "2.6" - "2.7" before_install: - - export PIP_USE_MIRRORS=true - - export PIP_INDEX_URL=https://simple.crate.io/ - export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings install: - pip install -e . @@ -16,8 +14,9 @@ script: - coverage run --branch --source=dbtemplates `which django-admin.py` test dbtemplates - coverage report --omit="dbtemplates/test*,dbtemplates/migrations*" env: - - DJANGO=1.3.1 - - DJANGO=1.4 + - DJANGO=1.3.7 + - DJANGO=1.4.5 + - DJANGO=1.5.1 branches: only: - develop From f668370eee24f12636d13be9696b0b231848fc47 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Thu, 4 Apr 2013 11:41:38 +0200 Subject: [PATCH 100/103] Drop support for Python 2.5. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 743312d..71163ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: python python: - - "2.5" - "2.6" - "2.7" before_install: From 12ffd84380a1f3ea02cb199d72436d7926d79fac Mon Sep 17 00:00:00 2001 From: Wasil W Sergejczyk Date: Tue, 30 Jul 2013 14:35:07 +0600 Subject: [PATCH 101/103] add Russian locale --- dbtemplates/locale/ru/LC_MESSAGES/django.mo | Bin 0 -> 2837 bytes dbtemplates/locale/ru/LC_MESSAGES/django.po | 107 ++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 dbtemplates/locale/ru/LC_MESSAGES/django.mo create mode 100644 dbtemplates/locale/ru/LC_MESSAGES/django.po diff --git a/dbtemplates/locale/ru/LC_MESSAGES/django.mo b/dbtemplates/locale/ru/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..82f769ef15b93418388f55c33a214a3b365c95ec GIT binary patch literal 2837 zcmb_dU2NM_6u!VVAp8$_00BBf>ee!xI_m^e+H4DrJEA3R>9UFOW|EuKn`2k8Q&w#f zT`RPr4JHs{5@H}Eo>5m8)@@yYSDvoLGkbvto)B+{H@@REY0`!b0avj<`}+KR=R3#F zt*x6b2&~6(JcHv3j%RUX?!pP{JK%l5?}0_&55Qx<*xf=r3H%gzKX3`S4Y&f_4!i}d z0yp0yL@)3pa3AnXpbh*5crWm^O+q{bJPLdeSOVfFe4I7|XMmjlZ6N1a0R9RN9|E7o z{mCstoB@6eJP&*hL3abc0&-111786C0Zaj(N3b7(CEy5f5JAhpIp9U$@4zR33lSln z0$u|40Ivcc1^xuYPyB`x^ZgU}FmTHQLV#9laZQ|`YiKUEZ(r;OHvy@_wH0TS73#t{ zAW>NJBS6;RF&ro})Q)qGxhUa@N1Gh{i_ zrfn6lUx=>R_w?r7s^j++T3+5A-8#ZnX_-2T=HGAUH3Q@-3pm4$40R}R4-Z6(jmtzOER4T zHRWgoELzfD6~^*C%Dav)9X~22TC%N@3$^P)FV|{jr~r)}jEaqWA-S$PuD8XUK-ZCE zI%A|(y_mY!=WUGJ#dgEA#HpvZ6=1bIk*`S8w_JyK+=OjNR(6VD%DoL-7#k1+1 zZ;Xu^kql^Sxr*s{7%;aIr;)>%42>qU1`Qcm2)I9)N=+Dt4()}hQ>tPFwVX7|ampk| z4;*I7Lz&Ee+lsoC(wYsZX46??t-e@Pj|?~FLd(refwwPD`2Bc=EoYE*t9a5+9L|ks zd)DljR#8?o!^yh^jBlLwylMH7al2YEZEeJ@l)X4PQ{k1IEN4H8v8)>*Guu zY7YLL%RtMx*XfDriA0RHZzsOgw==%EkAbUJma;Q|}I z4?Z#Y?CKkg2=$Swt8a1KP&d_bFsEwjMsN<-b)h~9-U}8;UBS+I3KrC&x(u^A9xhTa zADo6?4co9KRS(X<{av`BTxP^7DSR1h1M}3C;_3iOF&hwZg$}^9@y>h5DXG zh(<=_X=@IGo<*O~J8l4&oDJUTWB|TGT>!TmYMI!aTgKrQQApT#Lclq0WkbFiAy7@N ztDZxvl^2_zWOX^1=e)rjanb5J7s-0G4GY9ULY7Ni2|j4BQ!B9NqQe|~LminwsEtQW zeGOg+Uk`K5s&CktiD1+&wl(}eNb|)V8c3+E9?XWlyAGWivvmhA9`>$&m*C%+AJ+3) z*ZG<6P!X?O+xH!l^N#{>yIJ=6;C;NC%Uy<|<8NcV#1OnDpm{jCjRsuhTXb!i=NFR_ pP83pvjl|3>qmRwL!ixRzxxnU9!wnm7Syb0BCuc?boOIma*, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-07-30 14:03+0600\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#: admin.py:57 +msgid "" +"Leaving this empty causes Django to look for a template with the given name " +"and populate this field with its content." +msgstr "Если вы оставите это поле незаполненным, Django будет искать шаблон с введённым именем и заполнит поле его содержимым." + +#: admin.py:92 +msgid "Advanced" +msgstr "Дополнительно" + +#: admin.py:95 +msgid "Date/time" +msgstr "Дата/время" + +#: admin.py:112 +#, python-format +msgid "Cache of one template successfully invalidated." +msgid_plural "Cache of %(count)d templates successfully invalidated." +msgstr[0] "Кэш для шаблона успешно очищен." +msgstr[1] "Кэш для шаблонов (%(count)d шт.) успешно очищен." + +#: admin.py:116 +msgid "Invalidate cache of selected templates" +msgstr "Очистить кэш для выделенных шаблонов" + +#: admin.py:124 +#, python-format +msgid "Cache successfully repopulated with one template." +msgid_plural "Cache successfully repopulated with %(count)d templates." +msgstr[0] "Кэш для шаблона успешно заполнен." +msgstr[1] "Кэш для шаблонов (%(count)d шт.) успешно заполнен." + +#: admin.py:128 +msgid "Repopulate cache with selected templates" +msgstr "Заполнить кэш для выделенных шаблонов" + +#: admin.py:140 +#, python-format +msgid "Template syntax check FAILED for %(names)s." +msgid_plural "Template syntax check FAILED for %(count)d templates: %(names)s." +msgstr[0] "Неверный синтаксис у шаблона %(names)s." +msgstr[1] "Неверный синтаксис у следующих шаблонов: %(names)s." + +#: admin.py:148 +#, python-format +msgid "Template syntax OK." +msgid_plural "Template syntax OK for %(count)d templates." +msgstr[0] "Синтаксис шаблона корректен." +msgstr[1] "Синтаксис шаблонов корректен." + +#: admin.py:151 +msgid "Check template syntax" +msgstr "Проверить синтаксис шаблона" + +#: admin.py:155 models.py:29 +msgid "sites" +msgstr "сайты" + +#: models.py:26 +msgid "name" +msgstr "название" + +#: models.py:27 +msgid "Example: 'flatpages/default.html'" +msgstr "Например: 'flatpages/default.html'" + +#: models.py:28 +msgid "content" +msgstr "содержимое" + +#: models.py:31 +msgid "creation date" +msgstr "дата создания" + +#: models.py:33 +msgid "last changed" +msgstr "последнее изменение" + +#: models.py:41 +msgid "template" +msgstr "шаблон" + +#: models.py:42 +msgid "templates" +msgstr "шаблоны" From bfd7186db0914f6ba994dd871f3cdd0755a410ee Mon Sep 17 00:00:00 2001 From: Jannis Date: Wed, 6 Nov 2013 14:35:34 +0100 Subject: [PATCH 102/103] Fix URL to django-reversion doc. Fix URL of django-reversion's documentation. Apparently, django-reversion uses Readthedocs instead of GitHub's wiki now. --- docs/advanced.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced.txt b/docs/advanced.txt index dc62866..273ab03 100644 --- a/docs/advanced.txt +++ b/docs/advanced.txt @@ -62,7 +62,7 @@ Short installation howto 4. Set ``DBTEMPLATES_USE_REVERSION`` setting to ``True`` .. _django-reversion: https://github.com/etianen/django-reversion -.. _django-reversion's documentation: https://github.com/etianen/django-reversion/wiki/getting-started +.. _django-reversion's documentation: http://django-reversion.readthedocs.org/en/latest/ .. _commands: From 4352fb639e3fecafd661d964227739e9e70c5adb Mon Sep 17 00:00:00 2001 From: Sutrisno Efendi Date: Tue, 23 Sep 2014 15:19:16 +0700 Subject: [PATCH 103/103] Include fields to class Meta --- dbtemplates/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 4b12095..0a74237 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -80,6 +80,7 @@ class TemplateAdminForm(forms.ModelForm): class Meta: model = Template + fields = ('name', 'content', 'sites', 'creation_date', 'last_changed') class TemplateAdmin(TemplateModelAdmin):