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

Merge remote-tracking branch 'origin/master' into 124-connection-to-redcap

parents 1f420cd1 776e73c5
No related branches found
No related tags found
1 merge request!71languages are not included in default merge inconsistencies
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),
}
......
......@@ -269,7 +269,7 @@ desired effect
{% block footer %}
<!-- To the right -->
<div class="pull-right hidden-xs">
Version: <strong>preview 0.7.0</strong> (21 June 2017)
Version: <strong>0.8.0</strong> (20 September 2017)
</div>
<!-- Default to the left -->
......
......@@ -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 %}
......@@ -25,8 +25,10 @@
<div class="box-header with-border">
<a href="{% url 'web.views.subject_edit' id %}"
class="btn btn-block btn-default">Subject</a>
<a href="{% url 'web.views.visit_add' id %}" type="button" class="btn btn-block btn-default">Add
visit</a>
{% if allow_add_visit %}
<a href="{% url 'web.views.visit_add' id %}" type="button" class="btn btn-block btn-default">
Add visit</a>
{% endif %}
</div>
<div class="box-body">
......
......@@ -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
......
......@@ -42,6 +42,14 @@ class SubjectsViewTests(TestCase):
response = self.client.get(reverse('web.views.subject_visit_details', kwargs={'id': subject.id}))
self.assertEqual(response.status_code, 200)
self.assertFalse("Add visit" in response.content)
def test_render_subject_visit_details(self):
subject = create_subject()
response = self.client.get(reverse('web.views.subject_visit_details', kwargs={'id': subject.id}))
self.assertEqual(response.status_code, 200)
self.assertTrue("Add visit" in response.content)
def test_save_subject_edit(self):
subject = create_subject()
......
......@@ -82,9 +82,10 @@ def subject_edit(request, id):
def subject_visit_details(request, id):
subjects = get_object_or_404(Subject, id=id)
visits = subjects.visit_set.all()
subject_to_be_viewed = get_object_or_404(Subject, id=id)
visits = subject_to_be_viewed.visit_set.all()
visits_data = []
allow_add_visit = True
for visit in visits:
appointments = visit.appointment_set.all()
finished = visit.is_finished
......@@ -92,5 +93,8 @@ def subject_visit_details(request, id):
visit_title = visit.follow_up_title()
visit_form = VisitDetailForm(instance=visit)
visits_data.append((visit_form, appointments, finished, visit_id, visit_title))
if not visit.is_finished:
allow_add_visit = False
return wrap_response(request, 'subjects/visitdetails.html', {'display': visits_data, "id": id})
return wrap_response(request, 'subjects/visitdetails.html',
{'display': visits_data, "id": id, "allow_add_visit": allow_add_visit})
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