# Path: diario/models.py
# class Entry(models.Model):
#     """A weblog entry."""
# 
#     title = models.CharField(_('title'), max_length=100)
#     slug = models.SlugField(
#         _('slug'),
#         unique_for_date='pub_date',
#         help_text=_('Automatically built from the title. A slug is a short '
#                     'label generally used in URLs.'),
#     )
#     author = models.ForeignKey(User, editable=False, verbose_name=_('author'))
#     body_source = models.TextField(_('body'))
#     body = models.TextField(
#         _('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:
#         tags = TagField(blank=True)
# 
#     # managers
#     objects   = models.Manager()
#     published = PublishedManager()
#     on_site   = CurrentSiteManager('publish_on')
#     published_on_site = CurrentSitePublishedManager('publish_on')
# 
#     class Meta:
#         abstract      = True
#         get_latest_by = 'pub_date'
#         ordering      = ('-pub_date',)
#         verbose_name  = _('entry')
#         verbose_name_plural = _('entries')
# 
#     def __unicode__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         return ('diario-entry', None, {
#             'year' : str(self.pub_date.year),
#             'month': str(self.pub_date.month).zfill(2),
#             'day'  : str(self.pub_date.day).zfill(2),
#             'slug' : str(self.slug)
#         })
#     get_absolute_url = permalink(get_absolute_url)
# 
#     def in_future(self):
#         return self.pub_date > datetime.now()
# 
# Path: diario/settings.py
# HAS_TAG_SUPPORT = True


from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from diario.models import Entry
from diario.settings import HAS_TAG_SUPPORT
        Called from the individual object editing page, to ensure the
        user is allowed to edit that object.

        Returns ``True`` if the user has permission for change the
        entry, otherwise returns ``False``.
        """
        has_class_permission = super(EntryAdmin, self).has_change_permission(request, obj)
        if not has_class_permission:
            return False
        if obj is not None and not request.user.is_superuser and request.user.id != obj.author.id:
            return False
        return True

    def queryset(self, request):
        """
        Filter the entries based on ``request.user``. This only
        affects the entries shown in the list view.
        """
        if request.user.is_superuser:
            return Entry.objects.all()
        return Entry.objects.filter(author=request.user)

    def save_model(self, request, obj, form, change):
        """
        Automatically fill in the author field on creation.
        """
        if not change:
            obj.author = request.user
        super(EntryAdmin, self).save_model(request, obj, form, change)


# Path: diario/models.py
# class Entry(models.Model):
#     """A weblog entry."""
# 
#     title = models.CharField(_('title'), max_length=100)
#     slug = models.SlugField(
#         _('slug'),
#         unique_for_date='pub_date',
#         help_text=_('Automatically built from the title. A slug is a short '
#                     'label generally used in URLs.'),
#     )
#     author = models.ForeignKey(User, editable=False, verbose_name=_('author'))
#     body_source = models.TextField(_('body'))
#     body = models.TextField(
#         _('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:
#         tags = TagField(blank=True)
# 
#     # managers
#     objects   = models.Manager()
#     published = PublishedManager()
#     on_site   = CurrentSiteManager('publish_on')
#     published_on_site = CurrentSitePublishedManager('publish_on')
# 
#     class Meta:
#         abstract      = True
#         get_latest_by = 'pub_date'
#         ordering      = ('-pub_date',)
#         verbose_name  = _('entry')
#         verbose_name_plural = _('entries')
# 
#     def __unicode__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         return ('diario-entry', None, {
#             'year' : str(self.pub_date.year),
#             'month': str(self.pub_date.month).zfill(2),
#             'day'  : str(self.pub_date.day).zfill(2),
#             'slug' : str(self.slug)
#         })
#     get_absolute_url = permalink(get_absolute_url)
# 
#     def in_future(self):
#         return self.pub_date > datetime.now()
# 
# Path: diario/settings.py
# HAS_TAG_SUPPORT = True


# Path: diario/admin.py
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from diario.models import Entry
from diario.settings import HAS_TAG_SUPPORT

        Called from the individual object editing page, to ensure the
        user is allowed to edit that object.

        Returns ``True`` if the user has permission for change the
        entry, otherwise returns ``False``.
        """
        has_class_permission = super(EntryAdmin, self).has_change_permission(request, obj)
        if not has_class_permission:
            return False
        if obj is not None and not request.user.is_superuser and request.user.id != obj.author.id:
            return False
        return True

    def queryset(self, request):
        """
        Filter the entries based on ``request.user``. This only
        affects the entries shown in the list view.
        """
        if request.user.is_superuser:
            return Entry.objects.all()
        return Entry.objects.filter(author=request.user)

    def save_model(self, request, obj, form, change):
        """
        Automatically fill in the author field on creation.
        """
        if not change:
            obj.author = request.user
        super(EntryAdmin, self).save_model(request, obj, form, change)


admin.site.register(Entry, EntryAdmin)