def _merge_users(target, source, **kwargs): Blocking.query.filter_by(created_by_id=source.id).update( {Blocking.created_by_id: target.id}) BlockingPrincipal.merge_users(target, source, 'blocking') Reservation.query.filter_by(created_by_id=source.id).update( {Reservation.created_by_id: target.id}) Reservation.query.filter_by(booked_for_id=source.id).update( {Reservation.booked_for_id: target.id}) Room.query.filter_by(owner_id=source.id).update({Room.owner_id: target.id}) RoomPrincipal.merge_users(target, source, 'room') rb_settings.acls.merge_users(target, source)
def _merge_users(target, source, **kwargs): from indico.modules.rb.models.blocking_principals import BlockingPrincipal from indico.modules.rb.models.blockings import Blocking from indico.modules.rb.models.principals import RoomPrincipal from indico.modules.rb.models.reservations import Reservation Blocking.query.filter_by(created_by_id=source.id).update({Blocking.created_by_id: target.id}) BlockingPrincipal.merge_users(target, source, 'blocking') Reservation.query.filter_by(created_by_id=source.id).update({Reservation.created_by_id: target.id}) Reservation.query.filter_by(booked_for_id=source.id).update({Reservation.booked_for_id: target.id}) Room.query.filter_by(owner_id=source.id).update({Room.owner_id: target.id}) RoomPrincipal.merge_users(target, source, 'room') rb_settings.acls.merge_users(target, source)
def _query_managed_rooms(user): criteria = [db.and_(RoomPrincipal.type == PrincipalType.user, RoomPrincipal.user_id == user.id, RoomPrincipal.has_management_permission())] for group in user.local_groups: criteria.append(db.and_(RoomPrincipal.type == PrincipalType.local_group, RoomPrincipal.local_group_id == group.id, RoomPrincipal.has_management_permission())) for group in user.iter_all_multipass_groups(): criteria.append(db.and_(RoomPrincipal.type == PrincipalType.multipass_group, RoomPrincipal.multipass_group_provider == group.provider.name, db.func.lower(RoomPrincipal.multipass_group_name) == group.name.lower(), RoomPrincipal.has_management_permission())) return Room.query.filter(~Room.is_deleted, Room.acl_entries.any(db.or_(*criteria)))