Room booking¶
Todo
Docstrings (module, models, utilities, services)
Models¶
-
class
indico.modules.rb.models.rooms.
Room
(**kwargs)¶ Bases:
indico.core.db.sqlalchemy.protection.ProtectionManagersMixin
,sqlalchemy.ext.declarative.api.Model
,indico.util.serializer.Serializer
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)¶
-
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)¶
-
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¶
-
details_url
¶
-
disallowed_protection_modes
= frozenset([<ProtectionMode.inheriting: 1>])¶
-
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_all
(*args, **kwargs)¶ Retrieve rooms, sorted by location and full name.
-
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)¶
-
has_photo
¶
-
id
¶
-
is_auto_confirm
¶
-
is_deleted
¶
-
is_reservable
¶
-
static
is_user_admin
(user)¶
-
key_location
¶
-
latitude
¶
-
location
¶
-
location_id
¶
-
location_name
¶
-
longitude
¶
-
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
¶
-
protection_parent
¶
-
reservations
¶
-
reservations_need_confirmation
¶
-
set_attribute_value
(name, value)¶
-
site
¶
-
sprite_position
¶
-
surface_area
¶
-
telephone
¶
-
verbose_name
¶ Verbose name for the room (long)
-
-
class
indico.modules.rb.models.room_attributes.
RoomAttribute
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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
¶
-
name
¶
-
title
¶
-
-
class
indico.modules.rb.models.room_attributes.
RoomAttributeAssociation
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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
¶
-
room_id
¶
-
value
¶
-
-
class
indico.modules.rb.models.room_bookable_hours.
BookableHours
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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)¶
-
room_id
¶
-
start_time
¶
-
-
class
indico.modules.rb.models.room_nonbookable_periods.
NonBookablePeriod
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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)¶
-
room_id
¶
-
start_dt
¶
-
-
class
indico.modules.rb.models.blockings.
Blocking
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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
¶
-
external_details_url
¶
-
id
¶
-
is_active_at
(d)¶
-
reason
¶
-
start_date
¶
-
-
class
indico.modules.rb.models.blocked_rooms.
BlockedRoom
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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
¶
-
reject
(user=None, reason=None)¶ Reject the room blocking.
-
rejected_by
¶
-
rejection_reason
¶
-
room_id
¶
-
state
¶
-
state_name
¶
-
-
class
indico.modules.rb.models.blocked_rooms.
BlockedRoomState
¶ Bases:
indico.util.struct.enum.RichIntEnum
-
accepted
= 1¶
-
pending
= 0¶
-
rejected
= 2¶
-
-
class
indico.modules.rb.models.blocking_principals.
BlockingPrincipal
(**kwargs)¶ Bases:
indico.core.db.sqlalchemy.principals.PrincipalMixin
,sqlalchemy.ext.declarative.api.Model
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
¶
-
local_group_id
¶
-
multipass_group_name
¶
-
multipass_group_provider
¶
-
principal_backref_name
= u'in_blocking_acls'¶
-
registration_form
= None¶
-
registration_form_id
= None¶
-
type
¶
-
unique_columns
= (u'blocking_id',)¶
-
user
¶
-
user_id
¶
-
-
class
indico.modules.rb.models.equipment.
EquipmentType
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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
¶
-
-
class
indico.modules.rb.models.locations.
Location
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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
¶
-
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)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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
¶
-
top_left_latitude
¶
-
top_left_longitude
¶
-
-
class
indico.modules.rb.models.photos.
Photo
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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
¶
-
-
exception
indico.modules.rb.models.reservations.
ConflictingOccurrences
¶ Bases:
exceptions.Exception
-
class
indico.modules.rb.models.reservations.
RepeatFrequency
¶ Bases:
int
,indico.util.struct.enum.IndicoEnum
-
DAY
= 1¶
-
MONTH
= 3¶
-
NEVER
= 0¶
-
WEEK
= 2¶
-
-
class
indico.modules.rb.models.reservations.
RepeatMapping
¶ Bases:
object
-
classmethod
get_message
(repeat_frequency, repeat_interval)¶
-
classmethod
get_short_name
(repeat_frequency, repeat_interval)¶
-
mapping
= {(<RepeatFrequency.NEVER: 0>, 0): (u'Single reservation', None, u'none'), (<RepeatFrequency.DAY: 1>, 1): (u'Repeat daily', 0, u'daily'), (<RepeatFrequency.WEEK: 2>, 1): (u'Repeat once a week', 1, u'weekly'), (<RepeatFrequency.WEEK: 2>, 2): (u'Repeat once every two weeks', 2, u'everyTwoWeeks'), (<RepeatFrequency.WEEK: 2>, 3): (u'Repeat once every three weeks', 3, u'everyThreeWeeks'), (<RepeatFrequency.MONTH: 3>, 1): (u'Repeat every month', 4, u'monthly')}¶
-
classmethod
-
class
indico.modules.rb.models.reservations.
Reservation
(**kwargs)¶ Bases:
indico.util.serializer.Serializer
,sqlalchemy.ext.declarative.api.Model
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)¶
-
contact_email
¶
-
classmethod
create_from_data
(room, data, user, prebook=None, ignore_admin=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.
-
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
¶
-
event
¶
-
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
¶
-
is_accepted
¶
-
is_archived
¶
-
is_booked_for
(user)¶
-
is_cancelled
¶
-
is_owned_by
(user)¶
-
is_pending
¶
-
is_rejected
¶
-
is_repeating
¶
-
link
¶
-
link_id
¶
-
linked_object
¶
-
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.
- data – A dict containing the booking data, usually from a
-
occurrences
¶
-
reject
(user, reason, silent=False)¶
-
rejection_reason
¶
-
repeat_frequency
¶
-
repeat_interval
¶
-
repetition
¶
-
reset_approval
(user)¶
-
room_id
¶
-
start_dt
¶
-
state
¶
-
-
class
indico.modules.rb.models.reservations.
ReservationLink
(**kwargs)¶ Bases:
indico.core.db.sqlalchemy.links.LinkMixin
,sqlalchemy.ext.declarative.api.Model
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_link_types
= set([<LinkType.event: 2>, <LinkType.contribution: 3>, <LinkType.session_block: 6>])¶
-
category
= None¶
-
category_id
= None¶
-
contribution
¶
-
contribution_id
¶
-
event
¶
-
event_id
¶
-
events_backref_name
= u'all_room_reservation_links'¶
-
id
¶
-
link_backref_name
= u'room_reservation_links'¶
-
link_type
¶
-
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
¶ Bases:
int
,indico.util.struct.enum.IndicoEnum
-
accepted
= 2¶
-
cancelled
= 3¶
-
pending
= 1¶
-
rejected
= 4¶
-
-
class
indico.modules.rb.models.reservation_edit_logs.
ReservationEditLog
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
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
¶
-
reservation_id
¶
-
timestamp
¶
-
user_name
¶
-
-
class
indico.modules.rb.models.reservation_occurrences.
ReservationOccurrence
(**kwargs)¶ Bases:
sqlalchemy.ext.declarative.api.Model
,indico.util.serializer.Serializer
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
(*args, **kwargs)¶
-
classmethod
create_series
(start, end, repetition)¶
-
classmethod
create_series_for_reservation
(reservation)¶
-
date
¶
-
end_dt
¶
-
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)¶
-
notification_sent
¶
-
overlaps
(occurrence, skip_self=False)¶
-
reject
(*args, **kwargs)¶
-
rejection_reason
¶
-
reservation_id
¶
-
start_dt
¶
-
state
¶
-
-
class
indico.modules.rb.models.reservation_occurrences.
ReservationOccurrenceState
¶ Bases:
int
,indico.util.struct.enum.IndicoEnum
-
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
indico.modules.rb.util.ReservationOccurrenceTmp
-
indico.modules.rb.util.
TempReservationOccurrence
¶ alias of
indico.modules.rb.util.ReservationOccurrenceTmp
-
indico.modules.rb.util.
build_rooms_spritesheet
()¶
-
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: event – Event 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_user_access
(*args, **kwargs)¶ Check if the user has access to the room booking system.
-
indico.modules.rb.util.
rb_is_admin
(*args, **kwargs)¶ 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)¶