Room booking

Todo

Docstrings (module, models, utilities, services)

Models

class indico.modules.rb.models.rooms.Room(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

access_key = None
acl_entries
attributes
available_equipment
blocked_rooms
bookable_hours
booking_limit_days
building
can_access(user, allow_admin=True)

Check if the user can access the object.

Parameters:
  • user – The User to check. May be None if the user is not logged in.

  • allow_admin – If admin users should always have access

can_book(user, allow_admin=True)
can_delete(user)
can_edit(user)
can_manage(user, permission=None, allow_admin=True, check_parent=True, explicit_permission=False)

Check if the user can manage the object.

Parameters:
  • user – The User to check. May be None if the user is not logged in.

  • allow_admin – If admin users should always have access

  • check_parent – If the parent object should be checked. In this case the permission is ignored; only full management access is inherited to children.

  • explicit_permission – If the specified permission should be checked explicitly instead of short-circuiting the check for Indico admins or managers. When this option is set to True, the values of allow_admin and check_parent are ignored. This also applies if permission is None in which case this argument being set to True is equivalent to allow_admin and check_parent being set to False.

Param:

permission: The management permission that is needed for the check to succeed. If not specified, full management privs are required. May be set to the string 'ANY' to check if the user has any management privileges. If the user has full_access privileges, he’s assumed to have all possible permissions.

can_moderate(user, allow_admin=True)
can_override(user, allow_admin=True)
can_prebook(user, allow_admin=True)
capacity
check_advance_days(end_date, user=None, quiet=False)
check_bookable_hours(start_time, end_time, user=None, quiet=False)
comments
default_protection_mode = 0

The default protection mode a new object has

property details_url
disallowed_protection_modes = frozenset({ProtectionMode.inheriting})

The protection modes that are not allowed. Can be overridden in the model that is using the mixin. Affects the table structure, so any changes to it should go along with a migration step! By default, the public mode is disallowed since it does not make much sense in most cases to make something public even though its parent object is private (or inheriting).

division
end_notification_daily
end_notification_monthly
end_notification_weekly
end_notifications_enabled
favorite_of
static filter_available(start_dt, end_dt, repetition, include_blockings=True, include_pre_bookings=True, include_pending_blockings=False)

Return a SQLAlchemy filter criterion ensuring that the room is available during the given time.

static filter_bookable_hours(start_time, end_time)
static filter_nonbookable_periods(start_dt, end_dt)
classmethod find_with_attribute(attribute)

Search rooms which have a specific attribute.

floor
full_name
generate_name()
get_attribute_by_name(attribute_name)
get_attribute_value(name, default=None)
get_blocked_rooms(*dates, **kwargs)
classmethod get_permissions_for_user(user, allow_admin=True)

Get the permissions for all rooms for a user.

In case of multipass-based groups it will try to get a list of all groups the user is in, and if that’s not possible check the permissions one by one for each room (which may result in many group membership lookups).

It is recommended to not call this in any place where performance matters and to memoize the result.

static get_with_data(*args, **kwargs)
has_attribute(attribute_name)
has_equipment(*names)
property has_photo
id
is_auto_confirm
is_deleted
is_reservable
static is_user_admin(user)
key_location
latitude
location
location_id
property location_name
longitude
property map_url
max_advance_days
name
nonbookable_periods
notification_before_days
notification_before_days_monthly
notification_before_days_weekly
notification_emails
notifications_enabled
number
own_no_access_contact = None
owner

The owner of the room. This is purely informational and does not grant any permissions on the room.

owner_id
photo
photo_id
protection_mode
property protection_parent

The parent object to consult for ProtectionMode.inheriting.

reservations
reservations_need_confirmation
set_attribute_value(name, value)
site
speakers_can_access = None
property sprite_position
surface_area
telephone
verbose_name

Verbose name for the room (long)

class indico.modules.rb.models.room_attributes.RoomAttribute(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id
is_hidden
name
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

title
class indico.modules.rb.models.room_attributes.RoomAttributeAssociation(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

attribute
attribute_id
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

room_id
value
class indico.modules.rb.models.room_bookable_hours.BookableHours(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

end_time
fits_period(st, et)
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

room_id
start_time
class indico.modules.rb.models.room_nonbookable_periods.NonBookablePeriod(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

end_dt
overlaps(st, et)
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

room_id
start_dt
class indico.modules.rb.models.blockings.Blocking(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

allowed

A descriptor that presents a read/write view of an object attribute.

blocked_rooms
can_delete(user, allow_admin=True)
can_edit(user, allow_admin=True)
can_override(user, room=None, explicit_only=False, allow_admin=True)

Check if a user can override the blocking.

The following persons are authorized to override a blocking: - the creator of the blocking - anyone on the blocking’s ACL - unless explicit_only is set: rb admins and room managers (if a room is given)

created_by_id
created_by_user

The user who created this blocking.

created_dt
end_date
property external_details_url
id
is_active_at(d)
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

reason
start_date
class indico.modules.rb.models.blocked_rooms.BlockedRoom(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

State

alias of BlockedRoomState

approve(notify_blocker=True)

Approve the room blocking, rejecting all colliding reservations/occurrences.

blocking_id
id
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

reject(user=None, reason=None)

Reject the room blocking.

rejected_by
rejection_reason
room_id
state
property state_name
class indico.modules.rb.models.blocked_rooms.BlockedRoomState(value)

An enumeration.

accepted = 1
pending = 0
rejected = 2
class indico.modules.rb.models.blocking_principals.BlockingPrincipal(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

blocking_id
category_role = None
category_role_id = None
email = None
event_role = None
event_role_id = None
id
ip_network_group = None
ip_network_group_id = None
local_group_id
multipass_group_name
multipass_group_provider
principal_backref_name = 'in_blocking_acls'

The name of the backref added to User and LocalGroup. For consistency, it is recommended to name the backref in_foo_acl with foo describing the ACL where this mixin is used.

registration_form = None
registration_form_id = None
type
unique_columns = ('blocking_id',)

The columns which should be included in the unique constraints. If set to None, no unique constraints will be added.

user_id
class indico.modules.rb.models.equipment.EquipmentType(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

features
id
name
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

class indico.modules.rb.models.locations.Location(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id
is_deleted
map_url_template
name
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

room_name_format

Translate Postgres’ format syntax (e.g. %1$s/%2$s-%3$s) to Python’s.

rooms
class indico.modules.rb.models.map_areas.MapArea(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

bottom_right_latitude
bottom_right_longitude
id
is_default
name
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

top_left_latitude
top_left_longitude
class indico.modules.rb.models.photos.Photo(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

data
id
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

exception indico.modules.rb.models.reservations.ConflictingOccurrences
class indico.modules.rb.models.reservations.RepeatFrequency(value)

An enumeration.

DAY = 1
MONTH = 3
NEVER = 0
WEEK = 2
class indico.modules.rb.models.reservations.RepeatMapping
classmethod get_message(repeat_frequency, repeat_interval, recurrence_weekdays)
classmethod get_short_name(repeat_frequency, repeat_interval, recurrence_weekdays)
mapping = {(RepeatFrequency.NEVER, 0): ('Single reservation', None, 'none'), (RepeatFrequency.DAY, 1): ('Repeat daily', 0, 'daily'), (RepeatFrequency.WEEK, 1): ('Repeat once a week', 1, 'weekly'), (RepeatFrequency.WEEK, 2): ('Repeat once every two weeks', 2, 'everyTwoWeeks'), (RepeatFrequency.WEEK, 3): ('Repeat once every three weeks', 3, 'everyThreeWeeks'), (RepeatFrequency.MONTH, 1): ('Repeat every month', 4, 'monthly')}
class indico.modules.rb.models.reservations.Reservation(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

accept(user, reason=None)
add_edit_log(edit_log)
booked_for_id
booked_for_name
booked_for_user

The user this booking was made for. Assigning a user here also updates booked_for_name.

booking_reason
can_accept(user, allow_admin=True)
can_cancel(user, allow_admin=True)
can_delete(user, allow_admin=True)
can_edit(user, allow_admin=True)
can_reject(user, allow_admin=True)
cancel(user, reason=None, silent=False)
property contact_email
classmethod create_from_data(room, data, user, *, prebook=None, ignore_admin=False, force_internal_note=False)

Create a new reservation.

Parameters:
  • room – The Room that’s being booked.

  • data – A dict containing the booking data, usually from a NewBookingConfirmForm instance

  • user – The User who creates the booking.

  • prebook – Instead of determining the booking type from the user’s permissions, always use the given mode.

  • ignore_admin – Whether to ignore the user’s admin status.

  • force_internal_note – Always set internal note regardless of config/permissions

create_occurrences(skip_conflicts, user=None, allow_admin=True)
created_by_id
created_by_user

The user who created this booking.

created_dt
edit_logs
end_dt
end_notification_sent
property event
property external_details_url
find_excluded_days()
find_overlapping()
static find_overlapping_with(room, occurrences, skip_reservation_id=None)
get_conflicting_occurrences()
static get_with_data(*args, **kwargs)
id
internal_note
is_accepted
is_archived
is_booked_for(user)
is_cancelled
is_owned_by(user)
is_pending
is_rejected
is_repeating
property linked_object
property location_name
modify(data, user)

Modify an existing reservation.

Parameters:
  • data – A dict containing the booking data, usually from a ModifyBookingForm instance

  • user – The User who modifies the booking.

occurrences
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

recurrence_weekdays
reject(user, reason, silent=False)
rejection_reason
repeat_frequency
repeat_interval
property repetition
reset_approval(user)
room_id
start_dt
state

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

The link types that are supported. Can be overridden in the model using the mixin. Affects the table structure, so any changes to it should go along with a migration step!

category = None
category_id = None
contribution
contribution_id
event
event_id
events_backref_name = 'all_room_reservation_links'

The name of the backref that’s added to the Event model to access all linked objects

id

The name of the backref that’s added to the linked objects

linked_event
linked_event_id
session = None
session_block
session_block_id
session_id = None
subcontribution = None
subcontribution_id = None
class indico.modules.rb.models.reservations.ReservationState(value)

An enumeration.

accepted = 2
cancelled = 3
pending = 1
rejected = 4
class indico.modules.rb.models.reservation_edit_logs.ReservationEditLog(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id
info
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

reservation_id
timestamp
user_name
class indico.modules.rb.models.reservation_occurrences.ReservationOccurrence(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

NO_RESERVATION_USER_STRATEGY = <sqlalchemy.orm.strategy_options._UnboundLoad object>

A relationship loading strategy that will avoid loading the users linked to a reservation. You want to use this in pretty much all cases where you eager-load the reservation relationship.

can_cancel(user, allow_admin=True)
can_reject(user, allow_admin=True)
cancel(user, reason=None, silent=False)
classmethod create_series(start, end, repetition)
classmethod create_series_for_reservation(reservation)
date
end_dt
property external_cancellation_url
static filter_overlap(occurrences)
classmethod find_overlapping_with(room, occurrences, skip_reservation_id=None)
get_overlap(occurrence, skip_self=False)
is_cancelled
is_rejected
is_valid
is_within_cancel_grace_period
classmethod iter_create_occurrences(start, end, repetition)
static iter_start_time(start, end, repetition)
static map_recurrence_weekdays_to_rrule(weekdays)

Map weekdays from database to rrule weekdays.

notification_sent
overlaps(occurrence, skip_self=False)
query: IndicoBaseQuery

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

reject(user, reason, silent=False)
rejection_reason
reservation_id
start_dt
state
class indico.modules.rb.models.reservation_occurrences.ReservationOccurrenceState(value)

An enumeration.

cancelled = 3
rejected = 4
valid = 2
indico.modules.rb.models.util.proxy_to_reservation_if_last_valid_occurrence(f)

Forward a method call to self.reservation if there is only one occurrence.

Utilities

indico.modules.rb.util.TempReservationConcurrentOccurrence

alias of ReservationOccurrenceTmp

indico.modules.rb.util.TempReservationOccurrence

alias of ReservationOccurrenceTmp

indico.modules.rb.util.build_rooms_spritesheet()
indico.modules.rb.util.check_empty_candidates(candidates)

Check for empty candidates.

This checks that a created time-series has at least one occurrence to filter by (similar to check_impossible_repetition() but without the need to pass all the data).

indico.modules.rb.util.check_impossible_repetition(data)

Check for broken repetition data.

This checks that a repetition using weekdays has a date range containing at least one of the specified weekdays.

indico.modules.rb.util.check_repeat_frequency(old_frequency, new_frequency)

Prevent changing the repeat frequency of an existing booking.

indico.modules.rb.util.format_weekdays(weekdays)

Format a list of weekdays into a nice readable string.

indico.modules.rb.util.generate_spreadsheet_from_occurrences(occurrences)

Generate spreadsheet data from a given booking occurrence list.

Parameters:

occurrences – The booking occurrences to include in the spreadsheet

indico.modules.rb.util.get_booking_params_for_event(event)

Get a set of RB interface parameters suitable for this event.

These parameters can then be used to construct a URL that will lead to a pre-filled search that matches the start/end times for a given day.

Parameters:

eventEvent object

indico.modules.rb.util.get_linked_object(type_, id_)
indico.modules.rb.util.get_prebooking_collisions(reservation)
indico.modules.rb.util.get_resized_room_photo(room)
indico.modules.rb.util.group_by_occurrence_date(occurrences, sort_by=None)
indico.modules.rb.util.is_booking_start_within_grace_period(start_dt, user, allow_admin=False)
indico.modules.rb.util.rb_check_if_visible(user)

Check if user should see links to the room booking system.

indico.modules.rb.util.rb_check_user_access(user)

Check if the user has access to the room booking system.

indico.modules.rb.util.rb_is_admin(user)

Check if the user is a room booking admin.

indico.modules.rb.util.remove_room_spritesheet_photo(room)
indico.modules.rb.util.serialize_availability(availability)
indico.modules.rb.util.serialize_blockings(data)
indico.modules.rb.util.serialize_booking_details(booking)
indico.modules.rb.util.serialize_concurrent_pre_bookings(data)
indico.modules.rb.util.serialize_nonbookable_periods(data)
indico.modules.rb.util.serialize_occurrences(data)
indico.modules.rb.util.serialize_unbookable_hours(data)
indico.modules.rb.statistics.calculate_rooms_bookable_time(rooms, start_date=None, end_date=None)
indico.modules.rb.statistics.calculate_rooms_booked_time(rooms, start_date=None, end_date=None)
indico.modules.rb.statistics.calculate_rooms_occupancy(rooms, start=None, end=None)