Map on mainpage
This commit is contained in:
@@ -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 )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user