From 24cdc2329d266c7902f1a87d11dc748187a10a64 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Mon, 2 Jul 2018 14:09:35 +0200 Subject: [PATCH] =?UTF-8?q?Autorise=20l'=C3=A9dition=20de=20facture=20si?= =?UTF-8?q?=20l'auto-souscription=20est=20interdite=20mais=20que=20l'on=20?= =?UTF-8?q?peut=20cr=C3=A9er=20des=20factures.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/views.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/cotisations/views.py b/cotisations/views.py index 47b716ce..ea137379 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -99,22 +99,26 @@ def new_facture(request, user, userid): ) # Building the invocie form and the article formset is_self_subscription = False - if not request.user.has_perm('cotisations.add_facture') and OptionalUser.get_cached_value('allow_self_subscription'): - is_self_subscription = True - article_list = article_list.filter(allow_self_subscription=True) - allowed_payment = Paiement.objects.filter(allow_self_subscription=True) - invoice_form = NewFactureForm(request.POST or None, instance=invoice, allowed_payment=allowed_payment) - elif not OptionalUser.get_cached_value('allow_self_subscription'): - messages.error( - request, - _("You cannot subscribe. Please ask to the staff.") - ) - return redirect(reverse( - 'users:profil', - kwargs={'userid': userid} - )) + can_create_invoice = request.user.has_perm('cotisations.add_facture') + allow_self_subscription = OptionalUser.get_cached_value('allow_self_subscription') + if not can_create_invoice: + if allow_self_subscription: + is_self_subscription = True + article_list = article_list.filter(allow_self_subscription=True) + allowed_payment = Paiement.objects.filter(allow_self_subscription=True) + invoice_form = NewFactureForm(request.POST or None, instance=invoice, allowed_payment=allowed_payment) + else: + messages.error( + request, + _("You cannot subscribe. Please ask to the staff.") + ) + return redirect(reverse( + 'users:profil', + kwargs={'userid': userid} + )) else: invoice_form = NewFactureForm(request.POST or None, instance=invoice) + if request.user.is_class_club: article_formset = formset_factory(SelectClubArticleForm)( request.POST or None,