port to new django, AI automated

This commit is contained in:
2026-03-30 22:35:36 +02:00
parent e2d166e437
commit 372da3caa9
215 changed files with 9283 additions and 2981 deletions

View File

@@ -1,50 +1,58 @@
from datetime import datetime
from .models import Event, EventParticipation, NoNextEventException
from musicians.models import Musician
from .models import Event, EventParticipation, NoNextEventException
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."""
"""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)
except NoNextEventException:
return
countdown = dict()
countdown = {}
if EventParticipation.isMember(username):
part = EventParticipation.objects.filter(user=username).filter(event=nextEvent)
countdown['participation'] = part[0].status
if part.exists():
countdown["participation"] = part[0].status
eventTime = nextEvent.displaydatetime
countdown['event'] = nextEvent
countdown['epoch'] = int((eventTime - datetime.now()).total_seconds() * 1000)
countdown["event"] = nextEvent
countdown["epoch"] = int((eventTime - datetime.now()).total_seconds() * 1000)
context["countdown"] = countdown
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"""
"""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)
except NoNextEventException:
return
routeInfo = dict()
routeInfo = {}
routeInfo['event'] = nextEvent
routeInfo["event"] = nextEvent
musician = Musician.objects.get(user=username);
routeInfo['origin'] = musician.street + ", " + str(musician.zip_code) + " " + musician.city
try:
musician = Musician.objects.get(user=username)
routeInfo["origin"] = (
musician.street + ", " + str(musician.zip_code) + " " + musician.city
)
except Musician.DoesNotExist:
routeInfo["origin"] = ""
if nextEvent.map_location:
# map_location has format "lat,longitute,zoomlevel"
routeInfo['destination'] = ",".join(nextEvent.map_location.split(",")[:2])
# map_location has format "lat,longitude,zoomlevel"
routeInfo["destination"] = ",".join(nextEvent.map_location.split(",")[:2])
else:
routeInfo['destination'] = nextEvent.location
routeInfo["destination"] = nextEvent.location
context["route"] = routeInfo