Enhanced Map control
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponse
|
||||
|
||||
from django.utils import simplejson
|
||||
@@ -15,37 +14,42 @@ from musicians.models import Musician
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
@login_required
|
||||
def home_view(request):
|
||||
context = dict()
|
||||
|
||||
|
||||
# Event participation for slider text
|
||||
context['hasParticipationSetForAllEvents'] = EventParticipation.hasUserSetParticipationForAllEvents( request.user)
|
||||
|
||||
|
||||
# Countdown
|
||||
countdown = dict()
|
||||
events = Event.objects.filter( date__gte = datetime.now() ).order_by('date')[:1]
|
||||
if ( len(events) > 0 ):
|
||||
print "len(events): " + str( len(events ))
|
||||
nextEvent = events[0]
|
||||
part = EventParticipation.objects.filter( musician__user = request.user ).filter( event = nextEvent )
|
||||
part = EventParticipation.objects.filter( user = request.user ).filter( event = nextEvent )
|
||||
|
||||
eventTime = datetime( events[0].date.year, events[0].date.month, events[0].date.day,
|
||||
events[0].displaytime.hour, events[0].displaytime.minute )
|
||||
|
||||
context['hasParticipationSetForAllEvents'] = EventParticipation.hasUserSetParticipationForAllEvents( request.user)
|
||||
context['event'] = events[0]
|
||||
countdown['event'] = events[0]
|
||||
countdown['epoch'] = int( (eventTime - datetime.now() ).total_seconds() * 1000 )
|
||||
countdown['participation'] = part[0].status
|
||||
|
||||
context['epoch'] = int( (eventTime - datetime.now() ).total_seconds() * 1000 )
|
||||
context['participation'] = part[0].status
|
||||
else:
|
||||
context['hasParticipationSetForAllEvents'] = True
|
||||
|
||||
context['countdown'] = countdown
|
||||
|
||||
|
||||
# Route to concert
|
||||
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
|
||||
musician = Musician.objects.get( user = request.user );
|
||||
routeInfo['origin'] = musician.street + ", " + str( musician.zip_code ) + " " + musician.city
|
||||
|
||||
if nextConcert.map_location:
|
||||
# map_location has format "lat,longitute,zoomlevel"
|
||||
@@ -59,6 +63,7 @@ def home_view(request):
|
||||
else:
|
||||
context['hasNextConcertInfo'] = False
|
||||
|
||||
|
||||
return render( request, 'website/mainpage.html', context )
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user