Map on mainpage

This commit is contained in:
Martin Bauer
2013-09-22 17:53:18 +02:00
parent 230f1e6a36
commit 3fa4bdaafd
6 changed files with 132 additions and 4 deletions

View File

@@ -11,6 +11,7 @@ from django.contrib.auth.decorators import login_required
from eventplanner.models import Event, EventParticipation
from musicians.models import Musician
from datetime import datetime
@@ -34,7 +35,29 @@ def home_view(request):
context['participation'] = part[0].status
else:
context['hasParticipationSetForAllEvents'] = True
nextConcerts = Event.objects.filter( date__gte = datetime.now(), type = 'Conc' ).order_by('date')[:1]
if len( nextConcerts) > 0 :
nextConcert = nextConcerts[0]
routeInfo = dict()
user = Musician.objects.get( user = request.user );
routeInfo['origin'] = user.street + ", " + str( user.zip_code ) + " " + user.city
if nextConcert.map_location:
# map_location has format "lat,longitute,zoomlevel"
routeInfo['destination'] = ",".join( nextConcert.map_location.split(",")[:2] )
else:
routeInfo['destination'] = nextConcert.location
context['routeInfo'] = routeInfo
context['nextConcert'] = nextConcert
context['hasNextConcertInfo'] = True
else:
context['hasNextConcertInfo'] = False
return render( request, 'website/mainpage.html', context )