Private
Public Access
1
0

exporting courses.kml

This commit is contained in:
2024-02-28 15:36:12 +01:00
parent af1adf132e
commit 25bfcb17fd
6 changed files with 165 additions and 71 deletions

View File

@@ -1,7 +1,7 @@
from rowers.views.statements import *
from rowers.tasks import handle_calctrimp
from rowers.opaque import encoder
from rowers.courses import coursetokml
from rowers.courses import coursetokml, coursestokml
from xml.etree import ElementTree as ET
import arrow
@@ -252,6 +252,7 @@ Optional, not for CN
- Update one or more new courses from KML
"""
@api_view(["GET"])
@permission_classes([AllowAny])
def course_list(request):
if request.method != 'GET':
dologging('apilog.log','{m} request to KML endpoint'.format(m=request.method))
@@ -304,6 +305,7 @@ def course_list(request):
return JsonResponse(response_dict, content_type='application/json; charset=utf8')
@api_view(["GET"])
@permission_classes([AllowAny])
def get_crewnerd_kml(request,id=0):
if request.method != 'GET':
dologging('apilog.log','{m} request to CrewNerd KML endpoint'.format(m=request.method))
@@ -318,6 +320,26 @@ def get_crewnerd_kml(request,id=0):
return HttpResponse(kml)
#@csrf_exempt
@api_view(["GET"])
@permission_classes([AllowAny])
def get_crewnerd_multiple(request):
if request.method != 'GET':
dologging('apilog.log','{m} request to CrewNerd KML endpoint'.format(m=request.method))
return HttpResponseNotAllowed("Method not supported")
ids = request.GET.get('id')
if ids is not None:
tdict = dict(request.GET.lists())
ids = [int(id) for id in tdict['id']]
else:
gcs = GeoCourse.objects.all()
ids = [c.id for c in gcs]
kml = coursestokml(ids, cn=True)
return HttpResponse(kml)
# Stroke data views
@csrf_exempt