Example #1
0
def _serializable_reservation(reservation_data, include_room=False):
    """Serializable reservation (standalone or inside room)

    :param reservation_data: Reservation data
    :param include_room: Include minimal room information
    """
    reservation = reservation_data['reservation']
    data = reservation.to_serializable('__api_public__',
                                       converters={datetime: _add_server_tz})
    data['_type'] = 'Reservation'
    data['repeatability'] = None
    if reservation.repeat_frequency:
        data['repeatability'] = RepeatMapping.get_short_name(
            *reservation.repetition)
    data['vcList'] = reservation_data['vc_equipment']
    if include_room:
        data['room'] = _serializable_room_minimal(
            reservation_data['reservation'].room)
    if 'occurrences' in reservation_data:
        data['occurrences'] = [
            o.to_serializable('__api_public__',
                              converters={datetime: _add_server_tz})
            for o in reservation_data['occurrences']
        ]
    return data
Example #2
0
File: api.py Project: indico/indico
def _serializable_reservation(reservation_data, include_room=False):
    """Serializable reservation (standalone or inside room)

    :param reservation_data: Reservation data
    :param include_room: Include minimal room information
    """
    reservation = reservation_data['reservation']
    data = reservation.to_serializable('__api_public__', converters={datetime: _add_server_tz})
    data['_type'] = 'Reservation'
    data['repeatability'] = None
    if reservation.repeat_frequency:
        data['repeatability'] = RepeatMapping.get_short_name(*reservation.repetition)
    if include_room:
        data['room'] = _serializable_room_minimal(reservation_data['reservation'].room)
    if 'occurrences' in reservation_data:
        data['occurrences'] = [o.to_serializable('__api_public__', converters={datetime: _add_server_tz})
                               for o in reservation_data['occurrences']]
    return data
Example #3
0
def _serializable_reservation(reservation_data, include_room=False):
    """Serializable reservation (standalone or inside room).

    :param reservation_data: Reservation data
    :param include_room: Include minimal room information
    """
    from indico.modules.rb.schemas import ReservationLegacyAPISchema, ReservationOccurrenceLegacyAPISchema
    reservation = reservation_data['reservation']
    data = ReservationLegacyAPISchema().dump(reservation)
    data['_type'] = 'Reservation'
    data['repeatability'] = None
    if reservation.repeat_frequency:
        data['repeatability'] = RepeatMapping.get_short_name(
            *reservation.repetition)
    if include_room:
        data['room'] = _serializable_room_minimal(
            reservation_data['reservation'].room)
    if 'occurrences' in reservation_data:
        data['occurrences'] = ReservationOccurrenceLegacyAPISchema(
            many=True).dump(reservation_data['occurrences'])
    return data
Example #4
0
def test_repeat_mapping(repetition, legacy, short_name, message):
    assert RepeatMapping.get_message(*repetition) == message
    assert RepeatMapping.get_short_name(*repetition) == short_name
    assert RepeatMapping.convert_legacy_repeatability(legacy) == repetition
def test_repeat_mapping(repetition, legacy, short_name, message):
    assert RepeatMapping.get_message(*repetition) == message
    assert RepeatMapping.get_short_name(*repetition) == short_name
    assert RepeatMapping.convert_legacy_repeatability(legacy) == repetition