diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index ed9d4d8..777f190 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1 +1 @@ -__version__ = "0.7.4" +__version__ = "0.8.0" diff --git a/dbtemplates/locale/de/LC_MESSAGES/django.mo b/dbtemplates/locale/de/LC_MESSAGES/django.mo index 6e32001..cfc7ba0 100644 Binary files a/dbtemplates/locale/de/LC_MESSAGES/django.mo and b/dbtemplates/locale/de/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/de/LC_MESSAGES/django.po b/dbtemplates/locale/de/LC_MESSAGES/django.po index 96f877a..aed7b26 100644 --- a/dbtemplates/locale/de/LC_MESSAGES/django.po +++ b/dbtemplates/locale/de/LC_MESSAGES/django.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-10-09 13:45+0200\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" @@ -12,7 +12,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: German\n" -#: admin.py:29 +#: admin.py:53 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." @@ -20,60 +20,66 @@ 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:43 +#: admin.py:77 +msgid "Advanced" +msgstr "Erweiterte Einstellungen" + +#: admin.py:80 msgid "Date/time" msgstr "Datum/Uhrzeit" -#: admin.py:61 +#: admin.py:98 #, 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:65 +#: admin.py:102 msgid "Invalidate cache of selected templates" msgstr "Cache der ausgewählten Templates leeren" -#: admin.py:74 +#: admin.py:111 #, 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[1] "Der Cache von %(count)d 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:78 +#: admin.py:115 msgid "Repopulate cache with selected templates" msgstr "Cache der ausgewählten Templates neu füllen" -#: admin.py:82 +#: admin.py:119 models.py:29 msgid "sites" msgstr "Seiten" -#: models.py:18 +#: models.py:26 msgid "name" msgstr "Name" -#: models.py:19 +#: models.py:27 msgid "Example: 'flatpages/default.html'" msgstr "Zum Beispiel: 'flatpages/default.html'" -#: models.py:20 +#: models.py:28 msgid "content" msgstr "Inhalt" -#: models.py:22 +#: models.py:30 msgid "creation date" msgstr "Erstellt" -#: models.py:24 +#: models.py:32 msgid "last changed" msgstr "Geändert" -#: models.py:32 +#: models.py:40 msgid "template" msgstr "Template" -#: models.py:33 +#: models.py:41 msgid "templates" msgstr "Templates" diff --git a/dbtemplates/locale/en/LC_MESSAGES/django.mo b/dbtemplates/locale/en/LC_MESSAGES/django.mo index d9cde8b..b5e8316 100644 Binary files a/dbtemplates/locale/en/LC_MESSAGES/django.mo and b/dbtemplates/locale/en/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/en/LC_MESSAGES/django.po b/dbtemplates/locale/en/LC_MESSAGES/django.po index 79e77d0..6c5e97c 100644 --- a/dbtemplates/locale/en/LC_MESSAGES/django.po +++ b/dbtemplates/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-10-09 13:45+0200\n" +"POT-Creation-Date: 2010-11-07 00:02+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,66 +16,70 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: admin.py:29 +#: admin.py:53 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:43 +#: admin.py:77 +msgid "Advanced" +msgstr "" + +#: admin.py:80 msgid "Date/time" msgstr "" -#: admin.py:61 +#: admin.py:98 #, python-format msgid "Cache of one template successfully invalidated." msgid_plural "Cache of %(count)d templates successfully invalidated." msgstr[0] "" msgstr[1] "" -#: admin.py:65 +#: admin.py:102 msgid "Invalidate cache of selected templates" msgstr "" -#: admin.py:74 +#: admin.py:111 #, python-format msgid "Cache successfully repopulated with one template." msgid_plural "Cache successfully repopulated with %(count)d templates." msgstr[0] "" msgstr[1] "" -#: admin.py:78 +#: admin.py:115 msgid "Repopulate cache with selected templates" msgstr "" -#: admin.py:82 +#: admin.py:119 models.py:29 msgid "sites" msgstr "" -#: models.py:18 +#: models.py:26 msgid "name" msgstr "" -#: models.py:19 +#: models.py:27 msgid "Example: 'flatpages/default.html'" msgstr "" -#: models.py:20 +#: models.py:28 msgid "content" msgstr "" -#: models.py:22 +#: models.py:30 msgid "creation date" msgstr "" -#: models.py:24 +#: models.py:32 msgid "last changed" msgstr "" -#: models.py:32 +#: models.py:40 msgid "template" msgstr "" -#: models.py:33 +#: models.py:41 msgid "templates" msgstr "" diff --git a/dbtemplates/locale/fi/LC_MESSAGES/django.mo b/dbtemplates/locale/fi/LC_MESSAGES/django.mo new file mode 100644 index 0000000..46ab68c Binary files /dev/null and b/dbtemplates/locale/fi/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/fi/LC_MESSAGES/django.po b/dbtemplates/locale/fi/LC_MESSAGES/django.po new file mode 100644 index 0000000..b41bf65 --- /dev/null +++ b/dbtemplates/locale/fi/LC_MESSAGES/django.po @@ -0,0 +1,89 @@ +# 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. +# +# Finnish translation provided by holster@iki.fi +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-11-05 11:32+0200\n" +"PO-Revision-Date: 2010-11-05 11:32+0200\n" +"Last-Translator: Jaakko Holster \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin.py:53 +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ä." + +#: admin.py:77 +msgid "Advanced" +msgstr "Lisäasetukset" + +#: admin.py:80 +msgid "Date/time" +msgstr "Päiväys/aika" + +#: admin.py:98 +#, 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." + +#: admin.py:102 +msgid "Invalidate cache of selected templates" +msgstr "Poista valitut sivupohjat välimuistista." + +#: 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." + +#: admin.py:115 +msgid "Repopulate cache with selected templates" +msgstr "Lisää valitut sivupohjat välimuistiin." + +#: admin.py:119 +msgid "sites" +msgstr "sivustot" + +#: models.py:26 +msgid "name" +msgstr "nimi" + +#: models.py:27 +msgid "Example: 'flatpages/default.html'" +msgstr "Esimerkki: 'flatpages/default.html'" + +#: models.py:28 +msgid "content" +msgstr "sisältö" + +#: models.py:30 +msgid "creation date" +msgstr "luotu" + +#: models.py:32 +msgid "last changed" +msgstr "muokattu" + +#: models.py:40 +msgid "template" +msgstr "sivupohja" + +#: models.py:41 +msgid "templates" +msgstr "sivupohjat" diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 2743c46..cdd1ac3 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -8,6 +8,8 @@ from django.template.loaders.app_directories import app_template_dirs 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 + ( @@ -15,11 +17,18 @@ class Command(NoArgsCommand): 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") + 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"), ) + def handle_noargs(self, **options): extension = options.get('ext') force = options.get('force') + overwrite = options.get('overwrite') + app_first = options.get('app_first') if not extension.startswith("."): extension = ".%s" % extension @@ -34,8 +43,11 @@ class Command(NoArgsCommand): raise CommandError("Please make sure settings.TEMPLATE_DIRS is a " "list or tuple.") - templatedirs = [d for d in - settings.TEMPLATE_DIRS + app_template_dirs if os.path.isdir(d)] + if app_first: + tpl_dirs = app_template_dirs + settings.TEMPLATE_DIRS + else: + tpl_dirs = settings.TEMPLATE_DIRS + app_template_dirs + templatedirs = [d for d in tpl_dirs if os.path.isdir(d)] for templatedir in templatedirs: for dirpath, subdirs, filenames in os.walk(templatedir): @@ -46,31 +58,38 @@ class Command(NoArgsCommand): try: t = Template.on_site.get(name__exact=name) except Template.DoesNotExist: - if force == False: + if not force: confirm = raw_input( "\nA '%s' template doesn't exist in the database.\n" "Create it with '%s'?" " (y/[n]): """ % (name, path)) - if confirm.lower().startswith('y') or force: + if force or confirm.lower().startswith('y'): t = Template(name=name, content=open(path, "r").read()) t.save() t.sites.add(site) else: while 1: - 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__())) - if confirm == '' or confirm in ('1', '2'): - if confirm == '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__())) + else: + confirm = overwrite + if confirm == '' or confirm in (FILES_TO_DATABASE, DATABASE_TO_FILES): + if confirm == FILES_TO_DATABASE: t.content = open(path, 'r').read() t.save() t.sites.add(site) - elif confirm == '2': - open(path, 'w').write(t.content) + elif confirm == DATABASE_TO_FILES: + try: + f = open(path, 'w') + f.write(t.content) + finally: + f.close() break diff --git a/dbtemplates/models.py b/dbtemplates/models.py index dfae4e4..c7c1c97 100644 --- a/dbtemplates/models.py +++ b/dbtemplates/models.py @@ -26,7 +26,7 @@ class Template(models.Model): name = models.CharField(_('name'), unique=True, max_length=100, help_text=_("Example: 'flatpages/default.html'")) content = models.TextField(_('content'), blank=True) - sites = models.ManyToManyField(Site) + sites = models.ManyToManyField(Site, verbose_name=_('sites')) creation_date = models.DateTimeField(_('creation date'), default=datetime.now) last_changed = models.DateTimeField(_('last changed'), diff --git a/docs/conf.py b/docs/conf.py index 09e52e2..55885df 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,9 +45,9 @@ copyright = u'2010, Jannis Leidel' # built documents. # # The short X.Y version. -version = '0.7.4' +version = '0.8.0' # The full version, including alpha/beta/rc tags. -release = '0.7.4' +release = '0.8.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/overview.txt b/docs/overview.txt index 0d732fb..f09303d 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -295,6 +295,13 @@ Admin actions Changelog ========= +0.8.0 (11-07-10) +---------------- + +* Added Finnish translation (by jholster) + +* Added --overwrite and --app-first options to sync_templates command (by Alex Kamedov). + 0.7.4 (09-23-10) ----------------