From 137bebc045ff5fe349976952b36bc59f37a4541f Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Thu, 7 Dec 2017 12:59:42 +0100
Subject: [PATCH] arguments renamed to not shadow system built-ins

---
 smash/web/api_urls.py                         |  2 +-
 smash/web/api_views/appointment.py            | 14 +++++++-------
 smash/web/tests/api_views/test_appointment.py | 12 ++++++------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/smash/web/api_urls.py b/smash/web/api_urls.py
index 08be1500..8b880d23 100644
--- a/smash/web/api_urls.py
+++ b/smash/web/api_urls.py
@@ -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'),
diff --git a/smash/web/api_views/appointment.py b/smash/web/api_views/appointment.py
index ef22810c..ee9bee97 100644
--- a/smash/web/api_views/appointment.py
+++ b/smash/web/api_views/appointment.py
@@ -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()
 
diff --git a/smash/web/tests/api_views/test_appointment.py b/smash/web/tests/api_views/test_appointment.py
index 0ca80009..0fafe6c6 100644
--- a/smash/web/tests/api_views/test_appointment.py
+++ b/smash/web/tests/api_views/test_appointment.py
@@ -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)
-- 
GitLab