comparison gpp/gcalendar/admin.py @ 204:b4305e18d3af

Resolve ticket #74. Add user badges. Some extra credit was done here: also refactored how pending news, links, and downloads are handled.
author Brian Neal <bgneal@gmail.com>
date Sat, 01 May 2010 21:53:59 +0000
parents bc657962941e
children d77e0dc772ad
comparison
equal deleted inserted replaced
203:40e5903903e1 204:b4305e18d3af
5 from django.http import HttpResponse 5 from django.http import HttpResponse
6 from django.conf.urls.defaults import * 6 from django.conf.urls.defaults import *
7 7
8 from gcalendar.models import Event 8 from gcalendar.models import Event
9 from gcalendar.admin_views import google_sync 9 from gcalendar.admin_views import google_sync
10 import bio.badges
10 11
11 12
12 class EventAdmin(admin.ModelAdmin): 13 class EventAdmin(admin.ModelAdmin):
13 list_display = ('what', 'user', 'start_date', 'where', 'date_submitted', 14 list_display = ('what', 'user', 'start_date', 'where', 'date_submitted',
14 'status', 'is_approved') 15 'status', 'is_approved')
45 if event.status in self.pending_states: 46 if event.status in self.pending_states:
46 event.status = self.pending_states[event.status] 47 event.status = self.pending_states[event.status]
47 event.save() 48 event.save()
48 count += 1 49 count += 1
49 50
51 if event.status == Event.NEW_APRV:
52 bio.badges.award_badge(bio.badges.CALENDAR_PIN, event.user)
53
50 msg = "1 event was" if count == 1 else "%d events were" % count 54 msg = "1 event was" if count == 1 else "%d events were" % count
51 msg += " approved." 55 msg += " approved."
52 self.message_user(request, msg) 56 self.message_user(request, msg)
53 57
54 approve_events.short_description = "Approve selected events" 58 approve_events.short_description = "Approve selected events"