Projet

Général

Profil

0001-dossiers-display-notification-on-patient-record-cont.patch

Serghei Mihai (congés, retour 15/05), 24 août 2014 00:04

Télécharger (3,61 ko)

Voir les différences:

Subject: [PATCH] dossiers: display notification on patient record contacts and
 addresses update

Closes #4807
 calebasse/cbv.py            | 10 ++++++++++
 calebasse/dossiers/views.py | 17 +++--------------
 2 files changed, 13 insertions(+), 14 deletions(-)
calebasse/cbv.py
1
# -*- coding: utf-8 -*-
2

  
1 3
from datetime import datetime, date
2 4
from dateutil.relativedelta import relativedelta
3 5

  
......
7 9
from django.http import Http404, HttpResponseRedirect
8 10
from django.core.urlresolvers import resolve
9 11
from django.core.exceptions import ImproperlyConfigured
12
from django.contrib import messages
10 13

  
11 14
from calebasse.ressources.models import Service
12 15
from calebasse.middleware.request import get_request
......
14 17

  
15 18
HOME_SERVICE_COOKIE = 'home-service'
16 19

  
20
class NotificationDisplayView(object):
21

  
22
    def form_valid(self, form):
23
        valid = super(NotificationDisplayView, self).form_valid(form)
24
        messages.info(self.request, u'Modification enregistrée avec succès')
25
        return valid
26

  
17 27
class ReturnToObjectMixin(object):
18 28
    def get_success_url(self):
19 29
        return '../#object-' + str(self.object.pk)
calebasse/dossiers/views.py
94 94

  
95 95
new_patient_contact = NewPatientContactView.as_view()
96 96

  
97
class UpdatePatientContactView(RecordPatientRecordIdMixing, cbv.UpdateView):
97
class UpdatePatientContactView(RecordPatientRecordIdMixing, cbv.NotificationDisplayView, cbv.UpdateView):
98 98
    model = PatientContact
99 99
    form_class = forms.PatientContactForm
100 100
    template_name = 'dossiers/patientcontact_new.html'
101 101
    success_url = '../../view#tab=2'
102 102

  
103
    def form_valid(self, form):
104
        valid = super(UpdatePatientContactView, self).form_valid(form)
105
        messages.info(self.request, u'Modification enregistrée avec succès')
106
        return valid
107

  
108 103
update_patient_contact = UpdatePatientContactView.as_view()
109 104

  
110 105
class DeletePatientContactView(cbv.DeleteView):
......
143 138

  
144 139
new_patient_address = NewPatientAddressView.as_view()
145 140

  
146
class UpdatePatientAddressView(cbv.UpdateView):
141
class UpdatePatientAddressView(cbv.NotificationDisplayView, cbv.UpdateView):
147 142
    model = PatientAddress
148 143
    form_class = forms.PatientAddressForm
149 144
    template_name = 'dossiers/patientaddress_new.html'
150 145
    success_url = '../../view#tab=2'
151 146

  
152
    def form_valid(self, form):
153
        messages.add_message(self.request,
154
                messages.INFO,
155
                u'Modification enregistrée avec succès.')
156
        return super(UpdatePatientAddressView, self).form_valid(form)
157

  
158 147
update_patient_address = UpdatePatientAddressView.as_view()
159 148

  
160 149
class DeletePatientAddressView(cbv.DeleteView):
......
341 330

  
342 331
tab2_fiche_adm = PatientRecordAdmView.as_view()
343 332

  
344
class PatientRecordAddrView(cbv.ServiceViewMixin, cbv.MultiUpdateView):
333
class PatientRecordAddrView(cbv.ServiceViewMixin, cbv.NotificationDisplayView, cbv.MultiUpdateView):
345 334
    model = PatientRecord
346 335
    forms_classes = {
347 336
            'contact': forms.PatientContactForm,
348
-