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

hide visit fields in appointment edit view - #73

parent e6e28e30
No related branches found
No related tags found
1 merge request!19hide visit fields in appointment edit view - #73
Pipeline #
......@@ -145,6 +145,7 @@ class AppointmentEditForm(ModelForm):
raise TypeError("Worker not defined for: " + user.username)
super(ModelForm, self).__init__(*args, **kwargs)
self.fields.pop('visit')
def clean_location(self):
location = self.cleaned_data['location']
......
......@@ -19,18 +19,23 @@ class AppointmentEditFormTests(TestCase):
self.sample_data = {'first_name': 'name',
'length': '50',
'visit': self.visit.id,
'location': location.id,
'datetime_when': "2020-01-01",
}
add_form = AppointmentAddForm(user=self.user, data=self.sample_data)
self.sample_data_with_visit = self.sample_data
self.sample_data_with_visit['visit'] = self.visit.id
add_form = AppointmentAddForm(user=self.user, data=self.sample_data_with_visit)
self.appointment = add_form.save()
def test_validation(self):
form = AppointmentEditForm(user=self.user, data=self.sample_data)
self.assertTrue(form.is_valid())
def test_no_visit_field(self):
form = AppointmentEditForm(user=self.user, data=self.sample_data)
self.assertNotIn('visit', form.fields)
def test_validation_invalid_location(self):
self.sample_data['location'] = create_location(name="xxx").id
form = AppointmentEditForm(user=self.user, data=self.sample_data)
......
......@@ -717,11 +717,6 @@ def appointment_edit(request, id):
if appointment_form.is_valid() and subject_form.is_valid():
appointment_form.save()
subject_form.save()
data = appointment_form.cleaned_data
vis = data['visit']
get_object_or_404(Visit, id=vis.id)
return redirect(appointments)
else:
appointment_form = AppointmentEditForm(instance=the_appointment, user=request.user, prefix="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