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

arguments renamed to not shadow system built-ins

parent 3ac61187
No related branches found
No related tags found
1 merge request!111Resolve "Unfinished appointments"
......@@ -20,7 +20,7 @@ from web.api_views import worker, location, subject, appointment_type, appointme
urlpatterns = [
# appointments
url(r'^appointments/(?P<type>[A-z]+)$', appointment.appointments, name='web.api.appointments'),
url(r'^appointments/(?P<appointment_type>[A-z]+)$', appointment.appointments, name='web.api.appointments'),
# appointment types
url(r'^appointment_types$', appointment_type.appointment_types, name='web.api.appointment_types'),
......
......@@ -17,20 +17,20 @@ logger = logging.getLogger(__name__)
@login_required
def get_appointments(request, type, min_date, max_date):
if type == APPOINTMENT_LIST_GENERIC:
def get_appointments(request, appointment_type, min_date, max_date):
if appointment_type == APPOINTMENT_LIST_GENERIC:
result = Appointment.objects.filter(location__in=get_filter_locations(request.user),
)
elif type == APPOINTMENT_LIST_UNFINISHED:
elif appointment_type == APPOINTMENT_LIST_UNFINISHED:
result = get_unfinished_appointments(request.user)
elif type == APPOINTMENT_LIST_APPROACHING:
elif appointment_type == APPOINTMENT_LIST_APPROACHING:
result = Appointment.objects.filter(
datetime_when__gt=get_today_midnight_date(),
location__in=get_filter_locations(request.user),
status=Appointment.APPOINTMENT_STATUS_SCHEDULED
).order_by("datetime_when")
else:
raise TypeError("Unknown query type: " + type)
raise TypeError("Unknown query type: " + appointment_type)
if min_date is not None:
min_date = datetime.strptime(min_date, "%Y-%m-%d").replace(tzinfo=timezone.now().tzinfo)
......@@ -43,7 +43,7 @@ def get_appointments(request, type, min_date, max_date):
@login_required
def appointments(request, type):
def appointments(request, appointment_type):
# id of the query from dataTable: https://datatables.net/manual/server-side
draw = int(request.GET.get("draw", "-1"))
......@@ -56,7 +56,7 @@ def appointments(request, type):
if min_date is not None:
length = 1000000000
all_appointments = get_appointments(request, type, min_date, max_date)
all_appointments = get_appointments(request, appointment_type, min_date, max_date)
count = all_appointments.count()
......
......@@ -41,7 +41,7 @@ class TestAppointmentApi(TestCase):
appointment2.save()
AppointmentTypeLink.objects.create(appointment=appointment2, appointment_type=appointment_type)
url = reverse('web.api.appointments', kwargs={'type': APPOINTMENT_LIST_GENERIC})
url = reverse('web.api.appointments', kwargs={'appointment_type': APPOINTMENT_LIST_GENERIC})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
......@@ -55,7 +55,7 @@ class TestAppointmentApi(TestCase):
appointment.flying_team = create_flying_team(place=place)
appointment.save()
url = reverse('web.api.appointments', kwargs={'type': APPOINTMENT_LIST_GENERIC})
url = reverse('web.api.appointments', kwargs={'appointment_type': APPOINTMENT_LIST_GENERIC})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
......@@ -68,7 +68,7 @@ class TestAppointmentApi(TestCase):
visit = create_visit(self.study_subject)
create_appointment(visit, get_today_midnight_date() + datetime.timedelta(days=2))
url = reverse('web.api.appointments', kwargs={'type': APPOINTMENT_LIST_APPROACHING})
url = reverse('web.api.appointments', kwargs={'appointment_type': APPOINTMENT_LIST_APPROACHING})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
......@@ -81,7 +81,7 @@ class TestAppointmentApi(TestCase):
visit = create_visit(self.study_subject)
create_appointment(visit, get_today_midnight_date() + datetime.timedelta(days=-12))
url = reverse('web.api.appointments', kwargs={'type': APPOINTMENT_LIST_UNFINISHED})
url = reverse('web.api.appointments', kwargs={'appointment_type': APPOINTMENT_LIST_UNFINISHED})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
......@@ -102,7 +102,7 @@ class TestAppointmentApi(TestCase):
"end_date": (get_today_midnight_date() + datetime.timedelta(days=3)).strftime("%Y-%m-%d"),
}
url = ("%s" + create_get_suffix(params)) % reverse('web.api.appointments',
kwargs={'type': APPOINTMENT_LIST_GENERIC})
kwargs={'appointment_type': APPOINTMENT_LIST_GENERIC})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
......@@ -110,7 +110,7 @@ class TestAppointmentApi(TestCase):
params["start_date"] = (get_today_midnight_date() + datetime.timedelta(days=-2)).strftime("%Y-%m-%d")
url = ("%s" + create_get_suffix(params)) % reverse('web.api.appointments',
kwargs={'type': APPOINTMENT_LIST_GENERIC})
kwargs={'appointment_type': APPOINTMENT_LIST_GENERIC})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
......
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