commit a869df8f3d5ab8e773540b5099a4781a5958f992
Author: Mikaël Ates <mates@entrouvert.com>
Date:   Fri Oct 3 09:28:16 2014 +0200

    dossiers: use the new comment field for addresses and contacts (fixes #4372).

diff --git a/calebasse/dossiers/forms.py b/calebasse/dossiers/forms.py
index 5aa3adc1..3e8fd3ee 100644
--- a/calebasse/dossiers/forms.py
+++ b/calebasse/dossiers/forms.py
@@ -173,13 +173,20 @@ class PaperIDForm(ModelForm):
         model = PatientRecord
         fields = ('paper_id', )
 
+class AddrCommentForm(ModelForm):
+    class Meta:
+        model = PatientRecord
+        fields = ('addresses_contacts_comment', )
+        widgets = {
+                'addresses_contacts_comment': forms.Textarea(attrs={'cols': 50, 'rows': 2}),
+                }
+
 class PolicyHolderForm(ModelForm):
     class Meta:
         model = PatientRecord
-        fields = ('policyholder', 'contact_comment')
-        widgets = { 
+        fields = ('policyholder',)
+        widgets = {
                 'policyholder': forms.RadioSelect(),
-                'contact_comment': forms.Textarea(attrs={'cols': 50, 'rows': 2}),
                 }
 
 class PatientContactForm(ModelForm):
diff --git a/calebasse/dossiers/templates/dossiers/generate_rtf_form.html b/calebasse/dossiers/templates/dossiers/generate_rtf_form.html
index 9b1b2328..fcffb18e 100644
--- a/calebasse/dossiers/templates/dossiers/generate_rtf_form.html
+++ b/calebasse/dossiers/templates/dossiers/generate_rtf_form.html
@@ -24,15 +24,14 @@ errors:
 </ul>
 
 <h3>Adresse</h3>
-<p><strong>Commentaire :</strong> <br />
-{{ object.policyholder.contact_comment }}
-</p>
+
+{% if object.addresses_contacts_comment %}<p>Commentaire : <strong>{{ object.addresses_contacts_comment }}</strong></p>{% endif %}
 
 <ul class="addresses">
   {% for address in object.addresses.all %}
   <li>
   <span>{{ address.display_name }} {% if address.phone %}(Tél : {{ address.phone }}){% endif %}</span>
-  <pre>{{ address.comment }}</pre>
+  {% if address.comment %}<p><em>Commentaire : {{ address.comment }}</em></p>{% endif %}
   <ul>
     {% if address.recipient %}
     <li><input type="radio" name="contact" id="contact_{{ address.id }}_{{ contact.id }}"
diff --git a/calebasse/dossiers/templates/dossiers/patientrecord_print.html b/calebasse/dossiers/templates/dossiers/patientrecord_print.html
index 7b3957db..e5e4d54a 100644
--- a/calebasse/dossiers/templates/dossiers/patientrecord_print.html
+++ b/calebasse/dossiers/templates/dossiers/patientrecord_print.html
@@ -56,9 +56,7 @@
         {% else %}
         <label class="highlight">Aucun lieu de vie d'indiqué</label>
         {% endif %}
-        {% if object.contact_comment %}
-        <p>{{ object.contact_comment }}</p>
-        {% endif %}
+        {% if object.addresses_contacts_comment %}<p>Commentaire : <strong>{{ object.addresses_contacts_comment }}</strong></p>{% endif %}
         {% if object.addresses.all %}
         <ul>
           {% for address in object.addresses.all %}
diff --git a/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html b/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html
index d2337295..bfa4c23b 100644
--- a/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html
+++ b/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html
@@ -20,7 +20,7 @@
       {% else %}
       <label class="highlight">Aucun lieu de vie n'est indiqué.</label>
       {% endif %}
-      {% if object.contact_comment %}<p>{{ object.contact_comment|linebreaks }}</p>{% endif %}
+      {% if object.addresses_contacts_comment %}<p><strong>{{ object.addresses_contacts_comment }}</strong></p>{% endif %}
         {% if object.addresses.all %}
         <ul>
           {% for address in object.addresses.all %}
diff --git a/calebasse/dossiers/templates/dossiers/patientrecord_tab3_adresses.html b/calebasse/dossiers/templates/dossiers/patientrecord_tab3_adresses.html
index 3e6a9dc2..f94c2489 100644
--- a/calebasse/dossiers/templates/dossiers/patientrecord_tab3_adresses.html
+++ b/calebasse/dossiers/templates/dossiers/patientrecord_tab3_adresses.html
@@ -5,7 +5,6 @@
 {% load dossiers %}
 {% block content %}
 <div id="tabs-3">
-  <form method="post" action="tab3" id="policyholder-form" class="patientrecordform">{% csrf_token %}
     <p>
     {% if nb_place_of_lifes == 1 %}
     <span>Un lieu de vie unique est indiqué</span>
@@ -15,15 +14,19 @@
     <span class="highlight">Aucun lieu de vie n'est indiqué.</span>
     {% endif %}
     </p>
+    <form method="post" action="tab3" class="autosubmit-form patientrecordform">{% csrf_token %}
     <p>
     <label>Commentaire <button class="save enable-on-change btn-maj">✔</button></label>
-    {{ forms.policyholder.contact_comment }}
+    {{ forms.comment.addresses_contacts_comment }}
     </p>
+    </form>
     <p>
     <button type="button" id="new-address-btn" class="icon-home-space">Nouvelle adresse</button>
     <button type="button" id="new-contact-btn" class="icon-user-space">Nouveau contact</button>
     </p>
 
+  <form method="post" action="tab3" class="autosubmit-form patientrecordform">{% csrf_token %}
+
     <div class="contact patient">
       <h4 class="icon-user-space">Patient</h4>
       <div class="right">Assuré
diff --git a/calebasse/dossiers/views.py b/calebasse/dossiers/views.py
index 01cf0435..8f792d21 100644
--- a/calebasse/dossiers/views.py
+++ b/calebasse/dossiers/views.py
@@ -334,7 +334,8 @@ class PatientRecordAddrView(cbv.ServiceViewMixin, cbv.NotificationDisplayView, c
     model = PatientRecord
     forms_classes = {
             'contact': forms.PatientContactForm,
-            'policyholder': forms.PolicyHolderForm
+            'policyholder': forms.PolicyHolderForm,
+            'comment' : forms.AddrCommentForm,
             }
     template_name = 'dossiers/patientrecord_tab3_adresses.html'
     success_url = './view#tab=2'
diff --git a/calebasse/static/css/dossiers.css b/calebasse/static/css/dossiers.css
index ad068389..ed9e06ff 100644
--- a/calebasse/static/css/dossiers.css
+++ b/calebasse/static/css/dossiers.css
@@ -99,7 +99,7 @@ div#tabs-4 div div.buttons {
     width: 85%;
 }
 
-#id_policyholder-contact_comment {
+#id_comment-addresses_contacts_comment {
     margin: 0;
 }
 
diff --git a/calebasse/static/js/calebasse.dossiers.js b/calebasse/static/js/calebasse.dossiers.js
index c4523c21..ea54235c 100644
--- a/calebasse/static/js/calebasse.dossiers.js
+++ b/calebasse/static/js/calebasse.dossiers.js
@@ -201,7 +201,7 @@ function load_tab3_addresses() {
       });
     }
     $('.autosubmit').on('click', function() {
-        $('#policyholder-form').submit();
+        $('.autosubmit-form').submit();
     });
     $('#new-contact-btn').click(function() {
         generic_ajaxform_dialog('contact/new', 'Ajouter un contact',
@@ -475,4 +475,3 @@ function load_tab8_medical() {
     });
 
 })(window.jQuery)
-
