misc: add presence/absence callback URLs (#75896)

This commit is contained in:
Frédéric Péters 2023-03-31 08:34:39 +02:00
parent ba91b0d520
commit 5265839e69
5 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,22 @@
# Generated by Django 3.2.16 on 2023-03-31 06:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agendas', '0151_event_invoiced'),
]
operations = [
migrations.AddField(
model_name='booking',
name='absence_callback_url',
field=models.URLField(blank=True),
),
migrations.AddField(
model_name='booking',
name='presence_callback_url',
field=models.URLField(blank=True),
),
]

View File

@ -2163,6 +2163,8 @@ class Booking(models.Model):
form_url = models.URLField(blank=True)
backoffice_url = models.URLField(blank=True)
cancel_callback_url = models.URLField(blank=True)
presence_callback_url = models.URLField(blank=True)
absence_callback_url = models.URLField(blank=True)
color = models.ForeignKey(BookingColor, null=True, on_delete=models.SET_NULL, related_name='bookings')
@property

View File

@ -82,6 +82,8 @@ class FillSlotSerializer(serializers.Serializer):
form_url = serializers.CharField(max_length=250, allow_blank=True)
backoffice_url = serializers.URLField(allow_blank=True)
cancel_callback_url = serializers.URLField(allow_blank=True)
presence_callback_url = serializers.URLField(allow_blank=True)
absence_callback_url = serializers.URLField(allow_blank=True)
count = serializers.IntegerField(min_value=1)
cancel_booking_id = serializers.CharField(max_length=250, allow_blank=True, allow_null=True)
force_waiting_list = serializers.BooleanField(default=False)

View File

@ -727,6 +727,8 @@ def make_booking(event, payload, extra_data, primary_booking=None, in_waiting_li
form_url=translate_to_publik_url(payload.get('form_url', '')),
backoffice_url=translate_to_publik_url(payload.get('backoffice_url', '')),
cancel_callback_url=translate_to_publik_url(payload.get('cancel_callback_url', '')),
presence_callback_url=translate_to_publik_url(payload.get('presence_callback_url', '')),
absence_callback_url=translate_to_publik_url(payload.get('absence_callback_url', '')),
user_display_label=payload.get('user_display_label', ''),
extra_emails=payload.get('extra_emails', []),
extra_phone_numbers=payload.get('extra_phone_numbers', []),

View File

@ -80,6 +80,8 @@ def test_booking_api(app, user):
'form_url': 'http://example.net/',
'extra_emails': ['baz@baz.com', 'hop@hop.com'],
'extra_phone_numbers': ['+33123456789', '+33123456789'],
'presence_callback_url': 'http://example.net/jump/trigger2/',
'absence_callback_url': 'http://example.net/jump/trigger3/',
},
)
booking = Booking.objects.get(id=resp.json['booking_id'])
@ -88,6 +90,8 @@ def test_booking_api(app, user):
assert booking.user_last_name == 'bar'
assert booking.backoffice_url == 'http://example.net/'
assert booking.cancel_callback_url == 'http://example.net/jump/trigger/'
assert booking.presence_callback_url == 'http://example.net/jump/trigger2/'
assert booking.absence_callback_url == 'http://example.net/jump/trigger3/'
assert booking.user_email == 'bar@bar.com'
assert booking.user_phone_number == '+33 (0) 6 12 34 56 78'
assert booking.form_url == 'http://example.net/'