ignore unfilled placeholders, add an atom: namespace to opensearch.xml
[wolnelektury.git] / apps / waiter / views.py
1 from os.path import join
2 from waiter.models import WaitedFile
3 from waiter.settings import WAITER_URL
4 from django.shortcuts import render, get_object_or_404
5 from django.http import HttpResponse
6
7 def wait(request, path):
8     if WaitedFile.exists(path):
9         file_url = join(WAITER_URL, path)
10     else:
11         file_url = ""
12         waiting = get_object_or_404(WaitedFile, path=path)
13         if waiting.is_stale():
14             waiting = None
15
16     if request.is_ajax():
17         return HttpResponse(file_url)
18     else:
19         return render(request, "waiter/wait.html", locals())