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

problem with flying team unicode encoding fixed

parent 0213d3dc
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): ...@@ -212,7 +212,7 @@ def events(request, date):
'link_who': link.worker_id, 'link_who': link.worker_id,
'link_end': link_end, 'link_end': link_end,
'location': str(appointment.location), '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_start': appointment.datetime_when.replace(tzinfo=None),
'appointment_end': appointment.datetime_when.replace(tzinfo=None, hour=19, minute=0), 'appointment_end': appointment.datetime_when.replace(tzinfo=None, hour=19, minute=0),
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
{% block styles %} {% block styles %}
{{ block.super }} {{ block.super }}
{% include "includes/datetimepicker.css.html" %} {% include "includes/datetimepicker.css.html" %}
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}"/>
{% endblock styles %} {% endblock styles %}
{% block ui_active_tab %}'workers'{% endblock ui_active_tab %} {% block ui_active_tab %}'workers'{% endblock ui_active_tab %}
...@@ -70,16 +69,5 @@ ...@@ -70,16 +69,5 @@
{% block scripts %} {% block scripts %}
{{ block.super }} {{ 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" %} {% include "includes/datetimepicker.js.html" %}
{% endblock scripts %} {% endblock scripts %}
...@@ -7,9 +7,10 @@ from django.test import Client ...@@ -7,9 +7,10 @@ from django.test import Client
from django.test import TestCase from django.test import TestCase
from django.urls import reverse 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.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): class TestApi(TestCase):
...@@ -32,6 +33,31 @@ class TestApi(TestCase): ...@@ -32,6 +33,31 @@ class TestApi(TestCase):
self.assertEqual(0, len(availabilities)) 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): def test_nonempty_availabilities(self):
availability = Availability.objects.create(person=self.worker, day_number=TUESDAY_AS_DAY_OF_WEEK, availability = Availability.objects.create(person=self.worker, day_number=TUESDAY_AS_DAY_OF_WEEK,
available_from="8:00", available_till="16:00") available_from="8:00", available_till="16:00")
......
...@@ -116,6 +116,7 @@ def create_appointment(visit=None, when=None): ...@@ -116,6 +116,7 @@ def create_appointment(visit=None, when=None):
visit=visit, visit=visit,
length=30, length=30,
location=get_test_location(), location=get_test_location(),
status=Appointment.APPOINTMENT_STATUS_SCHEDULED,
datetime_when=when) datetime_when=when)
...@@ -128,8 +129,10 @@ def create_configuration_item(): ...@@ -128,8 +129,10 @@ def create_configuration_item():
return item return item
def create_flying_team(): def create_flying_team(place=None):
result = FlyingTeam.objects.create() if place is None:
place = "CHEM"
result = FlyingTeam.objects.create(place=place)
return result 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