annotate banners/admin.py @ 752:95f4e7f352fd
For Django 1.6: contrib auth password reset confirm view signature changed.
The uidb64 parameter was previously base 36 encoded and named uidb36.
Had to update urls.py. While I was in there I decided to make the
password reset email use the {% url %} tag to be more resilient if the
url changes.
author |
Brian Neal <bgneal@gmail.com> |
date |
Wed, 01 Jan 2014 19:52:07 -0600 |
parents |
ee87ea74d46b |
children |
|
rev |
line source |
bgneal@558
|
1 """
|
bgneal@558
|
2 This file contains the automatic admin site definitions for the banners models.
|
bgneal@558
|
3
|
bgneal@558
|
4 """
|
bgneal@558
|
5 from django.contrib import admin
|
bgneal@558
|
6
|
bgneal@558
|
7 from banners.models import Campaign, Banner
|
bgneal@558
|
8
|
bgneal@558
|
9
|
bgneal@558
|
10 class BannerInline(admin.TabularInline):
|
bgneal@558
|
11 model = Banner
|
bgneal@558
|
12 extra = 1
|
bgneal@558
|
13
|
bgneal@558
|
14
|
bgneal@558
|
15 class CampaignAdmin(admin.ModelAdmin):
|
bgneal@558
|
16 prepopulated_fields = {'slug': ['name']}
|
bgneal@558
|
17 list_display = ['name', 'slug', 'creation_date']
|
bgneal@558
|
18 date_hierarchy = 'creation_date'
|
bgneal@558
|
19 search_fields = ['name']
|
bgneal@558
|
20 inlines = [BannerInline]
|
bgneal@558
|
21
|
bgneal@558
|
22
|
bgneal@558
|
23 class BannerAdmin(admin.ModelAdmin):
|
bgneal@558
|
24 list_display = ['campaign', 'description', 'image_tag', 'creation_date']
|
bgneal@558
|
25 date_hierarchy = 'creation_date'
|
bgneal@558
|
26 search_fields = ['description']
|
bgneal@558
|
27 list_filter = ['campaign']
|
bgneal@558
|
28
|
bgneal@558
|
29 def image_tag(self, obj):
|
bgneal@558
|
30 return '<img src="%s" alt="%s" />' % (obj.image.url, obj.description)
|
bgneal@558
|
31 image_tag.allow_tags = True
|
bgneal@558
|
32
|
bgneal@558
|
33 admin.site.register(Campaign, CampaignAdmin)
|
bgneal@558
|
34 admin.site.register(Banner, BannerAdmin)
|