# Path: easy_news/models.py
# class News(models.Model):
#     class Meta:
#         verbose_name = _('News')
#         verbose_name_plural = _('News')
#         ordering = ['-date', 'title', ]
# 
#     show = models.BooleanField(verbose_name=_('Published'), default=True)
#     title = models.CharField(max_length=500, verbose_name=_('Title'))
#     slug = models.SlugField(max_length=200, verbose_name=_('Slug'), unique_for_date='date')
#     author = models.CharField(max_length=100, verbose_name=_('Author'), null=True, blank=True)
# 
#     date = models.DateField(verbose_name=_('Publication date'), default=timezone.now)
#     creation_date = models.DateField(verbose_name=_('Creation date'), auto_now_add=True)
# 
#     short = models.TextField(verbose_name=_('Short description'), default='', blank=True)
#     text = HTMLField(verbose_name=_('main content'), default='', blank=True)
# 
#     if news_settings.NEWS_TAGGING:
#         from tagging import fields
#         tags = fields.TagField(null=True)
# 
#     def month(self):
#         return MONTHS[self.date.month - 1]
# 
#     def save(self, *args, **kwds):
#         need_update = False
#         if self.slug is None:
#             if self.id is None:
#                 need_update = True
#                 self.slug = ''
#             else:
#                 self.slug = self.id
#         super(News, self).save(*args, **kwds)
#         if need_update:
#             self.slug = self.id
#             super(News, self).save(force_update=True)
#     save.alters_data = True
# 
#     def get_absolute_url(self):
#         return reverse('news_detail', kwargs={
#             'year': '%04d' % self.date.year,
#             'month': '%02d' % self.date.month,
#             'day': '%02d' % self.date.day,
#             'slug': self.slug,
#         })
# 
#     @property
#     def main_content(self):
#         return self.text
# 
#     @property
#     def short_description(self):
#         return self.short
# 
#     def __str__(self):
#         return self.title
# 
# Path: easy_news/forms.py
# class NewsAdminForm(forms.ModelForm):
# 
#     class Meta:
#         model = News
#         fields = '__all__'
#         widgets = {
#             'title': forms.TextInput(attrs={'class': get_extra_class('title')}),
#             'author': forms.TextInput(attrs={'class': get_extra_class('author')}),
#             'short': forms.Textarea(attrs={'class': get_extra_class('short')}),
#             'slug': forms.TextInput(attrs={'class': get_extra_class('slug')})
#         }
# 
#     if news_settings.NEWS_TAGGING:
#         tags = TagField(required=False)
# 
# Path: easy_news/settings.py
#     NEWS_TAGGING = getattr(settings, 'NEWS_TAGGING', True)
#         NEWS_TAGGING = getattr(settings, 'NEWS_TAGGING', False)
#         NEWS_TAGGING = False
# ENABLE_NEWS_LIST = getattr(settings, 'ENABLE_NEWS_LIST', True)
# ENABLE_NEWS_ARCHIVE_INDEX = getattr(settings, 'ENABLE_NEWS_ARCHIVE_INDEX', True)
# ENABLE_NEWS_DATE_ARCHIVE = getattr(settings, 'ENABLE_NEWS_DATE_ARCHIVE', True)
# ADMIN_EXTRA_CLASS = getattr(settings, 'NEWS_ADMIN_EXTRA_CLASS', {'all': ''})
# ADMIN_EXTRA_CSS = getattr(settings, 'NEWS_ADMIN_EXTRA_CSS', {'all': ['']})


from django.contrib import admin
from .models import News
from .forms import NewsAdminForm
from easy_news import settings as news_settings
# -*- coding: utf-8 -*-


@admin.register(News)
class NewsAdmin(admin.ModelAdmin):

    # @property
    # def media(self):
    #     media = super(NewsAdmin, self).media
    #     media.add_css(news_settings.ADMIN_EXTRA_CSS)
    #     return media

    list_filter = ['show']
    search_fields = ['title', 'short', 'text', 'author']
    list_display = ['title', 'date', 'show', 'author']
    prepopulated_fields = {'slug': ('title',)}

