Projet

Général

Profil

« Précédent | Suivant » 

Révision f1a4cd58

Ajouté par Serghei Mihai il y a presque 10 ans

agenda: improving multiple patients adding/updating for a schedule
Reverting "agenda: add multiple patients for a schedule"

This reverts commit 6fdbe2459bab5933e993022a4e85a7b9c3c91004.

Closes #3118

Voir les différences:

calebasse/agenda/forms.py
22 22

  
23 23

  
24 24
class NewAppointmentForm(BaseForm):
25
    patients = AutoCompleteSelectMultipleField('patientrecord')
25
    patient = AutoCompleteSelectMultipleField('patientrecord')
26 26

  
27 27
    class Meta:
28 28
        model = EventWithAct
......
31 31
                'date',
32 32
                'time',
33 33
                'duration',
34
                'patients',
34
                'patient',
35 35
                'participants',
36 36
                'ressource',
37 37
                'act_type',
......
54 54
            self.service = service
55 55
            self.fields['participants'].queryset = \
56 56
                    Worker.objects.for_service(service)
57
            self.fields['patients'].queryset = \
57
            self.fields['patient'].queryset = \
58 58
                    PatientRecord.objects.for_service(service)
59 59
            self.fields['act_type'].queryset = \
60 60
                    ActType.objects.for_service(service) \
......
67 67
        except ValueError:
68 68
            return 0
69 69

  
70
    def clean_patients(self):
71
        patients = self.cleaned_data['patients']
70
    def clean_patient(self):
71
        patients = self.cleaned_data['patient']
72 72
        if patients:
73 73
            return [patient for patient in PatientRecord.objects.filter(pk__in=patients)]
74 74

  
......
79 79
        if cleaned_data.has_key('date') and cleaned_data.has_key('time'):
80 80
            cleaned_data['start_datetime'] = datetime.combine(cleaned_data['date'],
81 81
                    cleaned_data['time'])
82
        if 'patient' in cleaned_data and isinstance(cleaned_data['patient'], list):
83
            # nasty trick to store the list of patients and pass the form
84
            # validation
85
            cleaned_data['patients'] = cleaned_data['patient']
86
            cleaned_data['patient'] = cleaned_data['patient'][0]
82 87
        return cleaned_data
83 88

  
84 89
    def save(self, commit=True):
85
        for patient in self.cleaned_data.pop('patients'):
90

  
91
        patients = self.cleaned_data.pop('patients')
92
        for patient in patients:
86 93
            appointment = forms.save_instance(self, self._meta.model(), commit=False)
87 94
            appointment.start_datetime = datetime.combine(self.cleaned_data['date'],
88 95
                                                          self.cleaned_data['time'])
......
98 105

  
99 106
class UpdateAppointmentForm(NewAppointmentForm):
100 107

  
108
    patient = make_ajax_field(EventWithAct, 'patient', 'patientrecord', False)
109

  
101 110
    class Meta(NewAppointmentForm.Meta):
102 111
        fields = (
103 112
                'start_datetime',
......
110 119
                'act_type',
111 120
        )
112 121

  
122
    def clean_patient(self):
123
        return self.cleaned_data['patient']
124

  
125
    def save(self, commit=True):
126
        appointment = super(NewAppointmentForm, self).save(commit=False)
127
        appointment.start_datetime = datetime.combine(self.cleaned_data['date'],
128
                    self.cleaned_data['time'])
129
        appointment.end_datetime = appointment.start_datetime + timedelta(
130
                minutes=self.cleaned_data['duration'])
131
        appointment.creator = get_request().user
132
        appointment.clean()
133
        if commit:
134
            appointment.save()
135
            appointment.services = [self.service]
136
        return appointment
137

  
113 138

  
114 139
class UpdatePeriodicAppointmentForm(NewAppointmentForm):
115 140
    recurrence_periodicity = forms.ChoiceField(label=u"Périodicité",
calebasse/agenda/templates/agenda/appointment.html
47 47
           {{ form.participants.errors }}
48 48
           </div>
49 49
           </td>
50
           <td {% if form.patients.field.required %}class="required"{% endif %}>
51
           <h4>{{ form.patients.label_tag }}</h4>
52
           <div id="patients">
53
           {{ form.patients }}
54
           {{ form.patients.errors }}
50
           <td {% if form.patient.field.required %}class="required"{% endif %}>
51
           <h4>{{ form.patient.label_tag }}</h4>
52
           <div id="patient">
53
           {% if object.exception_to and not object.exception_to.canceled %}
54
           {{ object.patient }}
55
           {% else %}
56
           {{ form.patient }}
57
           {{ form.patient.errors }}
58
           {% endif %}
55 59
           </div>
56 60
           </td>
57 61
           <td {% if form.act_type.field.required %}class="required"{% endif %}>
calebasse/static/css/style.css
1192 1192
	right: 10px;
1193 1193
}
1194 1194

  
1195
#id_participants_on_deck, #id_patients_on_deck {
1195
#id_participants_on_deck, #id_patient_on_deck {
1196 1196
  max-height: 7em;
1197 1197
  overflow-y: scroll;
1198 1198
}
1199 1199

  
1200

  
1201 1200
ul.messages, ul.ajax_messages {
1202 1201
	position: absolute;
1203 1202
	width: 30em;

Formats disponibles : Unified diff