# HG changeset patch # User Brian Neal # Date 1411864901 18000 # Node ID 5103edd3acc45abb6f3b19ec23bbcdfff0cf069b # Parent d7e4c08b2e8bb8deac7271dcf5aba94b2ec754cd 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. diff -r d7e4c08b2e8b -r 5103edd3acc4 bandmap/admin.py --- a/bandmap/admin.py Sat Sep 27 15:14:47 2014 -0500 +++ b/bandmap/admin.py Sat Sep 27 19:41:41 2014 -0500 @@ -21,7 +21,7 @@ readonly_fields = ['lat', 'lon'] search_fields = ['name', 'location', 'note'] raw_id_fields = ['user'] - actions = ['approve_bands', 'update_location'] + actions = ['update_location', 'approve_bands'] def approve_bands(self, request, qs): """This admin action awards a map pin to the user who added the band. @@ -31,10 +31,12 @@ count = qs.count() now = datetime.datetime.now() for band in qs: - bio.badges.award_badge(bio.badges.MAP_PIN, band.user) - band.date_approved = now - band.is_approved = True - band.save() + if not band.is_approved: + if band.date_approved is None: + bio.badges.award_badge(bio.badges.MAP_PIN, band.user) + band.date_approved = now + band.is_approved = True + band.save() self.message_user(request, "%d band(s) approved." % count) diff -r d7e4c08b2e8b -r 5103edd3acc4 bandmap/static/css/bandmap.css --- a/bandmap/static/css/bandmap.css Sat Sep 27 15:14:47 2014 -0500 +++ b/bandmap/static/css/bandmap.css Sat Sep 27 19:41:41 2014 -0500 @@ -4,3 +4,6 @@ border: 1px solid black; margin: 0 auto; } +#map-info { + margin-top: 2em; +} diff -r d7e4c08b2e8b -r 5103edd3acc4 bandmap/static/js/bandmap.js --- a/bandmap/static/js/bandmap.js Sat Sep 27 15:14:47 2014 -0500 +++ b/bandmap/static/js/bandmap.js Sat Sep 27 19:41:41 2014 -0500 @@ -1,5 +1,11 @@ var bandmap = null; var geocoder = null; +var surfbands = []; +var map_options = { + center: {lat: 15.0, lng: -30.0}, + zoom: 2 +}; +var info_win = null; function addBandOnSubmit(event) { var location = $('#id_location').val(); @@ -26,14 +32,54 @@ return false; } + +function refreshMap() { + bandmap.setOptions(map_options); + $.each(surfbands, function(i, band) { + band.marker.setMap(null); + }); + surfbands.length = 0; + var band_sel = $('#map-bands'); + band_sel[0].length = 0; + band_sel.append($('