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 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 _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')