Skip to content
Snippets Groups Projects
Commit 6470185f authored by Valentin Groues's avatar Valentin Groues :eyes:
Browse files

bug fix for daily planning not supporting appointment updates #166

parent 7e92e5eb
No related branches found
No related tags found
1 merge request!81Resolve "update of appointment clears data from daily planning"
Pipeline #
...@@ -241,11 +241,20 @@ class AppointmentEditForm(ModelForm): ...@@ -241,11 +241,20 @@ class AppointmentEditForm(ModelForm):
def save(self, commit=True): def save(self, commit=True):
appointment = super(AppointmentEditForm, self).save(commit) appointment = super(AppointmentEditForm, self).save(commit)
AppointmentTypeLink.objects.filter(appointment=appointment).delete() appointment_type_links = AppointmentTypeLink.objects.filter(appointment=appointment).all()
appointment_types_from_links = []
appointment_types = self.cleaned_data['appointment_types'] appointment_types = self.cleaned_data['appointment_types']
for appointment_type_link in appointment_type_links:
if appointment_type_link.appointment_type not in appointment_types:
# we delete appointment links for appointments types that have been removed
appointment_type_link.delete()
else:
appointment_types_from_links.append(appointment_type_link.appointment_type)
for appointment_type in appointment_types: for appointment_type in appointment_types:
appointment_type_link = AppointmentTypeLink(appointment=appointment, appointment_type=appointment_type) if appointment_type not in appointment_types_from_links:
appointment_type_link.save() # we create new appointment links for appointements types that have been added
appointment_type_link = AppointmentTypeLink(appointment=appointment, appointment_type=appointment_type)
appointment_type_link.save()
return appointment return appointment
......
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