Project

General

Profile

« Previous | Next » 

Revision c082b14e

Added by Jérôme Schneider almost 13 years ago

agenda: don't authorized edition of patient for a periodic appointment

Fixes #2791

View differences:

calebasse/agenda/forms.py
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):
calebasse/agenda/templates/agenda/appointment.html
</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>
calebasse/agenda/views.py
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)
......
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

Also available in: Unified diff