Skip to content

Commit

Permalink
[#709] Updated maps template with project updates
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Aug 6, 2014
1 parent 6eb0911 commit d5c9a3f
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 532 deletions.
Binary file modified akvo/rsr/static/common/img/blueMarker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added akvo/rsr/static/common/img/greenMarker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified akvo/rsr/static/common/img/redMarker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 13 additions & 4 deletions akvo/rsr/templatetags/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from django import template
from django.conf import settings

from akvo.rsr.models import Project, Organisation, ProjectLocation, OrganisationLocation
from akvo.rsr.models import Project, Organisation, ProjectLocation, OrganisationLocation, ProjectUpdateLocation

register = template.Library()

PROJECT_MARKER_ICON = getattr(settings, 'GOOGLE_MAPS_PROJECT_MARKER_ICON', '')
PROJECT_UPDATE_MARKER_ICON = getattr(settings, 'GOOGLE_MAPS_PROJECT_UPDATE_MARKER_ICON', '')
ORGANISATION_MARKER_ICON = getattr(settings, 'GOOGLE_MAPS_ORGANISATION_MARKER_ICON', '')
MEDIA_URL = getattr(settings, 'MEDIA_URL', '/media/')

Expand All @@ -35,19 +36,24 @@ def project_map(id, width, height, dynamic='dynamic'):
dynamic = False

map_id = 'akvo_map_%s' % os.urandom(8).encode('hex')
marker_icon = PROJECT_MARKER_ICON

locations = []
update_locations = []

for location in ProjectLocation.objects.filter(location_target=id):
locations.append([location.latitude, location.longitude])

for update_location in ProjectUpdateLocation.objects.filter(location_target__project=id):
update_locations.append([update_location.latitude, update_location.longitude])

template_context = {
'map_id': map_id,
'width': width,
'height': height,
'marker_icon': marker_icon,
'marker_icon': PROJECT_MARKER_ICON,
'update_marker_icon': PROJECT_UPDATE_MARKER_ICON,
'locations': locations,
'update_locations': update_locations,
'dynamic': dynamic,
'infowindows': False,
'partnersite_widget': False
Expand Down Expand Up @@ -109,7 +115,10 @@ def global_project_map(width, height, dynamic='dynamic'):
for project in Project.objects.all().active():
try:
location = project.primary_location
thumbnail = project.current_image.extra_thumbnails['map_thumb'].absolute_url
try:
thumbnail = project.current_image.extra_thumbnails['map_thumb'].absolute_url
except:
thumbnail = ""
locations.append([location.latitude,
location.longitude,
[str(project.pk),project.title.encode('utf8'), thumbnail, 'project']])
Expand Down
4 changes: 1 addition & 3 deletions akvo/settings/30-rsr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ STATIC_URL = '/static/'

PROJECT_UPDATE_TIMEOUT = 30 # minutes

#GOOGLE_MAPS_PROJECT_MARKER_ICON = '%score/img/blueMarker.png' % MEDIA_URL
#GOOGLE_MAPS_ORGANISATION_MARKER_ICON = '%score/img/redMarker.png' % MEDIA_URL

GOOGLE_MAPS_PROJECT_MARKER_ICON = '%scommon/img/blueMarker.png' % STATIC_URL
GOOGLE_MAPS_PROJECT_UPDATE_MARKER_ICON = '%scommon/img/greenMarker.png' % STATIC_URL
GOOGLE_MAPS_ORGANISATION_MARKER_ICON = '%scommon/img/redMarker.png' % STATIC_URL

# Donation
Expand Down
112 changes: 0 additions & 112 deletions akvo/templates/inclusion_tags/google_global_organisation_map.html.old

This file was deleted.

This file was deleted.

115 changes: 0 additions & 115 deletions akvo/templates/inclusion_tags/google_global_project_map.html.old

This file was deleted.

0 comments on commit d5c9a3f

Please sign in to comment.