agendas: add user_external_id field on Booking (#40719)
This commit is contained in:
parent
8e775f2bd3
commit
1584b52ed3
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('agendas', '0042_auto_20200503_1231'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='booking', name='user_external_id', field=models.CharField(blank=True, max_length=250),
|
||||
),
|
||||
]
|
|
@ -677,6 +677,7 @@ class Booking(models.Model):
|
|||
user_display_label = models.CharField(
|
||||
verbose_name=_('Label displayed to user'), max_length=250, blank=True
|
||||
)
|
||||
user_external_id = models.CharField(max_length=250, blank=True)
|
||||
user_name = models.CharField(max_length=250, blank=True)
|
||||
backoffice_url = models.URLField(blank=True)
|
||||
|
||||
|
@ -734,16 +735,10 @@ class Booking(models.Model):
|
|||
return ics.serialize()
|
||||
|
||||
def clone(self, in_waiting_list=False, primary_booking=None, save=True):
|
||||
new_booking = Booking(
|
||||
primary_booking=primary_booking,
|
||||
event_id=self.event_id,
|
||||
in_waiting_list=in_waiting_list,
|
||||
label=self.label,
|
||||
user_name=self.user_name,
|
||||
backoffice_url=self.backoffice_url,
|
||||
user_display_label=self.user_display_label,
|
||||
extra_data=self.extra_data,
|
||||
)
|
||||
new_booking = copy.deepcopy(self)
|
||||
new_booking.id = None
|
||||
new_booking.in_waiting_list = in_waiting_list
|
||||
new_booking.primary_booking = primary_booking
|
||||
if save:
|
||||
new_booking.save()
|
||||
return new_booking
|
||||
|
|
|
@ -438,6 +438,7 @@ class SlotSerializer(serializers.Serializer):
|
|||
'''
|
||||
|
||||
label = serializers.CharField(max_length=250, allow_blank=True)
|
||||
user_external_id = serializers.CharField(max_length=250, allow_blank=True)
|
||||
user_name = serializers.CharField(max_length=250, allow_blank=True)
|
||||
user_display_label = serializers.CharField(max_length=250, allow_blank=True)
|
||||
backoffice_url = serializers.URLField(allow_blank=True)
|
||||
|
@ -752,6 +753,7 @@ class Fillslots(APIView):
|
|||
event_id=event.id,
|
||||
in_waiting_list=in_waiting_list,
|
||||
label=payload.get('label', ''),
|
||||
user_external_id=payload.get('user_external_id', ''),
|
||||
user_name=payload.get('user_name', ''),
|
||||
backoffice_url=payload.get('backoffice_url', ''),
|
||||
user_display_label=payload.get('user_display_label', ''),
|
||||
|
|
|
@ -675,14 +675,19 @@ def test_booking_api_fillslots(app, some_data, user):
|
|||
params={
|
||||
'slots': events_ids,
|
||||
'label': 'foo',
|
||||
'user_external_id': 'some_external_id',
|
||||
'user_name': 'bar',
|
||||
'user_display_label': 'foo',
|
||||
'backoffice_url': 'http://example.net/',
|
||||
},
|
||||
)
|
||||
booking_id = resp.json['booking_id']
|
||||
assert Booking.objects.get(id=booking_id).label == 'foo'
|
||||
assert Booking.objects.get(id=booking_id).user_name == 'bar'
|
||||
assert Booking.objects.get(id=booking_id).backoffice_url == 'http://example.net/'
|
||||
booking = Booking.objects.get(pk=booking_id)
|
||||
assert booking.label == 'foo'
|
||||
assert booking.user_external_id == 'some_external_id'
|
||||
assert booking.user_name == 'bar'
|
||||
assert booking.user_display_label == 'foo'
|
||||
assert booking.backoffice_url == 'http://example.net/'
|
||||
assert Booking.objects.filter(primary_booking=booking_id, label='foo').count() == 2
|
||||
# cancel
|
||||
cancel_url = resp.json['api']['cancel_url']
|
||||
|
|
Loading…
Reference in New Issue