Exemple #1
0
 def test_search_in_one_cluster(self):
     search = SingleSubjectManagerReservationSearch(
         subject_manager=self.hotel1.rooms, reservation_model=HotelRoomReservation
     )
     results = search.search("2050-01-05", "2050-01-22")
     length = len(results)
     self.assertEqual(length, 1, "There should be 1 results returned")
Exemple #2
0
def reservations(request, pool_id):
    pool = get_object_or_404(Pool, pk=pool_id)

    Form = PoolReservationsSearchForm

    form = Form(request.GET) if request.GET else Form()

    searcher = SingleSubjectManagerReservationSearch(
        reservation_model=LaneReservation, subject_manager=pool.subjects)

    reservations = (
        searcher.search(**form.cleaned_data)
        if form.is_valid() else
        LaneReservation.objects.filter(subject__cluster=pool)
        if not request.GET else
        []
    )

    return render(
        request,
        'pools/reservations.html',
        {
            'reservations': reservations,
            'pool': pool,
            'form': form,
        }
    )
Exemple #3
0
 def search(self, subject_manager):
     search = SingleSubjectManagerReservationSearch(reservation_model=LaneReservation,
                                                    subject_manager=subject_manager)
     return search.search(self.cleaned_data['start'], self.cleaned_data['end'])