OAI catalogue, started implementation + tests
[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 from django.views.decorators.cache import never_cache
7
8
9 @never_cache
10 def wait(request, path):
11     if WaitedFile.exists(path):
12         file_url = join(WAITER_URL, path)
13     else:
14         file_url = ""
15         waiting = get_object_or_404(WaitedFile, path=path)
16         if waiting.is_stale():
17             waiting = None
18
19     if request.is_ajax():
20         return HttpResponse(file_url)
21     else:
22         return render(request, "waiter/wait.html", locals())