# Path: easy_news/models.py
# class News(models.Model):
#     class Meta:
#         verbose_name = _('News')
#         verbose_name_plural = _('News')
#         ordering = ['-date', 'title', ]
# 
#     show = models.BooleanField(verbose_name=_('Published'), default=True)
#     title = models.CharField(max_length=500, verbose_name=_('Title'))
#     slug = models.SlugField(max_length=200, verbose_name=_('Slug'), unique_for_date='date')
#     author = models.CharField(max_length=100, verbose_name=_('Author'), null=True, blank=True)
# 
#     date = models.DateField(verbose_name=_('Publication date'), default=timezone.now)
#     creation_date = models.DateField(verbose_name=_('Creation date'), auto_now_add=True)
# 
#     short = models.TextField(verbose_name=_('Short description'), default='', blank=True)
#     text = HTMLField(verbose_name=_('main content'), default='', blank=True)
# 
#     if news_settings.NEWS_TAGGING:
#         from tagging import fields
#         tags = fields.TagField(null=True)
# 
#     def month(self):
#         return MONTHS[self.date.month - 1]
# 
#     def save(self, *args, **kwds):
#         need_update = False
#         if self.slug is None:
#             if self.id is None:
#                 need_update = True
#                 self.slug = ''
#             else:
#                 self.slug = self.id
#         super(News, self).save(*args, **kwds)
#         if need_update:
#             self.slug = self.id
#             super(News, self).save(force_update=True)
#     save.alters_data = True
# 
#     def get_absolute_url(self):
#         return reverse('news_detail', kwargs={
#             'year': '%04d' % self.date.year,
#             'month': '%02d' % self.date.month,
#             'day': '%02d' % self.date.day,
#             'slug': self.slug,
#         })
# 
#     @property
#     def main_content(self):
#         return self.text
# 
#     @property
#     def short_description(self):
#         return self.short
# 
#     def __str__(self):
#         return self.title
# 
# Path: easy_news/forms.py
# class NewsAdminForm(forms.ModelForm):
# 
#     class Meta:
#         model = News
#         fields = '__all__'
#         widgets = {
#             'title': forms.TextInput(attrs={'class': get_extra_class('title')}),
#             'author': forms.TextInput(attrs={'class': get_extra_class('author')}),
#             'short': forms.Textarea(attrs={'class': get_extra_class('short')}),
#             'slug': forms.TextInput(attrs={'class': get_extra_class('slug')})
#         }
# 
#     if news_settings.NEWS_TAGGING:
#         tags = TagField(required=False)
# 
# Path: easy_news/settings.py
#     NEWS_TAGGING = getattr(settings, 'NEWS_TAGGING', True)
#         NEWS_TAGGING = getattr(settings, 'NEWS_TAGGING', False)
#         NEWS_TAGGING = False
# ENABLE_NEWS_LIST = getattr(settings, 'ENABLE_NEWS_LIST', True)
# ENABLE_NEWS_ARCHIVE_INDEX = getattr(settings, 'ENABLE_NEWS_ARCHIVE_INDEX', True)
# ENABLE_NEWS_DATE_ARCHIVE = getattr(settings, 'ENABLE_NEWS_DATE_ARCHIVE', True)
# ADMIN_EXTRA_CLASS = getattr(settings, 'NEWS_ADMIN_EXTRA_CLASS', {'all': ''})
# ADMIN_EXTRA_CSS = getattr(settings, 'NEWS_ADMIN_EXTRA_CSS', {'all': ['']})


# Path: easy_news/admin.py
from django.contrib import admin
from .models import News
from .forms import NewsAdminForm
from easy_news import settings as news_settings

# -*- coding: utf-8 -*-


@admin.register(News)
class NewsAdmin(admin.ModelAdmin):

    # @property
    # def media(self):
    #     media = super(NewsAdmin, self).media
    #     media.add_css(news_settings.ADMIN_EXTRA_CSS)
    #     return media

    list_filter = ['show']
    search_fields = ['title', 'short', 'text', 'author']
    list_display = ['title', 'date', 'show', 'author']
    prepopulated_fields = {'slug': ('title',)}

    model = News