mirror of
https://github.com/jazzband/django-dbtemplates.git
synced 2026-05-08 15:44:47 +00:00
Added DBTEMPLATES_AUTO_POPULATE_CONTENT setting to be able to disable to auto populating of template content.
This commit is contained in:
parent
e4cdd4a1c4
commit
975e0a4087
3 changed files with 10 additions and 4 deletions
|
|
@ -49,6 +49,11 @@ if settings.USE_CODEMIRROR:
|
|||
else:
|
||||
TemplateContentTextArea = forms.Textarea
|
||||
|
||||
if settings.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.")
|
||||
else:
|
||||
content_help_text = ""
|
||||
|
||||
class TemplateAdminForm(forms.ModelForm):
|
||||
"""
|
||||
|
|
@ -56,9 +61,7 @@ class TemplateAdminForm(forms.ModelForm):
|
|||
"""
|
||||
content = forms.CharField(
|
||||
widget=TemplateContentTextArea({'rows': '24'}),
|
||||
help_text=_("Leaving this empty causes Django to look for a template "
|
||||
"with the given name and populate this field with its content."),
|
||||
required=False)
|
||||
help_text=content_help_text, required=False)
|
||||
|
||||
class Meta:
|
||||
model = Template
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ 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 not self.content:
|
||||
if settings.AUTO_POPULATE_CONTENT and not self.content:
|
||||
self.populate()
|
||||
super(Template, self).save(*args, **kwargs)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ CACHE_BACKEND = getattr(settings, 'DBTEMPLATES_CACHE_BACKEND', None)
|
|||
|
||||
ADD_DEFAULT_SITE = getattr(settings, 'DBTEMPLATES_ADD_DEFAULT_SITE', True)
|
||||
|
||||
AUTO_POPULATE_CONTENT = getattr(settings, 'DBTEMPLATES_AUTO_POPULATE_CONTENT', True)
|
||||
|
||||
MEDIA_PREFIX = getattr(settings, 'DBTEMPLATES_MEDIA_PREFIX',
|
||||
os.path.join(settings.MEDIA_ROOT, 'dbtemplates'))
|
||||
|
||||
|
|
@ -15,3 +17,4 @@ 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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue