Project

General

Profile

0002-api-rename-show_events-in-bookable_events-56615.patch

Lauréline Guerin, 04 Oct 2021 06:06 PM

Download (3.84 KB)

View differences:

Subject: [PATCH 2/5] api: rename show_events in bookable_events (#56615)

 chrono/api/views.py | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
chrono/api/views.py
455 455
    agenda=None,
456 456
    min_places=1,
457 457
    booked_user_external_id=None,
458
    show_events=None,
458
    bookable_events=None,
459 459
    multiple_agendas=False,
460 460
    disable_booked=True,
461 461
):
......
513 513
                'places': get_event_places(event),
514 514
            }
515 515
        )
516
    if show_events is not None:
517
        details['api']['fillslot_url'] += '?events=%s' % show_events
516
    if bookable_events is not None:
517
        details['api']['fillslot_url'] += '?events=%s' % bookable_events
518 518
    if booked_user_external_id:
519 519
        if getattr(event, 'user_places_count', 0) > 0:
520 520
            details['booked_for_external_user'] = 'main-list'
......
525 525

  
526 526

  
527 527
def get_events_meta_detail(
528
    request, events, agenda=None, min_places=1, show_events=None, multiple_agendas=False
528
    request, events, agenda=None, min_places=1, bookable_events=None, multiple_agendas=False
529 529
):
530 530
    bookable_datetimes_number_total = 0
531 531
    bookable_datetimes_number_available = 0
......
540 540
                    event,
541 541
                    agenda=agenda,
542 542
                    min_places=min_places,
543
                    show_events=show_events,
543
                    bookable_events=bookable_events,
544 544
                    multiple_agendas=multiple_agendas,
545 545
                )
546 546
    return {
......
763 763

  
764 764
        user_external_id = payload.get('user_external_id') or payload.get('exclude_user_external_id')
765 765
        disable_booked = bool(payload.get('exclude_user_external_id'))
766
        show_events_raw = payload.get('events')
767
        show_events = show_events_raw or 'future'
768
        show_past = show_events in ['all', 'past']
769
        show_future = show_events in ['all', 'future']
766
        bookable_events_raw = payload.get('events')
767
        bookable_events = bookable_events_raw or 'future'
768
        book_past = bookable_events in ['all', 'past']
769
        book_future = bookable_events in ['all', 'future']
770 770

  
771 771
        entries = []
772
        if show_past:
772
        if book_past:
773 773
            entries += agenda.get_past_events(
774 774
                min_start=payload.get('date_start'),
775 775
                max_start=payload.get('date_end'),
776 776
                user_external_id=user_external_id,
777 777
            )
778
        if show_future:
778
        if book_future:
779 779
            entries += agenda.get_open_events(
780 780
                min_start=payload.get('date_start'),
781 781
                max_start=payload.get('date_end'),
......
797 797
                    agenda=agenda,
798 798
                    min_places=payload['min_places'],
799 799
                    booked_user_external_id=payload.get('user_external_id'),
800
                    show_events=show_events_raw,
800
                    bookable_events=bookable_events_raw,
801 801
                    disable_booked=disable_booked,
802 802
                )
803 803
                for x in entries
804 804
            ],
805 805
            'meta': get_events_meta_detail(
806
                request, entries, agenda=agenda, min_places=payload['min_places'], show_events=show_events_raw
806
                request,
807
                entries,
808
                agenda=agenda,
809
                min_places=payload['min_places'],
810
                bookable_events=bookable_events_raw,
807 811
            ),
808 812
        }
809 813
        return Response(response)
810
-