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

Merge branch '162-sometimes-saving-daily-planning-doesn-t-work' into 'master'

Resolve "sometimes saving daily planning doesn't work"

Closes #162

See merge request !76
parents 9ff1a72c 8210d2af
No related branches found
No related tags found
1 merge request!76Resolve "sometimes saving daily planning doesn't work"
Pipeline #
......@@ -217,6 +217,8 @@ $(document).ready(function () {
console.log(data);
saveButton.css('border-color', 'red');
showErrorInfo("There was an unexpected problem with saving data. " +
"Please contact administrators.");
setTimeout(function () {
saveButton.delay(200).css('border-color', currentBorder);
}, 200);
......
......@@ -24,6 +24,7 @@ $(document).ready(function () {
return true;
}
})
});
$.ajaxSetup({
......@@ -49,4 +50,24 @@ $.ajaxSetup({
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
}
}
});
\ No newline at end of file
});
function showErrorInfo(content) {
var errorDialogDiv = document.createElement("div");
document.body.appendChild(errorDialogDiv);
errorDialogDiv.innerHTML = '<div class="modal-dialog" role="document">' +
'<div class="modal-content">' +
'<div class="modal-header">ERROR' +
'<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
'<span aria-hidden="true">&times;</span></button>' +
'</div>' +
'<div name="error-content" class="modal-body">' + content + '</div>' +
'<div class="modal-footer">' +
'<button type="button" class="btn btn-outline pull-right" data-dismiss="modal">Close</button>' +
'</div>' +
'</div>' +
'</div>';
$(errorDialogDiv).attr("role", "dialog");
$(errorDialogDiv).addClass("modal modal-danger fade");
$(errorDialogDiv).modal("show");
}
\ No newline at end of file
import datetime
import logging
from django.urls import reverse
......@@ -9,6 +10,8 @@ from web.models import Appointment, Subject
from web.views.notifications import get_today_midnight_date
from . import LoggedInTestCase
logger = logging.getLogger(__name__)
class AppointmentsViewTests(LoggedInTestCase):
def setUp(self):
......@@ -71,6 +74,22 @@ class AppointmentsViewTests(LoggedInTestCase):
self.assertEqual(response.status_code, 200)
def test_save_as_finished_appointments_edit_without_visit(self):
appointment = create_appointment(None, get_today_midnight_date())
appointment.visit = None
appointment.save()
form_appointment = AppointmentEditForm(user=self.user, instance=appointment, prefix="appointment")
form_data = {}
for key, value in form_appointment.initial.items():
if value is not None:
form_data['appointment-{}'.format(key)] = format_form_field(value)
form_data['appointment-status'.format(key)] = Appointment.APPOINTMENT_STATUS_FINISHED
self.client.post(reverse('web.views.appointment_edit', kwargs={'id': appointment.id}), data=form_data)
appointment_result = Appointment.objects.filter(id=appointment.id)[0]
self.assertEqual(Appointment.APPOINTMENT_STATUS_FINISHED, appointment_result.status)
def test_save_appointments_edit(self):
subject = create_subject()
visit = create_visit(subject)
......
......@@ -80,7 +80,7 @@ def appointment_edit(request, id):
subject_form.save()
the_appointment = get_object_or_404(Appointment, id=id)
if the_appointment.status == Appointment.APPOINTMENT_STATUS_FINISHED:
if the_appointment.status == Appointment.APPOINTMENT_STATUS_FINISHED and the_appointment.visit is not None:
subject = Subject.objects.get(id=the_appointment.visit.subject.id)
subject.information_sent = True
if the_appointment.flying_team is not None and subject.flying_team is None:
......
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