X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/d66f9960d12d739c44a89d1d4e013f52783097e7..0b270a76ad73162f894285c360a0ee87fa84e536:/src/references/views.py diff --git a/src/references/views.py b/src/references/views.py index 91ea44a21..7e0e3574b 100644 --- a/src/references/views.py +++ b/src/references/views.py @@ -1,3 +1,35 @@ -from django.shortcuts import render +from django.http import Http404 +from django.shortcuts import render, get_object_or_404 +from django.views.decorators.cache import never_cache +from catalogue.models import Book +from catalogue.views import analyse_tags +from . import models -# Create your views here. + +def pin_map(request): + return render(request, 'references/map.html', { + 'title': 'Mapa Wolnych Lektur', + 'entities': models.Entity.objects.exclude(lat=None).exclude(lon=None), + 'funding_no_show_current': True, + }) + +def pin_map_tagged(request, tags): + try: + tags = analyse_tags(request, tags) + except: + raise #Http404() + + books = Book.tagged.with_all(tags) + + return render(request, 'references/map.html', { + 'entities': models.Entity.objects.exclude(lat=None).exclude(lon=None).filter(reference__book__in=books).distinct(), + 'funding_no_show_current': True, + }) + + +def popup(request, pk): + e = get_object_or_404(models.Entity, pk=pk) + return render(request, 'references/popup.html', { + 'entity': e, + }) +