agenda: don't authorized edition of patient for a periodic appointment
Fixes #2791
This commit is contained in:
parent
ebd4ae0748
commit
c082b14ee1
|
@ -90,6 +90,21 @@ class NewAppointmentForm(BaseForm):
|
|||
appointment.services = [self.service]
|
||||
return appointment
|
||||
|
||||
class UpdatePeriodicAppointmentForm(NewAppointmentForm):
|
||||
|
||||
def __init__(self, instance, service=None, **kwargs):
|
||||
super(UpdatePeriodicAppointmentForm, self).__init__(instance,
|
||||
service, **kwargs)
|
||||
if instance and instance.pk:
|
||||
self.fields['patient'].required = False
|
||||
self.fields['patient'].widget.attrs['disabled'] = 'disabled'
|
||||
|
||||
def clean_patient(self):
|
||||
instance = getattr(self, 'instance', None)
|
||||
if instance:
|
||||
return instance.patient
|
||||
else:
|
||||
return self.cleaned_data.get('patient', None)
|
||||
|
||||
class UpdateAppointmentForm(NewAppointmentForm):
|
||||
class Meta(NewAppointmentForm.Meta):
|
||||
|
|
|
@ -49,8 +49,12 @@
|
|||
</td>
|
||||
<td {% if form.patient.field.required %}class="required"{% endif %}>
|
||||
<h4>{{ form.patient.label_tag }}</h4>
|
||||
{% if object.exception_to and not object.exception_to.canceled %}
|
||||
{{ object.patient }}
|
||||
{% else %}
|
||||
{{ form.patient }}
|
||||
{{ form.patient.errors }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td {% if form.act_type.field.required %}class="required"{% endif %}>
|
||||
<h4>{{ form.act_type.label_tag }}</h4>
|
||||
|
|
|
@ -22,7 +22,7 @@ from calebasse.actes.models import Act, ValidationMessage
|
|||
from calebasse.actes.validation import (automated_validation, unlock_all_acts_of_the_day)
|
||||
from calebasse import cbv
|
||||
|
||||
from forms import (NewAppointmentForm, NewEventForm,
|
||||
from forms import (NewAppointmentForm, NewEventForm, UpdatePeriodicAppointmentForm,
|
||||
UpdateAppointmentForm, UpdateEventForm, PeriodicEventsSearchForm)
|
||||
|
||||
|
||||
|
@ -184,14 +184,18 @@ class BaseAppointmentView(UpdateView):
|
|||
|
||||
|
||||
class UpdateAppointmentView(TodayOccurrenceMixin, BaseAppointmentView):
|
||||
pass
|
||||
|
||||
def get_form_class(self):
|
||||
if self.object.exception_to and not self.object.exception_to.canceled:
|
||||
return UpdatePeriodicAppointmentForm
|
||||
else:
|
||||
return self.form_class
|
||||
|
||||
|
||||
class UpdatePeriodicAppointmentView(BaseAppointmentView):
|
||||
form_class = NewAppointmentForm
|
||||
template_name = 'agenda/new-appointment.html'
|
||||
|
||||
|
||||
class NewEventView(CreateView):
|
||||
model = Event
|
||||
form_class = NewEventForm
|
||||
|
|
Reference in New Issue