fixes
[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         'entities': models.Entity.objects.exclude(lat=None).exclude(lon=None),
12         'funding_no_show_current': True,
13     })
14
15 def pin_map_tagged(request, tags):
16     try:
17         tags = analyse_tags(request, tags)
18     except:
19         raise #Http404()
20
21     books = Book.tagged.with_all(tags)
22
23     return render(request, 'references/map.html', {
24         'entities': models.Entity.objects.exclude(lat=None).exclude(lon=None).filter(reference__book__in=books).distinct(),
25         'funding_no_show_current': True,
26     })
27
28
29
30 @never_cache
31 def popup(request, pk):
32     e = get_object_or_404(models.Entity, pk=pk)
33     return render(request, 'references/popup.html', {
34         'entity': e,
35     })
36