bgneal@558: """ bgneal@558: This file contains the automatic admin site definitions for the banners models. bgneal@558: bgneal@558: """ bgneal@558: from django.contrib import admin bgneal@558: bgneal@558: from banners.models import Campaign, Banner bgneal@558: bgneal@558: bgneal@558: class BannerInline(admin.TabularInline): bgneal@558: model = Banner bgneal@558: extra = 1 bgneal@558: bgneal@558: bgneal@558: class CampaignAdmin(admin.ModelAdmin): bgneal@558: prepopulated_fields = {'slug': ['name']} bgneal@558: list_display = ['name', 'slug', 'creation_date'] bgneal@558: date_hierarchy = 'creation_date' bgneal@558: search_fields = ['name'] bgneal@558: inlines = [BannerInline] bgneal@558: bgneal@558: bgneal@558: class BannerAdmin(admin.ModelAdmin): bgneal@558: list_display = ['campaign', 'description', 'image_tag', 'creation_date'] bgneal@558: date_hierarchy = 'creation_date' bgneal@558: search_fields = ['description'] bgneal@558: list_filter = ['campaign'] bgneal@558: bgneal@558: def image_tag(self, obj): bgneal@558: return '%s' % (obj.image.url, obj.description) bgneal@558: image_tag.allow_tags = True bgneal@558: bgneal@558: admin.site.register(Campaign, CampaignAdmin) bgneal@558: admin.site.register(Banner, BannerAdmin)