Remove machina, remove default cache config, add some upgrades and compatibility...
[wolnelektury.git] / src / waiter / views.py
1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 from os.path import join
5 from waiter.models import WaitedFile
6 from waiter.settings import WAITER_URL
7 from django.shortcuts import render, get_object_or_404
8 from django.http import HttpResponse
9 from django.views.decorators.cache import never_cache
10
11
12 @never_cache
13 def wait(request, path):
14     if WaitedFile.exists(path):
15         file_url = join(WAITER_URL, path)
16         waiting = None
17     else:
18         file_url = None
19         waiting = get_object_or_404(WaitedFile, path=path)
20
21     if request.is_ajax():
22         return HttpResponse(file_url)
23     else:
24         return render(request, "waiter/wait.html", {
25             'waiting': waiting,
26             'file_url': file_url,
27         })