From 3ac611875f3e2faaac977fad251e1d657efc0633 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Thu, 7 Dec 2017 11:17:35 +0100 Subject: [PATCH] flying team is passed as separate field from api (not a part of location name) --- smash/web/api_views/appointment.py | 18 +++++++----------- smash/web/static/js/appointment.js | 1 + smash/web/templates/appointments/index.html | 6 +++++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/smash/web/api_views/appointment.py b/smash/web/api_views/appointment.py index 4951cbb7..ef22810c 100644 --- a/smash/web/api_views/appointment.py +++ b/smash/web/api_views/appointment.py @@ -6,6 +6,7 @@ from django.http import JsonResponse from django.urls import reverse from django.utils import timezone +from web.api_views.serialization_utils import serialize_datetime, location_to_str, flying_team_to_str from web.models import Appointment from web.views.appointment import APPOINTMENT_LIST_GENERIC, APPOINTMENT_LIST_UNFINISHED, APPOINTMENT_LIST_APPROACHING from web.views.notifications import get_filter_locations, \ @@ -95,17 +96,11 @@ def serialize_appointment(appointment): title = appointment.comment 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') - until = "" - if appointment.datetime_when is not None: - until = appointment.datetime_until().strftime('%Y-%m-%d %H:%M') - - if appointment.flying_team is None: - location = unicode(appointment.location) - else: - location = unicode(appointment.location) + " (" + unicode(appointment.flying_team) + ")" + time = serialize_datetime(appointment.datetime_when) + until = serialize_datetime(appointment.datetime_until()) + + location = location_to_str(appointment.location) + flying_team = flying_team_to_str(appointment.flying_team) result = { "subject": subject_string, @@ -121,6 +116,7 @@ def serialize_appointment(appointment): "color": appointment.color(), "id": appointment.id, "location": location, + "flying_team": flying_team, "url": reverse('web.views.appointment_edit', kwargs={'id': str(appointment.id)}) } return result diff --git a/smash/web/static/js/appointment.js b/smash/web/static/js/appointment.js index 65b3acf7..27c25a15 100644 --- a/smash/web/static/js/appointment.js +++ b/smash/web/static/js/appointment.js @@ -256,6 +256,7 @@ function get_calendar_events_function(source, allow_url_redirection, day_headers color: entry.color, nd_number: entry.nd_number, location: entry.location, + flying_team: entry.flying_team, screening_number: entry.screening_number, phone_number: entry.phone_number, appointment_types: entry.appointment_types diff --git a/smash/web/templates/appointments/index.html b/smash/web/templates/appointments/index.html index 81a642dc..8b975928 100644 --- a/smash/web/templates/appointments/index.html +++ b/smash/web/templates/appointments/index.html @@ -137,7 +137,11 @@ content += '<li>Appointment types: ' + event.appointment_types + '</li>' } if (event.location) { - content += '<li>Location: ' + event.location + '</li>' + var location = event.location; + if (event.flying_team) { + location += " (" + event.flying_team + ")"; + } + content += '<li>Location: ' + location + '</li>' } content += "</ul>"; $(element).popover({ -- GitLab