from django.utils.translation import get_language, ugettext_lazy as _, ugettext
from django_comments_xtd.models import XtdComment
from markupfield.fields import MarkupField
-from fnpdjango.utils.models.translation import add_translatable
+from fnpdjango.utils.models.translation import add_translatable, tQ
from migdal import app_settings
from migdal.fields import SlugNullField
})
+class PublishedEntryManager(models.Manager):
+ def get_query_set(self):
+ return super(PublishedEntryManager, self).get_query_set().filter(
+ tQ(published=True)
+ )
+
class Entry(models.Model):
type = models.CharField(max_length=16,
choices=((t.db, t.slug) for t in app_settings.TYPES),
in_stream = models.BooleanField(_('in stream'), default=True)
categories = models.ManyToManyField(Category, null=True, blank=True, verbose_name=_('categories'))
first_published_at = models.DateTimeField(_('published at'), null=True, blank=True)
+ canonical_url = models.URLField(_('canonical link'), null = True, blank = True)
+
+ objects = models.Manager()
+ published_objects = PublishedEntryManager()
class Meta:
verbose_name = _('entry')
mail_text, settings.SERVER_EMAIL, [self.author_email]
)
+ def inline_html(self):
+ for att in self.attachment_set.all():
+ if att.file.name.endswith(".html"):
+ with open(att.file.path) as f:
+ yield f.read()
+
add_translatable(Entry, languages=app_settings.OPTIONAL_LANGUAGES, fields={
'needed': models.CharField(_('needed'), max_length=1, db_index=True, choices=(