Browse Source

Fix js paiement

granuban
Gabriel Detraz 8 years ago
committed by root
parent
commit
84617e2460
  1. 1
      cotisations/forms.py
  2. 5
      cotisations/models.py
  3. 2
      cotisations/templates/cotisations/aff_article.html
  4. 6
      cotisations/templates/cotisations/new_facture.html

1
cotisations/forms.py

@ -34,6 +34,7 @@ class NewFactureForm(ModelForm):
self.fields['cheque'].label = 'Numero de chèque' self.fields['cheque'].label = 'Numero de chèque'
self.fields['banque'].empty_label = "Non renseigné" self.fields['banque'].empty_label = "Non renseigné"
self.fields['paiement'].empty_label = "Séléctionner un moyen de paiement" self.fields['paiement'].empty_label = "Séléctionner un moyen de paiement"
self.fields['paiement'].widget.attrs['data-cheque'] = Paiement.objects.filter(type_paiement=1).first().id
class Meta: class Meta:
model = Facture model = Facture

5
cotisations/models.py

@ -172,6 +172,11 @@ class Paiement(models.Model):
def clean(self): def clean(self):
self.moyen = self.moyen.title() self.moyen = self.moyen.title()
def save(self, *args, **kwargs):
if Paiement.objects.filter(type_paiement=1).count() > 1:
raise ValidationError("On ne peut avoir plusieurs mode de paiement chèque")
super(Paiement, self).save(*args, **kwargs)
class Cotisation(models.Model): class Cotisation(models.Model):
PRETTY_NAME = "Cotisations" PRETTY_NAME = "Cotisations"

2
cotisations/templates/cotisations/aff_article.html

@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr> <tr>
<td>{{ article.name }}</td> <td>{{ article.name }}</td>
<td>{{ article.prix }}</td> <td>{{ article.prix }}</td>
<td>{{ article.cotisation }}</td> <td>{{ article.iscotisation }}</td>
<td>{{ article.duration }}</td> <td>{{ article.duration }}</td>
<td class="text-right"> <td class="text-right">
{% if is_trez %} {% if is_trez %}

6
cotisations/templates/cotisations/new_facture.html

@ -109,9 +109,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
} }
function set_cheque_info_visibility(){ function set_cheque_info_visibility(){
var paiement = document.getElementById("id_paiement"); var visible = document.getElementById("id_paiement").value == document.getElementById("id_paiement").getAttribute('data-cheque');
var visible = paiement.value != '' && p = document.getElementById("id_paiement")
paiement.children[paiement.value].dataset['type'] == 'check'; console.log(p);
var display = 'none'; var display = 'none';
if (visible) { if (visible) {
display = 'block'; display = 'block';

Loading…
Cancel
Save