diff --git a/smash/web/api_views/appointment.py b/smash/web/api_views/appointment.py index 4951cbb738bfc7f8167ab43e8f88bab99dc99480..ef22810c30b6557c0ee56dad5a5a9f08a926b023 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 65b3acf7c14b86c05b3ba3e9ed572920aa7820f0..27c25a15abe1ae70652f65da1dd5775c6b161eba 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 81a642dc496a82ee4af2cf402e88b9ce640c42c2..8b975928d7d641a20399fa98118d4ca3257c8881 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({