Port to new django version - not yet fully working

- location field makes problems
This commit is contained in:
Martin Bauer
2019-01-05 11:27:15 +01:00
parent 72a9642a8e
commit 663185fd40
168 changed files with 797 additions and 5967 deletions

View File

@@ -1,38 +1,36 @@
from datetime import datetime
from models import Event, EventParticipation, NoNextEventException
from .models import Event, EventParticipation, NoNextEventException
from musicians.models import Musician
def addEventCountdownForNextEventToContext( context, username, eventType = "" ):
def addEventCountdownForNextEventToContext(context, username, eventType=""):
"""Returns an object that has to be added to the render context on the page where the countdown
should be displayed . The username is required to also supply participation information."""
try:
nextEvent = Event.getNextEvent( eventType, False )
try:
nextEvent = Event.getNextEvent(eventType, False)
except NoNextEventException:
return
countdown = dict()
if EventParticipation.isMember( username ):
part = EventParticipation.objects.filter( user = username ).filter( event = nextEvent )
if EventParticipation.isMember(username):
part = EventParticipation.objects.filter(user=username).filter(event=nextEvent)
countdown['participation'] = part[0].status
eventTime = nextEvent.displaydatetime
countdown['event'] = nextEvent
countdown['epoch'] = int( (eventTime - datetime.now() ).total_seconds() * 1000 )
countdown['epoch'] = int((eventTime - datetime.now()).total_seconds() * 1000)
context["countdown"] = countdown
def addEventRouteForNextEventToContext( context, username, eventType = ""):
def addEventRouteForNextEventToContext(context, username, eventType=""):
"""Returns an object that has to be added to the render context on the page where the route
should be displayed . The starting address of the route will be the home of the specified user"""
try:
nextEvent = Event.getNextEvent( eventType, True )
try:
nextEvent = Event.getNextEvent(eventType, True)
except NoNextEventException:
return
@@ -40,16 +38,13 @@ def addEventRouteForNextEventToContext( context, username, eventType = ""):
routeInfo['event'] = nextEvent
musician = Musician.objects.get( user = username );
routeInfo['origin'] = musician.street + ", " + str( musician.zip_code ) + " " + musician.city
musician = Musician.objects.get(user=username);
routeInfo['origin'] = musician.street + ", " + str(musician.zip_code) + " " + musician.city
if nextEvent.map_location:
# map_location has format "lat,longitute,zoomlevel"
routeInfo['destination'] = ",".join( nextEvent.map_location.split(",")[:2] )
routeInfo['destination'] = ",".join(nextEvent.map_location.split(",")[:2])
else:
routeInfo['destination'] = nextEvent.location
context["route"] = routeInfo