Skip to content
Snippets Groups Projects
Commit 5e850f27 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

api for list of locations

parent 241fba6a
No related branches found
No related tags found
1 merge request!34Performance of subject list
......@@ -22,6 +22,7 @@ urlpatterns = [
url(r'^countries$', api_views.countries, name='web.api.countries'),
url(r'^specializations$', api_views.specializations, name='web.api.specializations'),
url(r'^units$', api_views.units, name='web.api.units'),
url(r'^locations$', api_views.locations, name='web.api.locations'),
url(r'^referrals$', api_views.referrals, name='web.api.referrals'),
url(r'^appointment_types$', api_views.appointment_types, name='web.api.appointment_types'),
url(r'^subjects/(?P<type>[A-z]+)$', api_views.subjects, name='web.api.subjects'),
......
......@@ -3,7 +3,7 @@ import json
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse
from models import Subject, Worker, AppointmentType
from models import Subject, Worker, AppointmentType, Location
from views.subject import SUBJECT_LIST_GENERIC
......@@ -15,6 +15,14 @@ def cities(request):
})
@login_required
def locations(request):
X = Location.objects.values_list('name').distinct()
return JsonResponse({
"locations": [x[0] for x in X]
})
@login_required
def countries(request):
X = Subject.objects.filter(country__isnull=False).values_list('country').distinct()
......@@ -94,11 +102,11 @@ def get_subjects_filtered(subjects, filters):
elif column == "screening_number":
result = result.filter(screening_number__contains=value)
elif column == "dead":
result = result.filter(dead=(value=="true"))
result = result.filter(dead=(value == "true"))
elif column == "resigned":
result = result.filter(resigned=(value=="true"))
result = result.filter(resigned=(value == "true"))
elif column == "postponed":
result = result.filter(postponed=(value=="true"))
result = result.filter(postponed=(value == "true"))
else:
print row
# elif order_column == "default_location":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment