tag forms (unused for now)
[redakcja.git] / apps / catalogue / models / document.py
index 70f50f2..4f08480 100755 (executable)
@@ -7,6 +7,7 @@ from __future__ import unicode_literals
 
 from datetime import date
 from django.conf import settings
+from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
 from django.db import models
 from django.template.loader import render_to_string
 from django.utils.translation import ugettext_lazy as _
@@ -24,7 +25,9 @@ class Document(Ref):
     stage = models.CharField(_('stage'), max_length=128, blank=True, default=STAGES[0])
     assigned_to = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, related_name='assignments')
     deleted = models.BooleanField(default=False)
-    tags = models.ManyToManyField(Tag)
+    tags = models.ManyToManyField(Tag, blank=True)
+    # we need to know if it were ever published (for notifications)
+    published = models.BooleanField(default=False)
 
     # Where to cache searchable stuff from metadata?
     # Probably in some kind of search index.
@@ -53,7 +56,7 @@ class Document(Ref):
         if header is None:
             header = etree.fromstring(data).find('.//{http://nowoczesnapolska.org.pl/sst#}header')
         metadata['title'] = getattr(header, 'text', ' ') or ' '
-        #print 'meta', d['title']
+        # print 'meta', d['title']
 
         m = t.find('metadata')
         if m is None:
@@ -86,7 +89,7 @@ class Document(Ref):
     def get_plan(self):
         try:
             plan = self.plan_set.get(stage=self.stage)
-        except:
+        except (ObjectDoesNotExist, MultipleObjectsReturned):
             return None
         return plan