annotate gpp/downloads/admin.py @ 145:71cb4208dc98
Tweak to #30, admin dashboard. Because of a bug in Django (9568), my dashboard appears on the login page. To get around this, pass in the user to the templatetag, so it can do a 'if user.is_staff' check. Also tweaked the HTML and CSS to show non-zero pending items in red. Shortened the pending item titles for readability.
author |
Brian Neal <bgneal@gmail.com> |
date |
Wed, 09 Dec 2009 00:03:10 +0000 |
parents |
d6f3c38e8f50 |
children |
341759e1cda1 |
rev |
line source |
gremmie@1
|
1 """
|
gremmie@1
|
2 This file contains the automatic admin site definitions for the downloads models.
|
gremmie@1
|
3 """
|
gremmie@1
|
4 from django.contrib import admin
|
bgneal@6
|
5 from django.conf import settings
|
bgneal@6
|
6
|
gremmie@1
|
7 from downloads.models import Download
|
gremmie@1
|
8 from downloads.models import Category
|
gremmie@1
|
9 from downloads.models import AllowedExtension
|
gremmie@1
|
10 from downloads.models import VoteRecord
|
gremmie@1
|
11
|
gremmie@1
|
12 class DownloadAdmin(admin.ModelAdmin):
|
bgneal@8
|
13 exclude = ('html', )
|
bgneal@8
|
14 list_display = ('title', 'user', 'category', 'date_added', 'ip_address',
|
bgneal@8
|
15 'hits', 'average_score', 'size', 'is_public')
|
bgneal@8
|
16 list_filter = ('date_added', 'is_public', 'category', 'user', 'ip_address')
|
bgneal@8
|
17 date_hierarchy = 'date_added'
|
bgneal@8
|
18 ordering = ('-date_added', )
|
bgneal@8
|
19 search_fields = ('title', 'description', 'user__username')
|
bgneal@8
|
20 raw_id_fields = ('user', )
|
bgneal@8
|
21 save_on_top = True
|
gremmie@1
|
22
|
gremmie@1
|
23
|
gremmie@1
|
24 class VoteRecordAdmin(admin.ModelAdmin):
|
bgneal@8
|
25 list_display = ('user', 'download', 'vote_date')
|
bgneal@8
|
26 list_filter = ('user', 'download')
|
bgneal@8
|
27 date_hierarchy = 'vote_date'
|
gremmie@1
|
28
|
gremmie@1
|
29
|
gremmie@1
|
30 admin.site.register(Download, DownloadAdmin)
|
gremmie@1
|
31 admin.site.register(Category)
|
gremmie@1
|
32 admin.site.register(AllowedExtension)
|
gremmie@1
|
33 admin.site.register(VoteRecord, VoteRecordAdmin)
|
bgneal@8
|
34
|
bgneal@8
|
35 # vim: ts=4 sw=4
|