Skip to content
Snippets Groups Projects
admin.py 1.26 KiB
Newer Older
Olivier Le Brouster's avatar
Olivier Le Brouster committed
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
from newsbox.admin import NewsboxAdmin, NewsboxSEOAdmin, NewsboxExpiredAdmin

from .models import News, NewsSEO, NewsExpired, NewsComplete, NewsExtended

Dylann Cordel's avatar
Dylann Cordel committed

Olivier Le Brouster's avatar
Olivier Le Brouster committed
class NewsAdmin(NewsboxAdmin):
    pass

admin.site.register(News, NewsAdmin)


class NewsSEOAdmin(NewsboxSEOAdmin):
    pass

admin.site.register(NewsSEO, NewsSEOAdmin)


class NewsExpiredAdmin(NewsboxExpiredAdmin):
    pass

admin.site.register(NewsExpired, NewsExpiredAdmin)


class NewsCompleteAdmin(NewsboxSEOAdmin, NewsboxExpiredAdmin):
    pass

admin.site.register(NewsComplete, NewsCompleteAdmin)


class NewsExtendedAdmin(NewsboxSEOAdmin, NewsboxExpiredAdmin):
    def get_fieldsets(self, request, obj=None):
        fieldsets = super(NewsExtendedAdmin, self).get_fieldsets(request, obj)
        fieldsets[0][1]['fields'].append('general_field')
        fieldsets[2][1]['fields'].append('content_field')
        fieldsets[3][1]['fields'].append('seo_field')
        return fieldsets

    def get_list_display(self, request):
        list_display = super(NewsExtendedAdmin, self).get_list_display(request)
        list_display.append('seo_field')
        return list_display

admin.site.register(NewsExtended, NewsExtendedAdmin)