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

Merge branch '152-probelm-when-acquiring-information-about-events' into 'master'

problem with flying team unicode encoding fixed

Closes #152

See merge request !68
parents 0213d3dc 7ffa9ddd
No related branches found
No related tags found
1 merge request!68problem with flying team unicode encoding fixed
Pipeline #
......@@ -212,7 +212,7 @@ def events(request, date):
'link_who': link.worker_id,
'link_end': link_end,
'location': str(appointment.location),
'flying_team_location': str(appointment.flying_team),
'flying_team_location': unicode(appointment.flying_team),
'appointment_start': appointment.datetime_when.replace(tzinfo=None),
'appointment_end': appointment.datetime_when.replace(tzinfo=None, hour=19, minute=0),
}
......
......@@ -5,7 +5,6 @@
{% block styles %}
{{ block.super }}
{% include "includes/datetimepicker.css.html" %}
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}"/>
{% endblock styles %}
{% block ui_active_tab %}'workers'{% endblock ui_active_tab %}
......@@ -70,16 +69,5 @@
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script>
<script>
// If ever to debug and thinking why it doesn't work => look if there is 'null' in data from API
$.get("{% url 'web.api.specializations' %}", function (data) {
new Awesomplete(document.querySelector("#id_specialization")).list = data.specializations;
});
$.get("{% url 'web.api.units' %}", function (data) {
new Awesomplete(document.querySelector("#id_unit")).list = data.units;
});
</script>
{% include "includes/datetimepicker.js.html" %}
{% endblock scripts %}
......@@ -7,9 +7,10 @@ from django.test import Client
from django.test import TestCase
from django.urls import reverse
from web.models import Worker, Availability, Holiday
from web.models import Worker, Availability, Holiday, AppointmentTypeLink
from web.models.constants import TUESDAY_AS_DAY_OF_WEEK
from web.tests.functions import create_worker
from web.tests.functions import create_worker, create_subject, create_appointment, create_flying_team, create_visit, \
create_appointment_type
class TestApi(TestCase):
......@@ -32,6 +33,31 @@ class TestApi(TestCase):
self.assertEqual(0, len(availabilities))
def test_events_with_appointments(self):
flying_team = create_flying_team()
flying_team.place = "UTF name: ät"
flying_team.save()
subject = create_subject()
visit = create_visit(subject)
appointment = create_appointment(visit)
appointment.datetime_when = datetime.datetime.now().replace(year=2017, month=9, day=5,
hour=12)
appointment.length = 30
appointment.location = self.worker.locations.all()[0]
appointment.flying_team = flying_team
appointment.save()
AppointmentTypeLink.objects.create(appointment=appointment, appointment_type=create_appointment_type())
response = self.client.get(reverse('web.api.events', kwargs={'date': "2017-09-05"}))
self.assertEqual(response.status_code, 200)
content = json.loads(response.content)
self.assertEqual(0, len(content['availabilities']))
self.assertEqual(1, len(content['data'][0]['events']))
def test_nonempty_availabilities(self):
availability = Availability.objects.create(person=self.worker, day_number=TUESDAY_AS_DAY_OF_WEEK,
available_from="8:00", available_till="16:00")
......
......@@ -116,6 +116,7 @@ def create_appointment(visit=None, when=None):
visit=visit,
length=30,
location=get_test_location(),
status=Appointment.APPOINTMENT_STATUS_SCHEDULED,
datetime_when=when)
......@@ -128,8 +129,10 @@ def create_configuration_item():
return item
def create_flying_team():
result = FlyingTeam.objects.create()
def create_flying_team(place=None):
if place is None:
place = "CHEM"
result = FlyingTeam.objects.create(place=place)
return result
......
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