Mercurial > public > sg101
comparison bandmap/admin.py @ 827:5103edd3acc4
Bandmap: initial version complete.
Javascript queries server for band data.
View created to handle query.
Test created for view.
Link added to map in sidebar.
Template tweaks.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 27 Sep 2014 19:41:41 -0500 |
parents | d7e4c08b2e8b |
children | b9973588af28 |
comparison
equal
deleted
inserted
replaced
826:d7e4c08b2e8b | 827:5103edd3acc4 |
---|---|
19 date_hierarchy = 'date_submitted' | 19 date_hierarchy = 'date_submitted' |
20 list_filter = ['date_submitted', 'is_active', 'is_approved'] | 20 list_filter = ['date_submitted', 'is_active', 'is_approved'] |
21 readonly_fields = ['lat', 'lon'] | 21 readonly_fields = ['lat', 'lon'] |
22 search_fields = ['name', 'location', 'note'] | 22 search_fields = ['name', 'location', 'note'] |
23 raw_id_fields = ['user'] | 23 raw_id_fields = ['user'] |
24 actions = ['approve_bands', 'update_location'] | 24 actions = ['update_location', 'approve_bands'] |
25 | 25 |
26 def approve_bands(self, request, qs): | 26 def approve_bands(self, request, qs): |
27 """This admin action awards a map pin to the user who added the band. | 27 """This admin action awards a map pin to the user who added the band. |
28 The band is then published and will be available for display on the map. | 28 The band is then published and will be available for display on the map. |
29 | 29 |
30 """ | 30 """ |
31 count = qs.count() | 31 count = qs.count() |
32 now = datetime.datetime.now() | 32 now = datetime.datetime.now() |
33 for band in qs: | 33 for band in qs: |
34 bio.badges.award_badge(bio.badges.MAP_PIN, band.user) | 34 if not band.is_approved: |
35 band.date_approved = now | 35 if band.date_approved is None: |
36 band.is_approved = True | 36 bio.badges.award_badge(bio.badges.MAP_PIN, band.user) |
37 band.save() | 37 band.date_approved = now |
38 band.is_approved = True | |
39 band.save() | |
38 | 40 |
39 self.message_user(request, "%d band(s) approved." % count) | 41 self.message_user(request, "%d band(s) approved." % count) |
40 | 42 |
41 approve_bands.short_description = "Approve selected band map entries" | 43 approve_bands.short_description = "Approve selected band map entries" |
42 | 44 |