From 95593005d9e74ed7a558a80d0483477ad6bec775 Mon Sep 17 00:00:00 2001 From: Serghei MIHAI Date: Sat, 23 Aug 2014 23:58:55 +0200 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(-) diff --git a/calebasse/cbv.py b/calebasse/cbv.py index 2d60729..7c39752 100644 --- a/calebasse/cbv.py +++ b/calebasse/cbv.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from datetime import datetime, date from dateutil.relativedelta import relativedelta @@ -7,6 +9,7 @@ from django.shortcuts import get_object_or_404 from django.http import Http404, HttpResponseRedirect from django.core.urlresolvers import resolve from django.core.exceptions import ImproperlyConfigured +from django.contrib import messages from calebasse.ressources.models import Service from calebasse.middleware.request import get_request @@ -14,6 +17,13 @@ from calebasse.utils import is_super_user, is_validator HOME_SERVICE_COOKIE = 'home-service' +class NotificationDisplayView(object): + + def form_valid(self, form): + valid = super(NotificationDisplayView, self).form_valid(form) + messages.info(self.request, u'Modification enregistrée avec succès') + return valid + class ReturnToObjectMixin(object): def get_success_url(self): return '../#object-' + str(self.object.pk) diff --git a/calebasse/dossiers/views.py b/calebasse/dossiers/views.py index 199a093..01cf043 100644 --- a/calebasse/dossiers/views.py +++ b/calebasse/dossiers/views.py @@ -94,17 +94,12 @@ class NewPatientContactView(RecordPatientRecordIdMixing, cbv.CreateView): new_patient_contact = NewPatientContactView.as_view() -class UpdatePatientContactView(RecordPatientRecordIdMixing, cbv.UpdateView): +class UpdatePatientContactView(RecordPatientRecordIdMixing, cbv.NotificationDisplayView, cbv.UpdateView): model = PatientContact form_class = forms.PatientContactForm template_name = 'dossiers/patientcontact_new.html' success_url = '../../view#tab=2' - def form_valid(self, form): - valid = super(UpdatePatientContactView, self).form_valid(form) - messages.info(self.request, u'Modification enregistrée avec succès') - return valid - update_patient_contact = UpdatePatientContactView.as_view() class DeletePatientContactView(cbv.DeleteView): @@ -143,18 +138,12 @@ class NewPatientAddressView(cbv.CreateView): new_patient_address = NewPatientAddressView.as_view() -class UpdatePatientAddressView(cbv.UpdateView): +class UpdatePatientAddressView(cbv.NotificationDisplayView, cbv.UpdateView): model = PatientAddress form_class = forms.PatientAddressForm template_name = 'dossiers/patientaddress_new.html' success_url = '../../view#tab=2' - def form_valid(self, form): - messages.add_message(self.request, - messages.INFO, - u'Modification enregistrée avec succès.') - return super(UpdatePatientAddressView, self).form_valid(form) - update_patient_address = UpdatePatientAddressView.as_view() class DeletePatientAddressView(cbv.DeleteView): @@ -341,7 +330,7 @@ class PatientRecordAdmView(cbv.UpdateView): tab2_fiche_adm = PatientRecordAdmView.as_view() -class PatientRecordAddrView(cbv.ServiceViewMixin, cbv.MultiUpdateView): +class PatientRecordAddrView(cbv.ServiceViewMixin, cbv.NotificationDisplayView, cbv.MultiUpdateView): model = PatientRecord forms_classes = { 'contact': forms.PatientContactForm, -- 2.1.0