annotate gpp/gcalendar/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 e04d91babfcf
children bc657962941e
rev   line source
gremmie@1 1 """
gremmie@1 2 This file contains the automatic admin site definitions for the gcalendar application.
gremmie@1 3 """
gremmie@1 4 from django.contrib import admin
gremmie@1 5 from django.http import HttpResponse
gremmie@1 6 from django.conf.urls.defaults import *
gremmie@1 7
gremmie@1 8 from gcalendar.models import Event
gremmie@1 9 from gcalendar.admin_views import google_sync
gremmie@1 10
gremmie@1 11
gremmie@1 12 class EventAdmin(admin.ModelAdmin):
gremmie@1 13 list_display = ('what', 'user', 'start_date', 'where', 'date_submitted',
bgneal@139 14 'status', 'is_approved')
gremmie@1 15 list_filter = ('start_date', 'status')
gremmie@1 16 search_fields = ('what', 'where', 'description')
gremmie@1 17 raw_id_fields = ('user', )
gremmie@1 18 exclude = ('html', 'google_id')
gremmie@1 19 save_on_top = True
gremmie@1 20
gremmie@1 21 def get_urls(self):
gremmie@1 22 urls = super(EventAdmin, self).get_urls()
gremmie@1 23 my_urls = patterns('',
gremmie@1 24 url(r'^google_sync/$',
gremmie@1 25 self.admin_site.admin_view(google_sync),
gremmie@1 26 name="gcalendar-google_sync")
gremmie@1 27 )
gremmie@1 28 return my_urls + urls
gremmie@1 29
gremmie@1 30
gremmie@1 31 admin.site.register(Event, EventAdmin)
gremmie@1 32
gremmie@1 33 # vim: ts=4 sw=4