# Path: diario/managers.py
# class PublishedManager(Manager):
#     """
#     Manager for published entries on all sites. A published entry is
#     non-draft and/or non-future entry.
#     """
# 
#     def get_query_set(self):
#         queryset = super(PublishedManager, self).get_query_set()
#         return queryset.filter(is_draft=False, pub_date__lte=datetime.now)
# 
#     if HAS_TAG_SUPPORT:
#         def tagged(self, tag_instance):
#             """
#             Returns a QuerySet for a tag.
#             """
#             from tagging.models import TaggedItem
#             return TaggedItem.objects.get_by_model(self.get_query_set(),
#                                                    tag_instance)
# 
# class CurrentSitePublishedManager(CurrentSiteManager):
#     """
#     Manager for published entries on current site. A published entry is
#     non-draft and/or non-future entry.
#     """
# 
#     def get_query_set(self):
#         queryset = super(CurrentSitePublishedManager, self).get_query_set()
#         return queryset.filter(is_draft=False, pub_date__lte=datetime.now)
# 
#     if HAS_TAG_SUPPORT:
#         def tagged(self, tag_instance):
#             """Returns a QuerySet for a tag.
#             """
#             from tagging.models import TaggedItem
#             return TaggedItem.objects.get_by_model(self.get_query_set(),
#                                                    tag_instance)
# 
# Path: diario/settings.py
# DIARIO_DEFAULT_MARKUP_LANG = getattr(settings, 'DIARIO_DEFAULT_MARKUP_LANG',
#                                      'raw')
# 
# HAS_TAG_SUPPORT = True
# 
# Path: diario/signals.py
# def convert_body_to_html(instance, **kwargs):
#     """
#     Convert plain text markup in ``body_source`` field to HTML.
# 
#     This signal always connected in models module using ``pre_save``
#     method.
#     """
#     instance.body = unicode(markuping(instance.markup,
#                                       instance.body_source))
# 
# def update_draft_date(sender, instance, **kwargs):
#     """
#     Update instance's pub_date if entry was draft.
# 
#     This signal always connected in models module using ``pre_save``
#     method.
#     """
#     try:
#         e = sender.objects.get(id=instance.id)
#         if e.is_draft:
#             instance.pub_date = datetime.now()
#     except sender.DoesNotExist:
#         pass


from datetime import datetime
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.managers import CurrentSiteManager
from django.contrib.sites.models import Site
from django.db import models
from django.db.models import permalink
from django.utils.translation import ugettext_lazy as _
from diario.managers import PublishedManager, CurrentSitePublishedManager
from diario.settings import DIARIO_DEFAULT_MARKUP_LANG, HAS_TAG_SUPPORT
    from tagging.fields import TagField
from django.db.models import signals
from diario.signals import convert_body_to_html, update_draft_date
        _('body in HTML'),
        blank=True,
        editable=False,
    )
    markup = models.CharField(
        _('markup language'),
        default=DIARIO_DEFAULT_MARKUP_LANG,
        max_length=8,
        choices=MARKUP_CHOICES,
        help_text=_('Select "Raw text" to enter HTML or apply markup '
                    'elsewhere.'),
    )
    is_draft = models.BooleanField(
        _('draft'),
        default=False,
        help_text=_('Drafts are not published.'),
    )
    pub_date = models.DateTimeField(
        _('date published'),
        default=datetime.now,
        help_text=_('Entries in future dates are only published on '
                    'correct date.'),
    )
    publish_on = models.ManyToManyField(
        Site,
        default=[settings.SITE_ID],
        verbose_name=_('publish on')
    )
    enable_comments = models.BooleanField(_('enable comments'), default=True)


# Path: diario/managers.py
# class PublishedManager(Manager):
#     """
#     Manager for published entries on all sites. A published entry is
#     non-draft and/or non-future entry.
#     """
# 
#     def get_query_set(self):
#         queryset = super(PublishedManager, self).get_query_set()
#         return queryset.filter(is_draft=False, pub_date__lte=datetime.now)
# 
#     if HAS_TAG_SUPPORT:
#         def tagged(self, tag_instance):
#             """
#             Returns a QuerySet for a tag.
#             """
#             from tagging.models import TaggedItem
#             return TaggedItem.objects.get_by_model(self.get_query_set(),
#                                                    tag_instance)
# 
# class CurrentSitePublishedManager(CurrentSiteManager):
#     """
#     Manager for published entries on current site. A published entry is
#     non-draft and/or non-future entry.
#     """
# 
#     def get_query_set(self):
#         queryset = super(CurrentSitePublishedManager, self).get_query_set()
#         return queryset.filter(is_draft=False, pub_date__lte=datetime.now)
# 
#     if HAS_TAG_SUPPORT:
#         def tagged(self, tag_instance):
#             """Returns a QuerySet for a tag.
#             """
#             from tagging.models import TaggedItem
#             return TaggedItem.objects.get_by_model(self.get_query_set(),
#                                                    tag_instance)
# 
# Path: diario/settings.py
# DIARIO_DEFAULT_MARKUP_LANG = getattr(settings, 'DIARIO_DEFAULT_MARKUP_LANG',
#                                      'raw')
# 
# HAS_TAG_SUPPORT = True
# 
# Path: diario/signals.py
# def convert_body_to_html(instance, **kwargs):
#     """
#     Convert plain text markup in ``body_source`` field to HTML.
# 
#     This signal always connected in models module using ``pre_save``
#     method.
#     """
#     instance.body = unicode(markuping(instance.markup,
#                                       instance.body_source))
# 
# def update_draft_date(sender, instance, **kwargs):
#     """
#     Update instance's pub_date if entry was draft.
# 
#     This signal always connected in models module using ``pre_save``
#     method.
#     """
#     try:
#         e = sender.objects.get(id=instance.id)
#         if e.is_draft:
#             instance.pub_date = datetime.now()
#     except sender.DoesNotExist:
#         pass


# Path: diario/models.py
from datetime import datetime
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.managers import CurrentSiteManager
from django.contrib.sites.models import Site
from django.db import models
from django.db.models import permalink
from django.utils.translation import ugettext_lazy as _
from diario.managers import PublishedManager, CurrentSitePublishedManager
from diario.settings import DIARIO_DEFAULT_MARKUP_LANG, HAS_TAG_SUPPORT
    from tagging.fields import TagField
from django.db.models import signals
from diario.signals import convert_body_to_html, update_draft_date

        _('body in HTML'),
        blank=True,
        editable=False,
    )
    markup = models.CharField(
        _('markup language'),
        default=DIARIO_DEFAULT_MARKUP_LANG,
        max_length=8,
        choices=MARKUP_CHOICES,
        help_text=_('Select "Raw text" to enter HTML or apply markup '
                    'elsewhere.'),
    )
    is_draft = models.BooleanField(
        _('draft'),
        default=False,
        help_text=_('Drafts are not published.'),
    )
    pub_date = models.DateTimeField(
        _('date published'),
        default=datetime.now,
        help_text=_('Entries in future dates are only published on '
                    'correct date.'),
    )
    publish_on = models.ManyToManyField(
        Site,
        default=[settings.SITE_ID],
        verbose_name=_('publish on')
    )
    enable_comments = models.BooleanField(_('enable comments'), default=True)


    if HAS_TAG_SUPPORT: