コード例 #1
0
def addQueue(request):
    try:
        userprofile = UserProfile.objects.get(pk=request.user)
    except UserProfile.DoesNotExist:
        return render(request, "booking/booking_status_empty_profile.html")

    try:
        if request.method == 'POST':  # If the form has been submitted...
            form = BookingForm(request.POST)  # A form bound to the POST data

            if form.is_valid():
                maxPeople_preference = form.cleaned_data[
                    'maxPeople_preference']
                backend.addQueue(request.user, userprofile.serie,
                                 maxPeople_preference)
                backend.refreshBooking(userprofile.serie)
                return redirect("booking.views.status")
            else:
                render(request, 'booking/booking_start.html', {
                    'form': form,
                })
        else:
            return redirect("booking.views.status")
    except:
        return render(request, 'booking/booking_start.html', {
            'form': BookingForm(),
        })
コード例 #2
0
def addQueue(request):
  try:
    userprofile = UserProfile.objects.get(pk=request.user)
  except UserProfile.DoesNotExist:
    return render(request, "booking/booking_status_empty_profile.html")
  
  try:
    if request.method == 'POST': # If the form has been submitted...
      form = BookingForm(request.POST) # A form bound to the POST data
      
      if form.is_valid(): 
        maxPeople_preference = form.cleaned_data['maxPeople_preference']
        backend.addQueue(request.user, userprofile.serie, maxPeople_preference)
        backend.refreshBooking(userprofile.serie)
        return redirect("booking.views.status") 
      else:
        render(request, 'booking/booking_start.html', {
                'form': form,
          }
        )
    else:
      return redirect("booking.views.status") 
  except: 
    return render(request, 'booking/booking_start.html', {
                'form': BookingForm(),
              }
            )
コード例 #3
0
 def test_refreshBooking2(self):
     """
 Tests the refresh of the booking
 """
     self.assertEqual(len(SlotBooked.objects.all()), 0)
     backend.refreshBooking(2)
     self.assertEqual(len(SlotBooked.objects.filter(slot__serie=2)), 1)
     self.assertEqual(len(SlotBooked.objects.filter(slot__serie=1)), 0)
コード例 #4
0
 def test_refreshBooking2(self):
   """
   Tests the refresh of the booking
   """
   self.assertEqual(len(SlotBooked.objects.all()), 0)
   backend.refreshBooking(2)
   self.assertEqual(len(SlotBooked.objects.filter(slot__serie=2)), 1)
   self.assertEqual(len(SlotBooked.objects.filter(slot__serie=1)), 0)
コード例 #5
0
 def test_refreshBooking1(self):
   """
   Tests the refresh of the booking
   """
   backend.refreshBooking(1)
   self.assertEqual(len(Queue.objects.all()), 2)
   self.assertEqual(len(SlotBooked.objects.all()), 3)
   self.assertEqual(SlotBooked.objects.all()[0].user.username, "DummyUser")
   self.assertEqual(len(SlotBooked.objects.filter(slot__room__maxPeople=1)), 1)
   self.assertEqual(len(SlotBooked.objects.filter(slot__room__maxPeople=2)), 2)
コード例 #6
0
 def test_refreshBooking1(self):
     """
 Tests the refresh of the booking
 """
     backend.refreshBooking(1)
     self.assertEqual(len(Queue.objects.all()), 2)
     self.assertEqual(len(SlotBooked.objects.all()), 3)
     self.assertEqual(SlotBooked.objects.all()[0].user.username,
                      "DummyUser")
     self.assertEqual(
         len(SlotBooked.objects.filter(slot__room__maxPeople=1)), 1)
     self.assertEqual(
         len(SlotBooked.objects.filter(slot__room__maxPeople=2)), 2)