blackout
[wolnelektury.git] / src / references / views.py
1 from django.http import Http404
2 from django.shortcuts import render, get_object_or_404
3 from django.views.decorators.cache import never_cache
4 from catalogue.models import Book
5 from catalogue.views import analyse_tags
6 from . import models
7
8
9 def pin_map(request):
10     return render(request, 'references/map.html', {
11         'title': 'Wakacje',
12         'entities': models.Entity.objects.exclude(lat=None).exclude(lon=None),
13         'funding_no_show_current': True,
14     })
15
16 def pin_map_tagged(request, tags):
17     try:
18         tags = analyse_tags(request, tags)
19     except:
20         raise #Http404()
21
22     books = Book.tagged.with_all(tags)
23
24     return render(request, 'references/map.html', {
25         'entities': models.Entity.objects.exclude(lat=None).exclude(lon=None).filter(reference__book__in=books).distinct(),
26         'funding_no_show_current': True,
27     })
28
29
30 def popup(request, pk):
31     e = get_object_or_404(models.Entity, pk=pk)
32     return render(request, 'references/popup.html', {
33         'entity': e,
34     })
35