예제 #1
0
def get_room_nonbookable_periods_conflicts(candidates, occurrences):
    conflicts = set()
    conflicting_candidates = set()
    for candidate in candidates:
        for occurrence in occurrences:
            overlap = get_overlap((candidate.start_dt, candidate.end_dt), (occurrence.start_dt, occurrence.end_dt))
            if overlap.count(None) != len(overlap):
                conflicting_candidates.add(candidate)
                obj = TempReservationOccurrence(overlap[0], overlap[1], None)
                conflicts.add(obj)
    return conflicts, conflicting_candidates
예제 #2
0
def get_room_blockings_conflicts(room_id, candidates, occurrences):
    conflicts = set()
    conflicting_candidates = set()
    for candidate in candidates:
        for occurrence in occurrences:
            blocking = occurrence.blocking
            if blocking.start_date <= candidate.start_dt.date() <= blocking.end_date:
                if blocking.can_override(session.user, room=Room.get(room_id)):
                    continue
                conflicting_candidates.add(candidate)
                obj = TempReservationOccurrence(candidate.start_dt, candidate.end_dt, None)
                conflicts.add(obj)
    return conflicts, conflicting_candidates
예제 #3
0
def get_room_unbookable_hours_conflicts(candidates, occurrences):
    conflicts = set()
    conflicting_candidates = set()
    for candidate in candidates:
        for occurrence in occurrences:
            hours_start_dt = candidate.start_dt.replace(hour=occurrence.start_time.hour,
                                                        minute=occurrence.start_time.minute)
            hours_end_dt = candidate.end_dt.replace(hour=occurrence.end_time.hour,
                                                    minute=occurrence.end_time.minute)
            overlap = get_overlap((candidate.start_dt, candidate.end_dt), (hours_start_dt, hours_end_dt))
            if overlap.count(None) != len(overlap):
                conflicting_candidates.add(candidate)
                obj = TempReservationOccurrence(overlap[0], overlap[1], None)
                conflicts.add(obj)
    return conflicts, conflicting_candidates
예제 #4
0
def get_room_bookings_conflicts(candidates, occurrences, room_id, skip_conflicts_with=frozenset()):
    conflicts = set()
    pre_conflicts = set()
    conflicting_candidates = set()
    for candidate in candidates:
        for occurrence in occurrences:
            if occurrence.reservation.id in skip_conflicts_with:
                continue
            if candidate.overlaps(occurrence):
                conflicting_candidates.add(candidate)
                overlap = candidate.get_overlap(occurrence)
                obj = TempReservationOccurrence(*overlap, reservation=occurrence.reservation)
                if occurrence.reservation.is_accepted:
                    conflicts.add(obj)
                else:
                    pre_conflicts.add(obj)
    return conflicts, pre_conflicts, conflicting_candidates