# -*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _

from opps.channel.models import Channel
from opps.channel.utils import generate_long_slug


class ChannelAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}
    list_display = ['name', 'channel', 'date_available', 'homepage',
                    'position', 'published']
    list_filter = ['date_available', 'published', 'homepage', 'channel']
    search_fields = ['name']
    exclude = ('user', 'long_slug')
    raw_id_fields = ['channel', 'articlebox']

    fieldsets = (
        (_(u'Identification'), {
            'fields': ('site', 'channel', 'name', 'slug', 'description',
                       'position', 'homepage', 'articlebox')}),
        (_(u'Publication'), {
            'classes': ('extrapretty'),
            'fields': ('published', 'date_available')}),
    )

    def save_model(self, request, obj, form, change):
        obj.long_slug = generate_long_slug(obj.channel, obj.slug,
                                           obj.site.domain)
        try:
            if obj.user:
                pass
        except User.DoesNotExist:
            obj.user = request.user

        super(ChannelAdmin, self).save_model(request, obj, form, change)


admin.site.register(Channel, ChannelAdmin)

# -*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _

from opps.channel.models import Channel
from opps.channel.utils import generate_long_slug


class ChannelAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}
    list_display = ['name', 'channel', 'date_available', 'homepage',
                    'position', 'published']
    list_filter = ['date_available', 'published', 'homepage', 'channel']
    search_fields = ['name']
    exclude = ('user', 'long_slug')
    raw_id_fields = ['channel']

    fieldsets = (
        (_(u'Identification'), {
            'fields': ('site', 'channel', 'name', 'slug', 'description',
                       'position', 'homepage',)}),
        (_(u'Publication'), {
            'classes': ('extrapretty'),
            'fields': ('published', 'date_available')}),
    )

    def save_model(self, request, obj, form, change):
        obj.long_slug = generate_long_slug(obj.channel, obj.slug,
                                           obj.site.domain)
        try:
            if obj.user:
                pass
        except User.DoesNotExist:
            obj.user = request.user

        super(ChannelAdmin, self).save_model(request, obj, form, change)


admin.site.register(Channel, ChannelAdmin)

Remove articlebox field on admin channel