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

unused code removed

parent d3249073
No related branches found
No related tags found
1 merge request!111Resolve "Unfinished appointments"
......@@ -7,7 +7,6 @@ from django.urls import reverse
from django.utils import timezone
from web.models import Appointment
from web.views import e500_error
from web.views.appointment import APPOINTMENT_LIST_GENERIC, APPOINTMENT_LIST_UNFINISHED, APPOINTMENT_LIST_APPROACHING
from web.views.notifications import get_filter_locations, \
get_today_midnight_date, \
......@@ -44,42 +43,38 @@ def get_appointments(request, type, min_date, max_date):
@login_required
def appointments(request, type):
try:
# id of the query from dataTable: https://datatables.net/manual/server-side
draw = int(request.GET.get("draw", "-1"))
# id of the query from dataTable: https://datatables.net/manual/server-side
draw = int(request.GET.get("draw", "-1"))
start = int(request.GET.get("start", "0"))
length = int(request.GET.get("length", "10"))
start = int(request.GET.get("start", "0"))
length = int(request.GET.get("length", "10"))
min_date = request.GET.get("start_date", None)
max_date = request.GET.get("end_date", None)
min_date = request.GET.get("start_date", None)
max_date = request.GET.get("end_date", None)
if min_date is not None:
length = 1000000000
if min_date is not None:
length = 1000000000
all_appointments = get_appointments(request, type, min_date, max_date)
all_appointments = get_appointments(request, type, min_date, max_date)
count = all_appointments.count()
count = all_appointments.count()
sliced_subjects = all_appointments[start:(start + length)]
sliced_subjects = all_appointments[start:(start + length)]
result_appointments = sliced_subjects
result_appointments = sliced_subjects
count_filtered = all_appointments.count()
count_filtered = all_appointments.count()
data = []
for appointment in result_appointments:
data.append(serialize_appointment(appointment))
data = []
for appointment in result_appointments:
data.append(serialize_appointment(appointment))
return JsonResponse({
"draw": draw,
"recordsTotal": count,
"recordsFiltered": count_filtered,
"data": data,
})
except:
logger.exception("Problem with getting appointments")
return e500_error(request)
return JsonResponse({
"draw": draw,
"recordsTotal": count,
"recordsFiltered": count_filtered,
"data": data,
})
def serialize_appointment(appointment):
......@@ -94,11 +89,12 @@ def serialize_appointment(appointment):
phone_numbers = ", ".join(filter(None,
[study_subject.subject.phone_number, study_subject.subject.phone_number_2,
study_subject.subject.phone_number_3]))
appointment_types = ", ".join([unicode(type) for type in appointment.appointment_types.all()])
appointment_types = ", ".join(
[unicode(appointment_type) for appointment_type in appointment.appointment_types.all()])
else:
title = appointment.comment
type = ", ".join([type.code for type in appointment.appointment_types.all()])
appointment_type = ", ".join([appointment_type.code for appointment_type in appointment.appointment_types.all()])
time = ""
if appointment.datetime_when is not None:
time = appointment.datetime_when.strftime('%Y-%m-%d %H:%M')
......@@ -118,7 +114,7 @@ def serialize_appointment(appointment):
"screening_number": screening_number,
"phone_number": phone_numbers,
"appointment_types": appointment_types,
"type": type,
"type": appointment_type,
"datetime_when": time,
"datetime_until": until,
"comment": appointment.comment,
......
......@@ -208,7 +208,6 @@ function get_calendar_events_function(source, allow_url_redirection, day_headers
}
return function (start, end, timezone, callback) {
if (day_headers !== undefined) {
console.log("XXXX");
$.ajax({
data: {
start_date: start.format(),
......
......@@ -25,10 +25,6 @@ class TestAppointmentApi(TestCase):
self.worker = create_worker(self.user)
self.client.login(username=username, password=password)
def test_appointments_invalid(self):
response = self.client.get(reverse('web.api.appointments', kwargs={'type': "bla"}))
self.assertEqual(response.status_code, 500)
def test_appointments_valid(self):
place = "Some new flying team location"
name = "Piotrek"
......
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