Room booking¶
Todo
Docstrings (module, models, utilities, services)
Models¶
-
class
indico.modules.rb.models.rooms.
Room
(**kwargs)¶ Bases:
indico.core.db.sqlalchemy.util.cache._CacheVersionMixin
,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.
-
attributes
¶
-
available_equipment
¶
-
blocked_rooms
¶
-
bookable_hours
¶
-
booking_limit_days
¶
-
booking_url
¶
-
building
¶
-
can_be_booked
(user, ignore_admin=False)¶ Reservable rooms which does not require pre-booking can be booked by anyone. Other rooms - only by their responsibles.
-
can_be_deleted
(user)¶
-
can_be_modified
(user)¶ Only admin can modify rooms.
-
can_be_overridden
(user)¶
-
can_be_prebooked
(user, ignore_admin=False)¶ Reservable rooms can be pre-booked by anyone. Other rooms - only by their responsibles.
-
capacity
¶
-
check_advance_days
(end_date, user=None, quiet=False)¶
-
check_bookable_hours
(start_time, end_time, user=None, quiet=False)¶
-
comments
¶
-
details_url
¶
-
division
¶
-
static
filter_available
(start_dt, end_dt, repetition, include_pre_bookings=True, include_pending_blockings=True)¶ Returns a SQLAlchemy filter criterion ensuring that the room is available during the given time.
-
classmethod
find_all
(*args, **kwargs)¶ Retrieves rooms, sorted by location and full name
-
find_available_vc_equipment
()¶
-
classmethod
find_with_attribute
(attribute)¶ Search rooms which have a specific attribute
-
static
find_with_filters
(filters, user=None)¶
-
floor
¶
-
full_name
¶
-
generate_name
()¶
-
get_attribute_by_name
(attribute_name)¶
-
get_attribute_value
(*args, **kwargs)¶
-
get_blocked_rooms
(*dates, **kwargs)¶
-
classmethod
get_owned_by
(user)¶
-
static
get_with_data
(*args, **kwargs)¶
-
has_attribute
(attribute_name)¶
-
has_booking_groups
¶
-
has_equipment
(*args, **kwargs)¶
-
has_live_reservations
()¶
-
has_photo
¶
-
has_projector
¶
-
has_special_name
¶
-
has_vc
¶
-
has_webcast_recording
¶
-
id
¶
-
is_active
¶
-
is_auto_confirm
¶
-
is_owned_by
(**kwargs)¶ Checks if the user is managing the room (owner or manager)
-
is_public
¶
-
is_reservable
¶
-
key_location
¶
-
kind
¶
-
large_photo_url
¶
-
latitude
¶
-
location_id
¶
-
location_name
¶
-
locator
¶ Defines a smart locator property.
This behaves pretty much like a normal read-only property and the decorated function should return a dict containing the necessary data to build a URL for the object.
This decorator should usually be applied to a method named
locator
as this name is required for get_locator to find it automatically when just passing the object.If you need more than one locator, you can define it like this:
@locator_property def locator(self): return {...} @locator.other def locator(self): return {...}
The
other
locator can then be accessed by passingobj.locator.other
to the code expecting an object with a locator.
-
longitude
¶
-
manager_emails
¶
-
map_url
¶
-
marker_description
¶
-
max_advance_days
¶
-
max_capacity
¶ staticmethod(function) -> method
Convert a function to be a static method.
A static method does not receive an implicit first argument. To declare a static method, use this idiom:
class C: def f(arg1, arg2, …): … f = staticmethod(f)It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.
Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.
-
name
¶
-
nonbookable_periods
¶
-
notification_before_days
¶
-
notification_before_days_monthly
¶
-
notification_before_days_weekly
¶
-
notification_emails
¶
-
notification_for_assistance
¶
-
notifications_enabled
¶
-
number
¶
-
owner
¶ The owner of the room. If the room has the manager-group attribute set, any users in that group are also considered owners when it comes to management privileges. Use
is_owned_by()
for ownership checks that should also check against the management group.
-
owner_id
¶
-
photo
¶
-
photo_id
¶
-
reservations
¶
-
reservations_need_confirmation
¶
-
set_attribute_value
(name, value)¶
-
site
¶
-
small_photo_url
¶
-
surface_area
¶
-
telephone
¶
-
update_name
()¶
-
classmethod
user_owns_rooms
(user)¶
-
-
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.
-
children
¶
-
id
¶
-
is_required
¶
-
location_id
¶
-
name
¶
-
parent_id
¶
-
title
¶
-
type
¶
-
-
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.aspects.
Aspect
(**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.
-
bottom_right_latitude
¶
-
bottom_right_longitude
¶
-
center_latitude
¶
-
center_longitude
¶
-
default_on_startup
¶
-
id
¶
-
location_id
¶
-
name
¶
-
top_left_latitude
¶
-
top_left_longitude
¶
-
zoom_level
¶
-
-
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_be_deleted
(user)¶
-
can_be_modified
(user)¶ The following persons are authorized to modify a blocking: - owner (the one who created the blocking) - admin (of course)
-
can_be_overridden
(user, room=None, explicit_only=False)¶ Determines if a user can override the blocking
The following persons are authorized to override a blocking: - owner (the one who created the blocking) - any users on the blocking’s ACL - unless explicitOnly is set: admins and room owners (if a room is given)
-
created_by_id
¶
-
created_by_user
¶ The user who created this blocking.
-
created_dt
¶
-
end_date
¶
-
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
¶
-
classmethod
find_with_filters
(filters)¶
-
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
¶
-
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'¶
-
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.
-
children
¶
-
id
¶
-
location_id
¶
-
name
¶
-
parent_id
¶
-
-
class
indico.modules.rb.models.holidays.
Holiday
(**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.
-
date
¶
-
id
¶
-
location_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.
-
aspects
¶
-
attributes
¶
-
default_aspect
¶
-
default_aspect_id
¶
-
default_location
¶ classmethod(function) -> method
Convert a function to be a class method.
A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:
- class C:
- def f(cls, arg1, arg2, …): … f = classmethod(f)
It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.
Class methods are different than C++ or Java static methods. If you want those, see the staticmethod builtin.
-
equipment_types
¶
-
get_attribute_by_name
(name)¶
-
get_buildings
()¶
-
get_equipment_by_name
(name)¶
-
holidays
¶
-
id
¶
-
is_default
¶
-
is_map_available
¶
-
locator
¶ Defines a smart locator property.
This behaves pretty much like a normal read-only property and the decorated function should return a dict containing the necessary data to build a URL for the object.
This decorator should usually be applied to a method named
locator
as this name is required for get_locator to find it automatically when just passing the object.If you need more than one locator, you can define it like this:
@locator_property def locator(self): return {...} @locator.other def locator(self): return {...}
The
other
locator can then be accessed by passingobj.locator.other
to the code expecting an object with a locator.
-
map_url_template
¶
-
name
¶
-
rooms
¶
-
set_default
()¶
-
working_time_end
= datetime.time(17, 30)¶
-
working_time_periods
= ((datetime.time(8, 30), datetime.time(12, 30)), (datetime.time(13, 30), datetime.time(17, 30)))¶
-
working_time_start
= datetime.time(8, 30)¶
-
-
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
¶
-
thumbnail
¶
-
-
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
convert_legacy_repeatability
(**kw)¶
-
classmethod
get_message
(**kw)¶
-
classmethod
get_short_name
(**kw)¶
-
mapping
= {(<RepeatFrequency.NEVER: 0>, 0): ('Single reservation', None, 'none'), (<RepeatFrequency.DAY: 1>, 1): ('Repeat daily', 0, 'daily'), (<RepeatFrequency.WEEK: 2>, 1): ('Repeat once a week', 1, 'weekly'), (<RepeatFrequency.WEEK: 2>, 2): ('Repeat once every two weeks', 2, 'everyTwoWeeks'), (<RepeatFrequency.WEEK: 2>, 3): ('Repeat once every three weeks', 3, 'everyThreeWeeks'), (<RepeatFrequency.MONTH: 3>, 1): ('Repeat every month', 4, '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
(**kwargs)¶
-
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_be_accepted
(**kwargs)¶
-
can_be_cancelled
(**kwargs)¶
-
can_be_deleted
(**kwargs)¶
-
can_be_modified
(**kwargs)¶
-
can_be_rejected
(**kwargs)¶
-
cancel
(**kwargs)¶
-
contact_email
¶
-
contact_phone
¶
-
classmethod
create_from_data
(room, data, user, prebook=None)¶ Creates 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.
-
create_occurrences
(skip_conflicts, user=None)¶
-
created_by_id
¶
-
created_by_user
¶ The user who created this booking.
-
created_dt
¶
-
details_url
¶
-
edit_logs
¶
-
end_dt
¶
-
event
¶ The Event this reservation was made for
-
event_id
¶
-
find_excluded_days
()¶
-
find_overlapping
()¶
-
static
find_overlapping_with
(room, occurrences, skip_reservation_id=None)¶
-
get_conflicting_occurrences
()¶
-
get_vc_equipment
()¶
-
static
get_with_data
(*args, **kwargs)¶
-
id
¶
-
is_accepted
¶
-
is_archived
¶
-
is_booked_for
(user)¶
-
is_cancelled
¶
-
is_owned_by
(**kwargs)¶
-
is_pending
¶
-
is_rejected
¶
-
is_repeating
¶
-
is_valid
¶
-
location_name
¶
-
locator
¶ Defines a smart locator property.
This behaves pretty much like a normal read-only property and the decorated function should return a dict containing the necessary data to build a URL for the object.
This decorator should usually be applied to a method named
locator
as this name is required for get_locator to find it automatically when just passing the object.If you need more than one locator, you can define it like this:
@locator_property def locator(self): return {...} @locator.other def locator(self): return {...}
The
other
locator can then be accessed by passingobj.locator.other
to the code expecting an object with a locator.
-
modify
(data, user)¶ Modifies 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
-
needs_assistance
¶
-
needs_vc_assistance
¶
-
occurrences
¶
-
reject
(**kwargs)¶
-
rejection_reason
¶
-
repeat_frequency
¶
-
repeat_interval
¶
-
repetition
¶
-
room_id
¶
-
start_dt
¶
-
status_string
¶
-
used_equipment
¶
-
uses_vc
¶
-
-
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.
-
cancel
(*args, **kwargs)¶
-
classmethod
create_series
(start, end, repetition)¶
-
classmethod
create_series_for_reservation
(reservation)¶
-
date
¶
-
end_dt
¶
-
static
filter_overlap
(occurrences)¶
-
classmethod
find_overlapping_with
(room, occurrences, skip_reservation_id=None)¶
-
classmethod
find_with_filters
(filters, user=None)¶
-
get_overlap
(occurrence, skip_self=False)¶
-
is_cancelled
¶
-
is_rejected
¶
-
is_valid
¶
-
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
¶
-
-
indico.modules.rb.models.util.
proxy_to_reservation_if_last_valid_occurrence
(f)¶ Forwards a method call to self.reservation if there is only one occurrence.
-
indico.modules.rb.models.util.
unimplemented
(exceptions=(<type 'exceptions.Exception'>, ), message='Unimplemented')¶
Utilities¶
-
indico.modules.rb.util.
get_default_booking_interval
(duration=90, precision=15, force_today=False)¶ Get the default booking interval for a room.
Returns the default booking interval for a room as a tuple containing the start and end times as datetime objects.
The start time is the default working start time or the current time (if the working start time is in the past); rounded up to the given precision in minutes (15 by default).
The end time corresponds to the start time plus the given duration in minutes. If the booking ends after the end of work time, it is automatically moved to the next day.
Parameters: - duration – int – The duration of a booking in minutes (must be greater than 1)
- precision – int – The number of minutes by which to round up the current time for the start time of a booking. Negative values are allowed but will round the time down and create a booking starting in the past.
- force_today – Forces a booking to be for today, even if it past the end of work time. This is ignored if the current time is either after 23:50 or within the amount of minutes of the precision from midnight. For example with a precision of 30 minutes, if the current time is 23:42 then the meeting will be the following day.
Returns: (datetime, datetime, bool) – A tuple with the start and end times of the booking and a boolean which is True if the date was changed from today and False otherwise.
Raises: ValueError if the duration is less than 1 minute
-
indico.modules.rb.util.
rb_check_user_access
(*args, **kwargs)¶ Checks if the user has access to the room booking system
-
indico.modules.rb.util.
rb_is_admin
(*args, **kwargs)¶ Checks if the user is a room booking admin
-
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)¶
-
indico.modules.rb.statistics.
compose_rooms_stats
(rooms)¶
Services¶
-
class
indico.modules.rb.services.rooms.
BookingPermission
(params)¶ Bases:
indico.legacy.services.implementation.base.LoggedOnlyService
-
UNICODE_PARAMS
= True¶
-
-
class
indico.modules.rb.services.rooms.
RoomBookingAvailabilitySearchRooms
(params)¶ Bases:
indico.legacy.services.implementation.base.ServiceBase
-
UNICODE_PARAMS
= True¶
-
-
class
indico.modules.rb.services.rooms.
RoomBookingListLocationsAndRoomsWithGuids
(params)¶ Bases:
indico.legacy.services.implementation.base.ServiceBase
-
UNICODE_PARAMS
= True¶
-
-
class
indico.modules.rb.services.aspects.
RoomBookingMapBase
(params)¶ Bases:
indico.legacy.services.implementation.base.ServiceBase
-
UNICODE_PARAMS
= True¶
-
-
class
indico.modules.rb.services.aspects.
RoomBookingMapCreateAspect
(params)¶ Bases:
indico.modules.rb.services.aspects.RoomBookingMapBase
-
class
indico.modules.rb.services.aspects.
RoomBookingMapListAspects
(params)¶ Bases:
indico.modules.rb.services.aspects.RoomBookingMapBase
-
class
indico.modules.rb.services.aspects.
RoomBookingMapRemoveAspect
(params)¶ Bases:
indico.modules.rb.services.aspects.RoomBookingMapBase
-
class
indico.modules.rb.services.aspects.
RoomBookingMapUpdateAspect
(params)¶ Bases:
indico.modules.rb.services.aspects.RoomBookingMapBase
-
class
indico.modules.rb.services.blockings.
RoomBookingBlockingApprove
(params)¶ Bases:
indico.modules.rb.services.blockings.RoomBookingBlockingProcessBase
-
class
indico.modules.rb.services.blockings.
RoomBookingBlockingProcessBase
(params)¶ Bases:
indico.legacy.services.implementation.base.ServiceBase
-
UNICODE_PARAMS
= True¶
-
-
class
indico.modules.rb.services.blockings.
RoomBookingBlockingReject
(params)¶ Bases:
indico.modules.rb.services.blockings.RoomBookingBlockingProcessBase