def _sidemenu_sections(sender, **kwargs): user_has_rooms = session.user is not None and Room.user_owns_rooms(session.user) yield SideMenuSection('search', _("Search"), 40, icon='search', active=True) if user_has_rooms: yield SideMenuSection('my_rooms', _("My Rooms"), 30, icon='user') yield SideMenuSection('blocking', _("Room Blocking"), 20, icon='lock')
def _sidemenu_items(sender, **kwargs): user_is_admin = session.user is not None and rb_is_admin(session.user) user_has_rooms = session.user is not None and Room.user_owns_rooms(session.user) map_available = Location.default_location is not None and Location.default_location.is_map_available yield SideMenuItem('book_room', _('Book a Room'), url_for('rooms.book'), 80, icon='checkmark') if map_available: yield SideMenuItem('map', _('Map of Rooms'), url_for('rooms.roomBooking-mapOfRooms'), 70, icon='location') yield SideMenuItem('calendar', _('Calendar'), url_for('rooms.calendar'), 60, icon='calendar') yield SideMenuItem('my_bookings', _('My Bookings'), url_for('rooms.my_bookings'), 50, icon='time') yield SideMenuItem('search_bookings', _('Search bookings'), url_for('rooms.roomBooking-search4Bookings'), section='search') yield SideMenuItem('search_rooms', _('Search rooms'), url_for('rooms.search_rooms'), section='search') if user_has_rooms: yield SideMenuItem('bookings_in_my_rooms', _('Bookings in my rooms'), url_for('rooms.bookings_my_rooms'), section='my_rooms') yield SideMenuItem('prebookings_in_my_rooms', _('Pre-bookings in my rooms'), url_for('rooms.pending_bookings_my_rooms'), section='my_rooms') yield SideMenuItem('room_list', _('Room list'), url_for('rooms.search_my_rooms'), section='my_rooms') yield SideMenuItem('my_blockings', _('My Blockings'), url_for('rooms.blocking_list', only_mine=True, timeframe='recent'), section='blocking') if user_has_rooms: yield SideMenuItem('blockings_my_rooms', _('Blockings for my rooms'), url_for('rooms.blocking_my_rooms'), section='blocking') yield SideMenuItem('blocking_create', _('Block rooms'), url_for('rooms.create_blocking'), section='blocking') if user_is_admin: yield SideMenuItem('admin', _('Administration'), url_for('rooms_admin.roomBooking-admin'), 10, icon='user-chairperson')
def _sidemenu_items(sender, **kwargs): user_is_admin = session.user is not None and rb_is_admin(session.user) user_has_rooms = session.user is not None and Room.user_owns_rooms(session.user) map_available = Location.default_location is not None and Location.default_location.is_map_available yield SideMenuItem('book_room', _('Book a Room'), url_for('rooms.book'), 80, icon='checkmark') if map_available: yield SideMenuItem('map', _('Map of Rooms'), url_for('rooms.roomBooking-mapOfRooms'), 70, icon='location') yield SideMenuItem('calendar', _('Calendar'), url_for('rooms.calendar'), 60, icon='calendar') yield SideMenuItem('my_bookings', _('My Bookings'), url_for('rooms.my_bookings'), 50, icon='time') yield SideMenuItem('search_bookings', _('Search bookings'), url_for('rooms.roomBooking-search4Bookings'), section='search') yield SideMenuItem('search_rooms', _('Search rooms'), url_for('rooms.search_rooms'), section='search') if user_has_rooms: yield SideMenuItem('bookings_in_my_rooms', _('Bookings in my rooms'), url_for('rooms.bookings_my_rooms'), section='my_rooms') yield SideMenuItem('prebookings_in_my_rooms', _('Pre-bookings in my rooms'), url_for('rooms.pending_bookings_my_rooms'), section='my_rooms') yield SideMenuItem('room_list', _('Room list'), url_for('rooms.search_my_rooms'), section='my_rooms') yield SideMenuItem('my_blockings', _('My Blockings'), url_for('rooms.blocking_list', only_mine=True, timeframe='recent'), section='blocking') if user_has_rooms: yield SideMenuItem('blockings_my_rooms', _('Blockings for my rooms'), url_for('rooms.blocking_my_rooms'), section='blocking') yield SideMenuItem('blocking_create', _('Block rooms'), url_for('rooms.create_blocking'), section='blocking') if user_is_admin: yield SideMenuItem('admin', _('Administration'), url_for('rooms_admin.roomBooking-admin'), 10, icon='user-chairperson')
def _sidemenu_sections(sender, **kwargs): user_has_rooms = session.user is not None and Room.user_owns_rooms(session.user) yield SideMenuSection('search', _("Search"), 40, icon='search', active=True) if user_has_rooms: yield SideMenuSection('my_rooms', _("My Rooms"), 30, icon='user') yield SideMenuSection('blocking', _("Room Blocking"), 20, icon='lock')
def _sidemenu_sections(sender, **kwargs): user_has_rooms = session.user is not None and Room.user_owns_rooms(session.user) yield SideMenuSection("search", _("Search"), 40, icon="search", active=True) if user_has_rooms: yield SideMenuSection("my_rooms", _("My Rooms"), 30, icon="user") yield SideMenuSection("blocking", _("Room Blocking"), 20, icon="lock")
def _process_args(self): defaults = FormDefaults(location=Location.default_location) self._form = SearchRoomsForm(self._get_form_data(), obj=defaults, csrf_enabled=False) if (not session.user or not Room.user_owns_rooms( session.user)) and not hasattr(self, 'search_criteria'): # Remove the form element if the user has no rooms and we are not using a shortcut del self._form.is_only_my_rooms
def test_ownership_functions(dummy_room, create_user, create_room_attribute, is_owner, has_group, in_group, expected): user = create_user(u'user') create_room_attribute(u'manager-group') if is_owner: dummy_room.owner = user if has_group: dummy_room.set_attribute_value(u'manager-group', u'managers') if in_group: user.groups.add(u'managers') assert dummy_room.is_owned_by(user) == expected assert Room.user_owns_rooms(user) == expected assert set(Room.get_owned_by(user)) == ({dummy_room} if expected else set())
def test_ownership_functions(dummy_room, create_user, create_room_attribute, create_group, is_owner, has_group, in_group, expected): other_user = create_user(123) create_room_attribute(u'manager-group') if is_owner: dummy_room.owner = other_user if has_group: dummy_room.set_attribute_value(u'manager-group', u'123') if in_group: other_user.local_groups.add(create_group(123).group) assert dummy_room.is_owned_by(other_user) == expected assert Room.user_owns_rooms(other_user) == expected assert set(Room.get_owned_by(other_user)) == ({dummy_room} if expected else set())
def test_ownership_functions(dummy_room, create_user, create_room_attribute, create_group, is_owner, has_group, in_group, expected): other_user = create_user(123) create_room_attribute(u'manager-group') if is_owner: dummy_room.owner = other_user if has_group: dummy_room.set_attribute_value(u'manager-group', u'123') if in_group: other_user.local_groups.add(create_group(123).group) assert dummy_room.is_owned_by(other_user) == expected assert Room.user_owns_rooms(other_user) == expected assert set(Room.get_owned_by(other_user)) == ({dummy_room} if expected else set())
def test_ownership_functions(dummy_room, create_user, create_room_attribute, is_owner, has_group, in_group, expected): user = create_user(u'user') create_room_attribute(u'manager-group') if is_owner: dummy_room.owner = user if has_group: dummy_room.set_attribute_value(u'manager-group', u'managers') if in_group: user.groups.add(u'managers') assert dummy_room.is_owned_by(user) == expected assert Room.user_owns_rooms(user) == expected assert set( Room.get_owned_by(user)) == ({dummy_room} if expected else set())
def _sidemenu_items(sender, **kwargs): user_is_admin = session.user is not None and rb_is_admin(session.user) user_has_rooms = session.user is not None and Room.user_owns_rooms(session.user) map_available = Location.default_location is not None and Location.default_location.is_map_available yield SideMenuItem("book_room", _("Book a Room"), url_for("rooms.book"), 80, icon="checkmark") if map_available: yield SideMenuItem("map", _("Map of Rooms"), url_for("rooms.roomBooking-mapOfRooms"), 70, icon="location") yield SideMenuItem("calendar", _("Calendar"), url_for("rooms.calendar"), 60, icon="calendar") yield SideMenuItem("my_bookings", _("My Bookings"), url_for("rooms.my_bookings"), 50, icon="time") yield SideMenuItem( "search_bookings", _("Search bookings"), url_for("rooms.roomBooking-search4Bookings"), section="search" ) yield SideMenuItem("search_rooms", _("Search rooms"), url_for("rooms.search_rooms"), section="search") if user_has_rooms: yield SideMenuItem( "bookings_in_my_rooms", _("Bookings in my rooms"), url_for("rooms.bookings_my_rooms"), section="my_rooms" ) yield SideMenuItem( "prebookings_in_my_rooms", _("Pre-bookings in my rooms"), url_for("rooms.pending_bookings_my_rooms"), section="my_rooms", ) yield SideMenuItem("room_list", _("Room list"), url_for("rooms.search_my_rooms"), section="my_rooms") yield SideMenuItem( "my_blockings", _("My Blockings"), url_for("rooms.blocking_list", only_mine=True, timeframe="recent"), section="blocking", ) if user_has_rooms: yield SideMenuItem( "blockings_my_rooms", _("Blockings for my rooms"), url_for("rooms.blocking_my_rooms"), section="blocking" ) yield SideMenuItem("blocking_create", _("Block rooms"), url_for("rooms.create_blocking"), section="blocking") if user_is_admin: yield SideMenuItem( "admin", _("Administration"), url_for("rooms_admin.roomBooking-admin"), 10, icon="user-chairperson" )
def _getSideMenu(self): self._leftMenu = BasicSideMenu(session.user is not None) user_has_rooms = session.user is not None and Room.user_owns_rooms(session.user) user_is_admin = session.user is not None and rb_is_admin(session.user) self._roomsBookingOpt = SideMenuSection(currentPage=url_for('rooms.book')) self._bookRoomNewOpt = SideMenuItem( _('Book a Room'), url_for('rooms.book'), enabled=True ) self._roomMapOpt = SideMenuItem( _('Map of rooms'), urlHandlers.UHRoomBookingMapOfRooms.getURL(), enabled=True ) self._bookingListCalendarOpt = SideMenuItem( _('Calendar'), url_for('rooms.calendar'), enabled=True ) self._bookingsOpt = SideMenuSection( _('View My Bookings'), urlHandlers.UHRoomBookingSearch4Bookings.getURL() ) self._myBookingListOpt = SideMenuItem( _('My bookings'), url_for('rooms.my_bookings'), enabled=True ) self._usersBookingsOpt = SideMenuItem( _('Bookings in my rooms'), url_for('rooms.bookings_my_rooms'), enabled=user_has_rooms ) self._usersPendingBookingsOpt = SideMenuItem( _('Pre-bookings in my rooms'), url_for('rooms.pending_bookings_my_rooms'), enabled=user_has_rooms ) self._bookingListSearchOpt = SideMenuItem( _('Search bookings'), urlHandlers.UHRoomBookingSearch4Bookings.getURL(), enabled=True ) self._blockingsOpt = SideMenuSection(_('Room Blocking')) self._usersBlockingsOpt = SideMenuItem( _('Blockings for my rooms'), url_for('rooms.blocking_my_rooms', state='pending'), enabled=user_has_rooms ) self._roomsOpt = SideMenuSection(_('View Rooms')) self._roomSearchOpt = SideMenuItem( _('Search rooms'), url_for('rooms.search_rooms'), enabled=True ) self._myRoomListOpt = SideMenuItem( _('My rooms'), url_for('rooms.search_my_rooms'), enabled=user_has_rooms ) self._blockingListOpt = SideMenuItem( _('Blockings'), url_for('rooms.blocking_list', only_mine=True, timeframe='recent'), enabled=True ) self._blockRoomsOpt = SideMenuItem( _('Block rooms'), url_for('rooms.create_blocking') ) if user_is_admin: self._adminSect = SideMenuSection( _('Administration'), urlHandlers.UHRoomBookingAdmin.getURL() ) self._adminOpt = SideMenuItem( _('Administration'), urlHandlers.UHRoomBookingAdmin.getURL() ) self._leftMenu.addSection(self._roomsBookingOpt) self._roomsBookingOpt.addItem(self._bookRoomNewOpt) default_location = Location.default_location if default_location and default_location.is_map_available: self._roomsBookingOpt.addItem(self._roomMapOpt) self._roomsBookingOpt.addItem(self._bookingListCalendarOpt) self._leftMenu.addSection(self._bookingsOpt) self._bookingsOpt.addItem(self._myBookingListOpt) self._bookingsOpt.addItem(self._usersBookingsOpt) self._bookingsOpt.addItem(self._usersPendingBookingsOpt) self._bookingsOpt.addItem(self._bookingListSearchOpt) self._leftMenu.addSection(self._blockingsOpt) self._blockingsOpt.addItem(self._blockRoomsOpt) self._blockingsOpt.addItem(self._blockingListOpt) self._blockingsOpt.addItem(self._usersBlockingsOpt) self._leftMenu.addSection(self._roomsOpt) self._roomsOpt.addItem(self._roomSearchOpt) self._roomsOpt.addItem(self._myRoomListOpt) if user_is_admin: self._leftMenu.addSection(self._adminSect) self._adminSect.addItem(self._adminOpt) return self._leftMenu
def _getSideMenu(self): self._leftMenu = BasicSideMenu(session.user is not None) user_has_rooms = session.user is not None and Room.user_owns_rooms(session.user) user_is_admin = session.user is not None and rb_is_admin(session.user) self._roomsBookingOpt = SideMenuSection(icon="icon-checkmark") self._calendarOpt = SideMenuSection(icon="icon-calendar") self._mapOpt = SideMenuSection(icon="icon-location") self._searchOpt = SideMenuSection(_("Search"), active=True, icon="icon-search") self._roomsOpt = SideMenuSection(_("My Rooms"), visible=user_has_rooms, icon="icon-user") self._bookingsOpt = SideMenuSection(_("My Bookings"), active=True, icon="icon-time") self._blockingsOpt = SideMenuSection(_("Room Blocking"), icon="icon-lock") self._bookRoomNewOpt = SideMenuItem(_("Book a Room"), url_for("rooms.book"), enabled=True) self._roomMapOpt = SideMenuItem(_("Map of rooms"), urlHandlers.UHRoomBookingMapOfRooms.getURL(), enabled=True) self._bookingListCalendarOpt = SideMenuItem(_("Calendar"), url_for("rooms.calendar"), enabled=True) self._myBookingListOpt = SideMenuItem(_("My bookings"), url_for("rooms.my_bookings"), enabled=True) self._usersBookingsOpt = SideMenuItem( _("Bookings in my rooms"), url_for("rooms.bookings_my_rooms"), enabled=user_has_rooms ) self._usersPendingBookingsOpt = SideMenuItem( _("Pre-bookings in my rooms"), url_for("rooms.pending_bookings_my_rooms"), enabled=user_has_rooms ) self._bookingListSearchOpt = SideMenuItem( _("Search bookings"), urlHandlers.UHRoomBookingSearch4Bookings.getURL(), enabled=True ) self._usersBlockingsOpt = SideMenuItem( _("Blockings for my rooms"), url_for("rooms.blocking_my_rooms", state="pending"), enabled=user_has_rooms ) self._roomSearchOpt = SideMenuItem(_("Search rooms"), url_for("rooms.search_rooms"), enabled=True) self._myRoomListOpt = SideMenuItem(_("Room List"), url_for("rooms.search_my_rooms"), enabled=user_has_rooms) self._blockingListOpt = SideMenuItem( _("Blockings"), url_for("rooms.blocking_list", only_mine=True, timeframe="recent"), enabled=True ) self._blockRoomsOpt = SideMenuItem(_("Block rooms"), url_for("rooms.create_blocking")) if user_is_admin: self._adminSect = SideMenuSection(_("Administration"), icon="icon-user-chairperson") self._adminOpt = SideMenuItem(_("Administration"), urlHandlers.UHRoomBookingAdmin.getURL()) self._roomsBookingOpt.addItem(self._bookRoomNewOpt) default_location = Location.default_location if default_location and default_location.is_map_available: self._mapOpt.addItem(self._roomMapOpt) self._calendarOpt.addItem(self._bookingListCalendarOpt) self._searchOpt.addItem(self._roomSearchOpt) self._searchOpt.addItem(self._bookingListSearchOpt) self._bookingsOpt.addItem(self._myBookingListOpt) self._roomsOpt.addItem(self._usersBookingsOpt) self._roomsOpt.addItem(self._usersPendingBookingsOpt) self._roomsOpt.addItem(self._myRoomListOpt) self._blockingsOpt.addItem(self._blockRoomsOpt) self._blockingsOpt.addItem(self._blockingListOpt) self._blockingsOpt.addItem(self._usersBlockingsOpt) self._leftMenu.addSection(self._roomsBookingOpt) self._leftMenu.addSection(self._mapOpt) self._leftMenu.addSection(self._calendarOpt) self._leftMenu.addSection(self._bookingsOpt) self._leftMenu.addSection(self._searchOpt) self._leftMenu.addSection(self._roomsOpt) self._leftMenu.addSection(self._blockingsOpt) if user_is_admin: self._leftMenu.addSection(self._adminSect) self._adminSect.addItem(self._adminOpt) return self._leftMenu
def has_managed_rooms(user): if _can_get_all_groups(user): return _query_managed_rooms(user).has_rows() else: return Room.user_owns_rooms(user)
def _checkParams(self): defaults = FormDefaults(location=Location.default_location) self._form = SearchRoomsForm(self._get_form_data(), obj=defaults, csrf_enabled=False) if (not session.user or not Room.user_owns_rooms(session.user)) and not hasattr(self, 'search_criteria'): # Remove the form element if the user has no rooms and we are not using a shortcut del self._form.is_only_my_rooms
def has_rooms(self): """Checks if the user has any rooms""" from indico.modules.rb.models.rooms import Room # avoid circular import return Room.user_owns_rooms(self)
def has_rooms(self): """Checks if the user has any rooms""" from indico.modules.rb.models.rooms import Room # avoid circular import return Room.user_owns_rooms(self)
def has_managed_rooms(user): if _can_get_all_groups(user): return _query_managed_rooms(user).has_rows() else: return Room.user_owns_rooms(user)