From b342771b81e4c88df2871bc01e3414402b90b6a2 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Thu, 4 Jun 2020 14:28:47 +0200 Subject: [PATCH 1/3] lingo: allow passing extra basket item info (#42992) --- .../migrations/0040_auto_20200608_1222.py | 26 +++++++++++++++++++ combo/apps/lingo/models.py | 9 +++++-- combo/apps/lingo/views.py | 2 ++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 combo/apps/lingo/migrations/0040_auto_20200608_1222.py diff --git a/combo/apps/lingo/migrations/0040_auto_20200608_1222.py b/combo/apps/lingo/migrations/0040_auto_20200608_1222.py new file mode 100644 index 00000000..dd152747 --- /dev/null +++ b/combo/apps/lingo/migrations/0040_auto_20200608_1222.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2020-06-08 10:22 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lingo', '0039_transaction_transaction_date'), + ] + + operations = [ + migrations.AddField( + model_name='basketitem', + name='email', + field=models.EmailField(max_length=254, null=True), + ), + migrations.AddField( + model_name='basketitem', + name='reference_id', + field=models.CharField(default='', max_length=200), + preserve_default=False, + ), + ] diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index f5b06f13..10dd47c5 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -85,7 +85,8 @@ def build_remote_item(data, regie): online_payment=data.get('online_payment'), paid=data.get('paid'), payment_date=data.get('payment_date'), - no_online_payment_reason=data.get('no_online_payment_reason')) + no_online_payment_reason=data.get('no_online_payment_reason'), + reference_id=data.get('reference_id')) @python_2_unicode_compatible @@ -366,6 +367,8 @@ class BasketItem(models.Model): payment_date = models.DateTimeField(null=True) notification_date = models.DateTimeField(null=True) capture_date = models.DateField(null=True) + email = models.EmailField(null=True) + reference_id = models.CharField(max_length=200) class Meta: ordering = ['regie', 'extra_fee', 'subject'] @@ -422,7 +425,8 @@ class RemoteItem(object): def __init__(self, id, regie, creation_date, payment_limit_date, total_amount, amount, amount_paid, display_id, subject, has_pdf, - online_payment, paid, payment_date, no_online_payment_reason): + online_payment, paid, payment_date, no_online_payment_reason, + reference_id): self.id = id self.regie = regie self.creation_date = dateparse.parse_date(creation_date) @@ -437,6 +441,7 @@ class RemoteItem(object): self.online_payment = online_payment self.paid = paid self.no_online_payment_reason = no_online_payment_reason + self.reference_id = reference_id if payment_date: self.payment_date = parser.parse(payment_date) diff --git a/combo/apps/lingo/views.py b/combo/apps/lingo/views.py index bba6b54b..68690f51 100644 --- a/combo/apps/lingo/views.py +++ b/combo/apps/lingo/views.py @@ -184,6 +184,7 @@ class AddBasketItemApiView(View): user = User.objects.get(email=request.GET.get('email')) else: user = None + item.email = request_body.get('email_address') or '' except User.DoesNotExist: return BadRequestJsonResponse('unknown user') @@ -212,6 +213,7 @@ class AddBasketItemApiView(View): item.subject = request_body['display_name'] item.source_url = request_body.get('url') or '' + item.reference_id = request_body.get('reference_id') or '' if 'capture_date' in request_body: try: -- 2.20.1