Commit a38e56cd authored by chirac's avatar chirac

Merge branch 'translation' into 'master'

Translation of cotisation app

See merge request federez/re2o!114
parents 99928c88 f2f4336e
......@@ -25,6 +25,7 @@
Here are defined some functions to check acl on the application.
"""
from django.utils.translation import ugettext as _
def can_view(user):
"""Check if an user can view the application.
......@@ -37,4 +38,4 @@ def can_view(user):
viewing is granted and msg is a message (can be None).
"""
can = user.has_module_perms('cotisations')
return can, None if can else "Vous ne pouvez pas voir cette application."
return can, None if can else _("You don't have the rights to see this application.")
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -8,6 +8,7 @@ from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.views.decorators.csrf import csrf_exempt
from django.utils.datastructures import MultiValueDictKeyError
from django.utils.translation import ugettext as _
from django.http import HttpResponse, HttpResponseBadRequest
from collections import OrderedDict
......@@ -19,10 +20,15 @@ from .payment_utils.comnpay import Payment as ComnpayPayment
@csrf_exempt
@login_required
def accept_payment(request, factureid):
"""
The view called when an online payment has been accepted.
"""
facture = get_object_or_404(Facture, id=factureid)
messages.success(
request,
"Le paiement de {} € a été accepté.".format(facture.prix())
_("The payment of %(amount)s € has been accepted.") % {
amount: facture.prix()
}
)
return redirect(reverse('users:profil', kwargs={'userid':request.user.id}))
......@@ -30,14 +36,22 @@ def accept_payment(request, factureid):
@csrf_exempt
@login_required
def refuse_payment(request):
"""
The view called when an online payment has been refused.
"""
messages.error(
request,
"Le paiement a été refusé."
_("The payment has been refused.")
)
return redirect(reverse('users:profil', kwargs={'userid':request.user.id}))
@csrf_exempt
def ipn(request):
"""
The view called by Comnpay server to validate the transaction.
Verify that we can firmly save the user's action and notify
Comnpay with 400 response if not or with a 200 response if yes
"""
p = ComnpayPayment()
order = ('idTpe', 'idTransaction', 'montant', 'result', 'sec', )
try:
......@@ -52,7 +66,7 @@ def ipn(request):
idTpe = request.POST['idTpe']
idTransaction = request.POST['idTransaction']
# On vérifie que le paiement nous est destiné
# Checking that the payment is actually for us.
if not idTpe == AssoOption.get_cached_value('payment_id'):
return HttpResponseBadRequest("HTTP/1.1 400 Bad Request")
......@@ -63,22 +77,28 @@ def ipn(request):
facture = get_object_or_404(Facture, id=factureid)
# On vérifie que le paiement est valide
# Checking that the payment is valid
if not result:
# Le paiement a échoué : on effectue les actions nécessaires (On indique qu'elle a échoué)
# Payment failed: Cancelling the invoice operation
facture.delete()
# On notifie au serveur ComNPay qu'on a reçu les données pour traitement
# And send the response to Comnpay indicating we have well
# received the failure information.
return HttpResponse("HTTP/1.1 200 OK")
facture.valid = True
facture.save()
# A nouveau, on notifie au serveur qu'on a bien traité les données
# Everything worked we send a reponse to Comnpay indicating that
# it's ok for them to proceed
return HttpResponse("HTTP/1.0 200 OK")
def comnpay(facture, request):
"""
Build a request to start the negociation with Comnpay by using
a facture id, the price and the secret transaction data stored in
the preferences.
"""
host = request.get_host()
p = ComnpayPayment(
str(AssoOption.get_cached_value('payment_id')),
......@@ -105,6 +125,7 @@ def comnpay(facture, request):
return r
# The payment systems supported by re2o
PAYMENT_SYSTEM = {
'COMNPAY' : comnpay,
'NONE' : None
......
......@@ -23,15 +23,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load acl %}
{% load i18n %}
<table class="table table-striped">
<thead>
<tr>
<th>Article</th>
<th>Prix</th>
<th>Type Cotisation</th>
<th>Durée (mois)</th>
<th>Article pour</th>
<th>{% trans "Article" %}</th>
<th>{% trans "Price" %}</th>
<th>{% trans "Cotisation type" %}</th>
<th>{% trans "Duration (month)" %}</th>
<th>{% trans "Concerned users" %}</th>
<th></th>
</tr>
</thead>
......@@ -44,11 +45,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ article.type_user }}</td>
<td class="text-right">
{% can_edit article %}
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'cotisations:edit-article' article.id %}">
<a class="btn btn-primary btn-sm" role="button" title="{% trans "Edit" %}" href="{% url 'cotisations:edit-article' article.id %}">
<i class="fa fa-edit"></i>
</a>
{% acl_end %}
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'cotisations:history' 'article' article.id %}">
<a class="btn btn-info btn-sm" role="button" title="{% trans "Historique" %}" href="{% url 'cotisations:history' 'article' article.id %}">
<i class="fa fa-history"></i>
</a>
</td>
......
......@@ -23,11 +23,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load acl %}
{% load i18n %}
<table class="table table-striped">
<thead>
<tr>
<th>Banque</th>
<th>{% trans "Bank" %}</th>
<th></th>
</tr>
</thead>
......@@ -36,11 +37,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ banque.name }}</td>
<td class="text-right">
{% can_edit banque %}
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'cotisations:edit-banque' banque.id %}">
<a class="btn btn-primary btn-sm" role="button" title="{% trans "Edit" %}" href="{% url 'cotisations:edit-banque' banque.id %}">
<i class="fa fa-edit"></i>
</a>
{% acl_end %}
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'cotisations:history' 'banque' banque.id %}">
<a class="btn btn-info btn-sm" role="button" title="{% trans "Historique" %}" href="{% url 'cotisations:history' 'banque' banque.id %}">
<i class="fa fa-history"></i>
</a>
</td>
......
......@@ -23,20 +23,34 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load acl %}
{% load i18n %}
<div class="table-responsive">
{% if facture_list.paginator %}
{% include "pagination.html" with list=facture_list %}
{% include 'pagination.html' with list=facture_list %}
{% endif %}
<table class="table table-striped">
<thead>
<tr>
<th>{% include "buttons/sort.html" with prefix='cotis' col='user' text='Utilisateur' %}</th>
<th>Designation</th>
<th>Prix total</th>
<th>{% include "buttons/sort.html" with prefix='cotis' col='paiement' text='Moyen de paiement' %}</th>
<th>{% include "buttons/sort.html" with prefix='cotis' col='date' text='Date' %}</th>
<th>{% include "buttons/sort.html" with prefix='cotis' col='id' text='Id facture' %}</th>
<th>
{% trans "User" as tr_user %}
{% include 'buttons/sort.html' with prefix='cotis' col='user' text=tr_user %}
</th>
<th>{% trans "Designation" %}</th>
<th>{% trans "Total price" %}</th>
<th>
{% trans "Payment method" as tr_payment_method %}
{% include 'buttons/sort.html' with prefix='cotis' col='paiement' text=tr_payment_method %}
</th>
<th>
{% trans "Date" as tr_date %}
{% include 'buttons/sort.html' with prefix='cotis' col='date' text=tr_date %}
</th>
<th>
{% trans "Invoice id" as tr_invoice_id %}
{% include 'buttons/sort.html' with prefix='cotis' col='id' text=tr_invoice_id %}
</th>
<th></th>
<th></th>
</tr>
......@@ -50,39 +64,49 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ facture.date }}</td>
<td>{{ facture.id }}</td>
<td>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="editionfacture" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Edition
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="editionfacture">
{% can_edit facture %}
<li><a href="{% url 'cotisations:edit-facture' facture.id %}"><i class="fa fa-dollar-sign"></i> Modifier</a></li>
{% acl_else %}
<li>Facture controlée</li>
{% acl_end %}
{% can_delete facture %}
<li><a href="{% url 'cotisations:del-facture' facture.id %}"><i class="fa fa-trash"></i> Supprimer</a></li>
{% acl_end %}
<li><a href="{% url 'cotisations:history' 'facture' facture.id %}"><i class="fa fa-history"></i> Historique</a></li>
</ul>
</div>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="editinvoice" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{% trans "Edit" %}<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="editinvoice">
{% can_edit facture %}
<li>
<a href="{% url 'cotisations:edit-facture' facture.id %}">
<i class="fa fa-dollar-sign"></i> {% trans "Edit" %}
</a>
</li>
{% acl_else %}
<li>{% trans "Controlled invoice" %}</li>
{% acl_end %}
{% can_delete facture %}
<li>
<a href="{% url 'cotisations:del-facture' facture.id %}">
<i class="fa fa-trash"></i> {% trans "Delete" %}
</a>
</li>
{% acl_end %}
<li>
<a href="{% url 'cotisations:history' 'facture' facture.id %}">
<i class="fa fa-history"></i> {% trans "Historique" %}
</a>
</li>
</ul>
</div>
</td>
<td>
{% if facture.valid %}
{% if facture.valid %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:facture-pdf' facture.id %}">
<i class="fa fa-file-pdf"></i>
PDF
<i class="fa fa-file-pdf"></i> {% trans "PDF" %}
</a>
{% else %}
<i class="text-danger">Facture invalide</i>
{% endif %}
{% else %}
<i class="text-danger">{% trans "Invalidated invoice" %}</i>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% if facture_list.paginator %}
{% include "pagination.html" with list=facture_list %}
{% include 'pagination.html' with list=facture_list %}
{% endif %}
</div>
......@@ -23,11 +23,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load acl %}
{% load i18n %}
<table class="table table-striped">
<thead>
<tr>
<th>Moyen de paiement</th>
<th>{% trans "Payment method" %}</th>
<th></th>
</tr>
</thead>
......@@ -35,12 +36,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<td>{{ paiement.moyen }}</td>
<td class="text-right">
{% can_edit paiement %}
<a class="btn btn-primary btn-sm" role="button" title="Éditer" href="{% url 'cotisations:edit-paiement' paiement.id %}">
{% can_edit paiement %}
<a class="btn btn-primary btn-sm" role="button" title="{% trans "Edit" %}" href="{% url 'cotisations:edit-paiement' paiement.id %}">
<i class="fa fa-edit"></i>
</a>
{% acl_end %}
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'cotisations:history' 'paiement' paiement.id %}">
{% acl_end %}
<a class="btn btn-info btn-sm" role="button" title="{% trans "Historique" %}" href="{% url 'cotisations:history' 'paiement' paiement.id %}">
<i class="fa fa-history"></i>
</a>
</td>
......
......@@ -25,13 +25,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load staticfiles%}
{% load i18n %}
{% block title %}Controle des factures{% endblock %}
{% block title %}{% trans "Invoice control" %}{% endblock %}
{% block content %}
<h2>Controle et validité des factures</h2>
<h2>{% trans "Invoice control and validation" %}</h2>
{% if facture_list.paginator %}
{% include "pagination.html" with list=facture_list %}
{% include 'pagination.html' with list=facture_list %}
{% endif %}
<form class="form" method="post">
{% csrf_token %}
......@@ -39,24 +40,50 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<table class="table table-striped">
<thead>
<tr>
<th>Profil</th>
<th>{% include "buttons/sort.html" with prefix='control' col='name' text='Nom' %}</th>
<th>{% include "buttons/sort.html" with prefix='control' col='surname' text='Prénom' %}</th>
<th>{% include "buttons/sort.html" with prefix='control' col='id' text='Id facture' %}</th>
<th>{% include "buttons/sort.html" with prefix='control' col='user-id' text='Id user' %}</th>
<th>Designation</th>
<th>Prix total</th>
<th>{% include "buttons/sort.html" with prefix='control' col='paiement' text='Moyen de paiement' %}</th>
<th>{% include "buttons/sort.html" with prefix='control' col='date' text='Date' %}</th>
<th>{% include "buttons/sort.html" with prefix='control' col='valid' text='Valide' %}</th>
<th>{% include "buttons/sort.html" with prefix='control' col='control' text='Contrôlée' %}</th>
<th>{% trans "Profil" %}</th>
<th>
{% trans "Last name" as tr_last_name %}
{% include 'buttons/sort.html' with prefix='control' col='name' text=tr_last_name %}
</th>
<th>
{% trans "First name" as tr_first_name %}
{% include 'buttons/sort.html' with prefix='control' col='surname' text=tr_first_name %}
</th>
<th>
{% trans "Invoice id" as tr_invoice_id %}
{% include 'buttons/sort.html' with prefix='control' col='id' text=tr_invoice_id %}
</th>
<th>
{% trans "User id" as tr_user_id %}
{% include 'buttons/sort.html' with prefix='control' col='user-id' text=tr_user_id %}
</th>
<th>{% trans "Designation" %}</th>
<th>{% trans "Total price" %}</th>
<th>
{% trans "Payment method" as tr_payment_method %}
{% include 'buttons/sort.html' with prefix='control' col='paiement' text=tr_payment_method %}
</th>
<th>
{% trans "Date" as tr_date %}
{% include 'buttons/sort.html' with prefix='control' col='date' text=tr_date %}<
/th>
<th>
{% trans "Validated" as tr_validated %}
{% include 'buttons/sort.html' with prefix='control' col='valid' text=tr_validated %}<
/th>
<th>
{% trans "Controlled" as tr_controlled %}
{% include 'buttons/sort.html' with prefix='control' col='control' text=tr_controlled %}
</th>
</tr>
</thead>
{% for form in controlform.forms %}
{% bootstrap_form_errors form %}
<tr>
<td><a href="{% url "users:profil" form.instance.user.id%}" class="btn btn-primary btn-sm" role="button"><i class="fa fa-user"></i></a>
<td>
<a href="{% url 'users:profil' form.instance.user.id%}" class="btn btn-primary btn-sm" role="button">
<i class="fa fa-user"></i>
</a>
</td>
<td>{{ form.instance.user.name }}</td>
<td>{{ form.instance.user.surname }}</td>
......@@ -74,10 +101,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</tr>
{% endfor %}
</table>
{% bootstrap_button "Modifier" button_type="submit" icon="star" %}
{% trans "Edit" as tr_edit %}
{% bootstrap_button tr_edit button_type='submit' icon='star' %}
</form>
{% endblock %}
{% if facture_list.paginator %}
{% include "pagination.html" with list=facture_list %}
{% include 'pagination.html' with list=facture_list %}
{% endif %}
......@@ -24,17 +24,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load bootstrap3 %}
{% load i18n %}
{% block title %}Création et modification de machines{% endblock %}
{% block title %}{% trans "Deletion of cotisations" %}{% endblock %}
{% block content %}
<form class="form" method="post">
{% csrf_token %}
<h4>Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?</h4>
{% bootstrap_button "Confirmer" button_type="submit" icon="trash" %}
<h4>
{% blocktrans %}
Warning. Are you sure you really want te delete this {{ object_name }} object ( {{ objet }} ) ?
{% endblocktrans %}
</h4>
{% trans "Confirm" as tr_confirm %}
{% bootstrap_button tr_confirm button_type='submit' icon='trash' %}
</form>
<br />
<br />
<br />
{% endblock %}
......@@ -26,27 +26,28 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load staticfiles%}
{% load massive_bootstrap_form %}
{% load i18n %}
{% block title %}Création et modification de factures{% endblock %}
{% block title %}{% trans "Invoices creation and edition" %}{% endblock %}
{% block content %}
{% bootstrap_form_errors factureform %}
<form class="form" method="post">
{% csrf_token %}
<h3>Editer la facture</h3>
<h3>{% trans "Edit the invoice" %}</h3>
{% massive_bootstrap_form factureform 'user' %}
{{ venteform.management_form }}
<h3>Articles de la facture</h3>
<h3>{% trans "Invoice's articles" %}</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Désignation</th>
<th>Quantité</th>
<th>{% trans "Designation" %}</th>
<th>{% trans "Quantity" %}</th>
</tr>
</thead>
{% for form in venteform.forms %}
{% bootstrap_form_errors form %}
{% for form in venteform.forms %}
{% bootstrap_form_errors form %}
<tr>
<td>{{ form.name }}</td>
<td>{{ form.number }}</td>
......@@ -56,7 +57,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</tr>
{% endfor %}
</table>
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
{% trans "Confirm" as tr_confirm %}
{% bootstrap_button tr_confirm button_type='submit' icon='star' %}
</form>
{% endblock %}
......@@ -25,8 +25,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load staticfiles%}
{% load i18n %}
{% block title %}Création et modification de factures{% endblock %}
{% block title %}{% trans "Invoices creation and edition" %}{% endblock %}
{% block content %}
{% bootstrap_form_errors factureform %}
......@@ -34,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<form class="form" method="post">
{% csrf_token %}
{% bootstrap_form factureform %}
{% bootstrap_button action_name button_type="submit" icon="star" %}
{% bootstrap_button action_name button_type='submit' icon='star' %}
</form>
{% endblock %}
......@@ -24,14 +24,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load bootstrap3 %}
{% load i18n %}
{% block title %}Facture{% endblock %}
{% block title %}{% trans "Invoices" %}{% endblock %}
{% block content %}
<h2>Cotisations</h2>
{% include "cotisations/aff_cotisations.html" with facture_list=facture_list %}
<br />
<br />
<br />
<h2>{% trans "Cotisations" %}</h2>
{% include 'cotisations/aff_cotisations.html' with facture_list=facture_list %}
{% endblock %}
......@@ -25,18 +25,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load acl %}
{% load i18n %}
{% block title %}Articles{% endblock %}
{% block title %}{% trans "Articles" %}{% endblock %}
{% block content %}
<h2>Liste des types d'articles</h2>
{% can_create Article %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:add-article' %}"><i class="fa fa-cart-plus"></i> Ajouter un type d'articles</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'cotisations:del-article' %}"><i class="fa fa-trash"></i> Supprimer un ou plusieurs types d'articles</a>
{% include "cotisations/aff_article.html" with article_list=article_list %}
<br />
<br />
<br />
<h2>{% trans "Article types list" %}</h2>
{% can_create Article %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:add-article' %}">
<i class="fa fa-cart-plus"></i> {% trans "Add an article type" %}
</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'cotisations:del-article' %}">
<i class="fa fa-trash"></i> {% trans "Delete article types" %}
</a>
{% include 'cotisations/aff_article.html' with article_list=article_list %}
{% endblock %}
......@@ -25,18 +25,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load acl %}
{% load i18n %}
{% block title %}Banques{% endblock %}
{% block title %}{% trans "Banks" %}{% endblock %}
{% block content %}
<h2>Liste des banques</h2>
{% can_create Banque %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:add-banque' %}"><i class="fa fa-cart-plus"></i> Ajouter une banque</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'cotisations:del-banque' %}"><i class="fa fa-trash"></i> Supprimer une ou plusieurs banques</a>
{% include "cotisations/aff_banque.html" with banque_list=banque_list %}
<br />
<br />
<br />
<h2>{% trans "Banks list" %}</h2>
{% can_create Banque %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:add-banque' %}">
<i class="fa fa-cart-plus"></i> {% trans "Add a bank" %}
</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'cotisations:del-banque' %}">
<i class="fa fa-trash"></i> {% trans "Delete banks" %}
</a>
{% include 'cotisations/aff_banque.html' with banque_list=banque_list %}
{% endblock %}
......@@ -25,18 +25,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load acl %}
{% load i18n %}
{% block title %}Paiements{% endblock %}
{% block title %}{% trans "Payments" %}{% endblock %}
{% block content %}
<h2>Liste des types de paiements</h2>
{% can_create Paiement %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:add-paiement' %}"><i class="fa fa-cart-plus"></i> Ajouter un type de paiement</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'cotisations:del-paiement' %}"><i class="fa fa-trash"></i> Supprimer un ou plusieurs types de paiements</a>
{% include "cotisations/aff_paiement.html" with paiement_list=paiement_list %}
<br />
<br />
<br />
<h2>{% trans "Payment types list" %}</h2>
{% can_create Paiement %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:add-paiement' %}">
<i class="fa fa-cart-plus"></i> {% trans "Add a payment type" %}
</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'cotisations:del-paiement' %}">
<i class="fa fa-trash"></i> {% trans "Delete payment types" %}
</a>
{% include 'cotisations/aff_paiement.html' with paiement_list=paiement_list %}
{% endblock %}
......@@ -25,40 +25,45 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load staticfiles%}
{% load i18n %}
{% block title %}Création et modification de factures{% endblock %}
{% block title %}{% trans "Invoices creation and edition" %}{% endblock %}
{% block content %}
{% bootstrap_form_errors factureform %}
<form class="form" method="post">
{% csrf_token %}
<h3>Nouvelle facture</h3>
<h3>{% trans "New invoice" %}</h3>
<p>
Solde de l'utilisateur : {{ user.solde }} €
{% blocktrans %}
User's balance : {{ user.solde }} €
{% endblocktrans %}
</p>
{% bootstrap_form factureform %}
{{ venteform.management_form }}
<!-- TODO: FIXME to include data-type="check" for right option in id_cheque select -->
<h3>Articles de la facture</h3>
<h3>{% trans "Invoice's articles" %}</h3>
<div id="form_set" class="form-group">
{% for form in venteform.forms %}
{% for form in venteform.forms %}
<div class='product_to_sell form-inline'>
Article : &nbsp;
{% bootstrap_form form label_class='sr-only' %}
&nbsp;
<button class="btn btn-danger btn-sm"
id="id_form-0-article-remove" type="button">
<span class="fa fa-times"></span>
</button>
{% trans "Article" %} : &nbsp;
{% bootstrap_form form label_class='sr-only' %}
&nbsp;
<button class="btn btn-danger btn-sm" id="id_form-0-article-remove" type="button">
<span class="fa fa-times"></span>
</button>
</div>
{% endfor %}
{% endfor %}
</div>
<input class="btn btn-primary btn-sm" role="button" value="Ajouter un article" id="add_one">
<input class="btn btn-primary btn-sm" role="button" value="{% trans "Add an article"%}" id="add_one">
<p>
Prix total : <span id="total_price">0,00</span>
{% blocktrans %}
Total price : <span id="total_price">0,00</span>
{% endblocktrans %}
</p>
{% bootstrap_button "Créer" button_type="submit" icon="star" %}
{% trans "Create" as tr_create %}
{% bootstrap_button tr_create button_type='submit' icon='star' %}
</form>
<script type="text/javascript">
......@@ -72,9 +77,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% bootstrap_form venteform.empty_form label_class='sr-only' %}
&nbsp;
<button class="btn btn-danger btn-sm"
id="id_form-__prefix__-article-remove" type="button">
<span class="fa fa-times"></span>
</button>`
id="id_form-__prefix__-article-remove" type="button">
<span class="fa fa-times"></span>
</button>`
function add_article(){
// Index start at 0 => new_index = number of items
......@@ -116,13 +121,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
document.getElementById('id_form-' + i.toString() + '-quantity')
.addEventListener("change", update_price, true);
document.getElementById('id_form-' + i.toString() + '-article-remove')
.addEventListener("click", function(event) {
var article = event.target.parentNode;
article.parentNode.removeChild(article);
.addEventListener("click", function(event) {
var article = event.target.parentNode;
article.parentNode.removeChild(article);
document.getElementById('id_form-TOTAL_FORMS').value --;
update_price();
}
)
update_price();
}
)
}
function set_cheque_info_visibility() {
......@@ -134,9 +139,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
display = 'block';