0001-agendas-add-user_external_id-field-on-Booking-40719.patch
chrono/agendas/migrations/0043_booking_user_external_id.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
from __future__ import unicode_literals |
|
3 | ||
4 |
from django.db import migrations, models |
|
5 | ||
6 | ||
7 |
class Migration(migrations.Migration): |
|
8 | ||
9 |
dependencies = [ |
|
10 |
('agendas', '0042_auto_20200503_1231'), |
|
11 |
] |
|
12 | ||
13 |
operations = [ |
|
14 |
migrations.AddField( |
|
15 |
model_name='booking', name='user_external_id', field=models.CharField(blank=True, max_length=250), |
|
16 |
), |
|
17 |
] |
chrono/agendas/models.py | ||
---|---|---|
677 | 677 |
user_display_label = models.CharField( |
678 | 678 |
verbose_name=_('Label displayed to user'), max_length=250, blank=True |
679 | 679 |
) |
680 |
user_external_id = models.CharField(max_length=250, blank=True) |
|
680 | 681 |
user_name = models.CharField(max_length=250, blank=True) |
681 | 682 |
backoffice_url = models.URLField(blank=True) |
682 | 683 | |
... | ... | |
734 | 735 |
return ics.serialize() |
735 | 736 | |
736 | 737 |
def clone(self, in_waiting_list=False, primary_booking=None, save=True): |
737 |
new_booking = Booking( |
|
738 |
primary_booking=primary_booking, |
|
739 |
event_id=self.event_id, |
|
740 |
in_waiting_list=in_waiting_list, |
|
741 |
label=self.label, |
|
742 |
user_name=self.user_name, |
|
743 |
backoffice_url=self.backoffice_url, |
|
744 |
user_display_label=self.user_display_label, |
|
745 |
extra_data=self.extra_data, |
|
746 |
) |
|
738 |
new_booking = copy.deepcopy(self) |
|
739 |
new_booking.id = None |
|
740 |
new_booking.in_waiting_list = in_waiting_list |
|
741 |
new_booking.primary_booking = primary_booking |
|
747 | 742 |
if save: |
748 | 743 |
new_booking.save() |
749 | 744 |
return new_booking |
chrono/api/views.py | ||
---|---|---|
438 | 438 |
''' |
439 | 439 | |
440 | 440 |
label = serializers.CharField(max_length=250, allow_blank=True) |
441 |
user_external_id = serializers.CharField(max_length=250, allow_blank=True) |
|
441 | 442 |
user_name = serializers.CharField(max_length=250, allow_blank=True) |
442 | 443 |
user_display_label = serializers.CharField(max_length=250, allow_blank=True) |
443 | 444 |
backoffice_url = serializers.URLField(allow_blank=True) |
... | ... | |
752 | 753 |
event_id=event.id, |
753 | 754 |
in_waiting_list=in_waiting_list, |
754 | 755 |
label=payload.get('label', ''), |
756 |
user_external_id=payload.get('user_external_id', ''), |
|
755 | 757 |
user_name=payload.get('user_name', ''), |
756 | 758 |
backoffice_url=payload.get('backoffice_url', ''), |
757 | 759 |
user_display_label=payload.get('user_display_label', ''), |
tests/test_api.py | ||
---|---|---|
675 | 675 |
params={ |
676 | 676 |
'slots': events_ids, |
677 | 677 |
'label': 'foo', |
678 |
'user_external_id': 'some_external_id', |
|
678 | 679 |
'user_name': 'bar', |
680 |
'user_display_label': 'foo', |
|
679 | 681 |
'backoffice_url': 'http://example.net/', |
680 | 682 |
}, |
681 | 683 |
) |
682 | 684 |
booking_id = resp.json['booking_id'] |
683 |
assert Booking.objects.get(id=booking_id).label == 'foo' |
|
684 |
assert Booking.objects.get(id=booking_id).user_name == 'bar' |
|
685 |
assert Booking.objects.get(id=booking_id).backoffice_url == 'http://example.net/' |
|
685 |
booking = Booking.objects.get(pk=booking_id) |
|
686 |
assert booking.label == 'foo' |
|
687 |
assert booking.user_external_id == 'some_external_id' |
|
688 |
assert booking.user_name == 'bar' |
|
689 |
assert booking.user_display_label == 'foo' |
|
690 |
assert booking.backoffice_url == 'http://example.net/' |
|
686 | 691 |
assert Booking.objects.filter(primary_booking=booking_id, label='foo').count() == 2 |
687 | 692 |
# cancel |
688 | 693 |
cancel_url = resp.json['api']['cancel_url'] |
689 |
- |