def user_reservations(request, user_id): if request.user.is_authenticated(): reservations = get_reservations(user_id) return render(request, 'views/user_reservations.html', {'user_id':user_id, 'reservations':reservations}) else: return render(request, 'views/index.html')
def user_reserve_delete(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_reservations(user_id) return render(request, 'views/user_reservations.html', {'user_id':user_id, 'reservations':reservations}) else: return render(request, 'views/index.html')