Author: leidel
Date: Sat Nov  1 03:56:52 2008
New Revision: 56

Modified:
    trunk/dbtemplates/models.py

Log:
Merge branch 'master' of git://github.com/svetlyak40wt/django-dbtemplates

Modified: trunk/dbtemplates/models.py
==============================================================================
--- trunk/dbtemplates/models.py (original)
+++ trunk/dbtemplates/models.py Sat Nov  1 03:56:52 2008
@@ -3,6 +3,9 @@
  from django.db import models
  from django.contrib.sites.models import Site
  from django.utils.translation import gettext_lazy as _
+from django.template import TemplateDoesNotExist
+from django.template.loader import find_template_source
+

  class Template(models.Model):
      """
@@ -10,7 +13,7 @@
      The field ``name`` is the equivalent to the filename of a static  
template.
      """
      name = models.CharField(_('name'), unique=True, max_length=100,  
help_text=_("Example: 'flatpages/default.html'"))
-    content = models.TextField(_('content'))
+    content = models.TextField(_('content'), blank=True)
      sites = models.ManyToManyField(Site)
      creation_date = models.DateTimeField(_('creation date'),  
default=datetime.now)
      last_changed = models.DateTimeField(_('last changed'),  
default=datetime.now)
@@ -26,6 +29,13 @@

      def save(self, *args, **kwargs):
          self.last_changed = datetime.now()
+        if not self.content:
+            try:
+                source, origin = find_template_source(self.name)
+                if source:
+                    self.content = source
+            except TemplateDoesNotExist:
+                pass
          super(Template, self).save(*args, **kwargs)



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to