list of courses api
This commit is contained in:
@@ -235,6 +235,46 @@ def part_of_day(hour):
|
||||
else:
|
||||
return "Night"
|
||||
|
||||
# KML API views
|
||||
"""
|
||||
- Get a list of courses
|
||||
- Nearby a certain coordinate
|
||||
- Filtered by
|
||||
- Get a (KML) course (in response.content rather than as attachment)
|
||||
- Get multiple courses as one KML in response.content
|
||||
- GET with parameters?
|
||||
Optional, not for CN
|
||||
- Create one or more new courses from KML
|
||||
- Should check for duplicates (Placemark ID)
|
||||
- Update one or more new courses from KML
|
||||
"""
|
||||
@api_view(["GET"])
|
||||
def course_list(request):
|
||||
if request.method != 'GET':
|
||||
dologging('apilog.log','{m} request to KML endpoint'.format(m=request.method))
|
||||
return HttpResponseNotAllower("Method not supported")
|
||||
|
||||
courses = GeoCourse.objects.all()
|
||||
courselist = []
|
||||
for c in courses:
|
||||
d = {
|
||||
'id': c.id,
|
||||
'name':c.name,
|
||||
'country':c.country,
|
||||
'distance':c.distance,
|
||||
'notes':c.notes,
|
||||
'location':(c.coord[0], c.coord[1]),
|
||||
}
|
||||
courselist.append(d)
|
||||
|
||||
response_dict = {'courses': courselist}
|
||||
|
||||
print(response_dict)
|
||||
|
||||
return JsonResponse(response_dict, content_type='application/json; charset=utf8')
|
||||
|
||||
# Stroke data views
|
||||
|
||||
@csrf_exempt
|
||||
@login_required()
|
||||
@api_view(["POST"])
|
||||
|
||||
Reference in New Issue
Block a user