From d1591db3910e562a4447c854aefd19ead9902256 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 23 Sep 2020 14:29:19 +0200 Subject: [PATCH 4/4] lingo: allow requiring individual payment for regie (#46503) --- combo/apps/lingo/forms.py | 3 ++- .../0041_regie_individual_payment.py | 20 ++++++++++++++++ combo/apps/lingo/models.py | 3 +++ .../lingo/templates/lingo/combo/basket.html | 19 +++++++++++---- combo/apps/lingo/views.py | 4 ++++ tests/test_lingo_cells.py | 19 +++++++++++++++ tests/test_lingo_payment.py | 23 +++++++++++++++++++ 7 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 combo/apps/lingo/migrations/0041_regie_individual_payment.py diff --git a/combo/apps/lingo/forms.py b/combo/apps/lingo/forms.py index fe50a253..aa6a7775 100644 --- a/combo/apps/lingo/forms.py +++ b/combo/apps/lingo/forms.py @@ -87,7 +87,8 @@ class RegieForm(forms.ModelForm): class Meta: model = Regie fields = ['label', 'slug', 'description', 'payment_backend', 'is_default', - 'webservice_url', 'extra_fees_ws_url', 'payment_min_amount', 'text_on_success'] + 'webservice_url', 'extra_fees_ws_url', 'payment_min_amount', 'text_on_success', + 'individual_payment'] def __init__(self, *args, **kwargs): super(RegieForm, self).__init__(*args, **kwargs) diff --git a/combo/apps/lingo/migrations/0041_regie_individual_payment.py b/combo/apps/lingo/migrations/0041_regie_individual_payment.py new file mode 100644 index 00000000..79e015d3 --- /dev/null +++ b/combo/apps/lingo/migrations/0041_regie_individual_payment.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2020-09-30 16:10 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lingo', '0040_auto_20200608_1222'), + ] + + operations = [ + migrations.AddField( + model_name='regie', + name='individual_payment', + field=models.BooleanField(default=False, verbose_name='Basket items must be paid individually'), + ), + ] diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index 868f260d..dc90f1cb 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -145,6 +145,9 @@ class Regie(models.Model): payment_backend = models.ForeignKey( PaymentBackend, on_delete=models.CASCADE, verbose_name=_('Payment backend')) transaction_options = JSONField(blank=True, verbose_name=_('Transaction Options')) + individual_payment = models.BooleanField( + default=False, verbose_name=_('Basket items must be paid individually') + ) def is_remote(self): return self.webservice_url != '' diff --git a/combo/apps/lingo/templates/lingo/combo/basket.html b/combo/apps/lingo/templates/lingo/combo/basket.html index ae0fd1b9..1ff2c50a 100644 --- a/combo/apps/lingo/templates/lingo/combo/basket.html +++ b/combo/apps/lingo/templates/lingo/combo/basket.html @@ -4,22 +4,31 @@

{% trans "Basket" %}

{% for regie_info in regies %} {% if regies|length != 1 %}

{{regie_info.regie.label}}

{% endif %} -
-{% csrf_token %} - - -