lingo: allow passing extra basket item info (#42992)

This commit is contained in:
Valentin Deniaud 2020-06-04 14:28:47 +02:00
parent fca2a33b33
commit 1bdc236839
3 changed files with 35 additions and 2 deletions

View File

@ -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,
),
]

View File

@ -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)

View File

@ -182,6 +182,7 @@ class AddBasketItemApiView(View):
user = get_user_from_name_id(request.GET.get('NameId'), raise_on_missing=True)
else:
user = None
item.email = request_body.get('email') or ''
except User.DoesNotExist:
return BadRequestJsonResponse('unknown user')
@ -210,6 +211,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: