"""Admin for parrot.gallery"""
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from socialaggregator.models import Feed
from socialaggregator.models import Aggregator
from socialaggregator.models import Ressource


class FeedAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}

admin.site.register(Feed, FeedAdmin)


class AggregatorAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}

admin.site.register(Aggregator, AggregatorAdmin)


def make_activated(modeladmin, request, queryset):
    queryset.update(activate=True)
make_activated.short_description = _("Mark selected ressources as activated")


def make_unactivated(modeladmin, request, queryset):
    queryset.update(activate=False)
make_unactivated.short_description = _("Mark selected ressources as \
                                        unactivated")


class RessourceAdmin(admin.ModelAdmin):
    date_hierarchy = 'ressource_date'
    prepopulated_fields = {"slug": ("name",)}
    list_display = ('name', 'author', 'language', 'social_type', 'query',
                    'ressource_date', 'activate', 'updated')
    list_filter = ('social_type', 'activate', 'updated', 'feeds', 'language')
    ordering = ['updated', '-ressource_date', 'query']
    exclude = ('updated', 'update_date',)
    actions = [make_activated, make_unactivated]

admin.site.register(Ressource, RessourceAdmin)

@@ -1373,16 +1373,962 @@
 tivated%5D
+%0A    fieldsets = ((_('Main infos'), %7B'fields': ('name', 'slug', 'description',%0A                                               'short_description', 'image',%0A                                               'thumbnail', 'media_url',%0A                                               'media_url_type')%7D),%0A                 (_('Extra infos'), %7B'fields': ('priority', 'activate',%0A                                                'author', 'language', 'feeds',%0A                                                'ressource_date', 'tags')%7D),%0A                 (_('Social network infos'), %7B'fields': ('social_id',%0A                                                         'social_type',%0A                                                         'query')%7D),%0A                 (_('Display infos'), %7B'fields': ('favorite', 'view_size',%0A                                                  'text_display',%0A                                                  'button_label',)%7D))
 %0A%0Aadmin.

reorganize ressource presentation by groups