def librarian_reservations_list(request, user_id): if request.user.is_authenticated(): reservations = get_all_reservations() return render(request, 'views/librarian_reservations_list.html', {'user_id':user_id, 'reservations':reservations}) else: return render(request, 'views/index.html')
def librarian_borrow_book_return_reservations(request, user_id, reservation_id): if request.user.is_authenticated(): reservation = Reservation.objects.get(id = reservation_id) borrow = Borrow() borrow.book_id = reservation.book_id borrow.user_id = reservation.user_id borrow.date_of_borrow = date.today() borrow.save() reservation.delete() reservations = get_all_reservations() return render(request, 'views/librarian_reservations_list.html', {'user_id':user_id, 'reservations':reservations}) else: return render(request, 'views/index.html')
def librarian_delete_reservation(request, user_id, reservation_id): if request.user.is_authenticated(): reservation = Reservation.objects.get(id = reservation_id) book = reservation.book_id tome = Tome.objects.get(book_id = book) tome.amount = tome.amount + 1 if book.availability == 0: book.availability = 1 book.save() tome.save() reservation.delete() reservations = get_all_reservations() return render(request, 'views/librarian_reservations_list.html', {'user_id':user_id, 'reservations':reservations}) else: return render(request, 'views/index.html')