Mercurial > public > sg101
comparison gpp/banners/admin.py @ 558:9a68fd3bd8a5
Creating a simple banner / ad campaign application, initially as a RFB / SG101
tie-in.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 02 Feb 2012 18:56:48 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
557:7247a406f92b | 558:9a68fd3bd8a5 |
---|---|
1 """ | |
2 This file contains the automatic admin site definitions for the banners models. | |
3 | |
4 """ | |
5 from django.contrib import admin | |
6 | |
7 from banners.models import Campaign, Banner | |
8 | |
9 | |
10 class BannerInline(admin.TabularInline): | |
11 model = Banner | |
12 extra = 1 | |
13 | |
14 | |
15 class CampaignAdmin(admin.ModelAdmin): | |
16 prepopulated_fields = {'slug': ['name']} | |
17 list_display = ['name', 'slug', 'creation_date'] | |
18 date_hierarchy = 'creation_date' | |
19 search_fields = ['name'] | |
20 inlines = [BannerInline] | |
21 | |
22 | |
23 class BannerAdmin(admin.ModelAdmin): | |
24 list_display = ['campaign', 'description', 'image_tag', 'creation_date'] | |
25 date_hierarchy = 'creation_date' | |
26 search_fields = ['description'] | |
27 list_filter = ['campaign'] | |
28 | |
29 def image_tag(self, obj): | |
30 return '<img src="%s" alt="%s" />' % (obj.image.url, obj.description) | |
31 image_tag.allow_tags = True | |
32 | |
33 admin.site.register(Campaign, CampaignAdmin) | |
34 admin.site.register(Banner, BannerAdmin) |