# django
Django>=1.9,<1.10
-fnpdjango>=0.2.8,<0.3
-django-pipeline>=1.6,<1.7
+fnpdjango==0.3
+django-pipeline==1.6.10
jsmin
-fnp-django-pagination
+fnp-django-pagination==2.2.2
django-maintenancemode==0.10
jsonfield==2.0.2
django-picklefield>=1.0,<1.1
-django-modeltranslation==0.11
+django-modeltranslation==0.12
django-allauth>=0.32,<0.33
-django-extensions
+django-extensions==1.7.8
djangorestframework<3.7
djangorestframework-xml
oauthlib>=3.0.1,<3.1
pyyaml
polib
-django-babel==0.5.0
+django-babel==0.6.0
pytz
paypalrestsdk
django-haystack<2.8.0
-django-migdal>=0.8.3
+django-migdal==0.8.5
python-slugify
from functools import wraps
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden
-from django.shortcuts import render_to_response
-from django.template import RequestContext
+from django.shortcuts import render
from django.utils.encoding import force_unicode
from django.utils.functional import Promise
from django.utils.http import urlquote_plus
"view_kwargs": kwargs,
}
context.update(self.extra_context(request, obj))
- return render_to_response(template, context, context_instance=RequestContext(request))
+ return render(request, template, context)
def validate_object(self, obj, request):
return None
from . import models
+class TokenAdmin(admin.ModelAdmin):
+ raw_id_fields = ['user']
+
+
admin.site.register(models.Nonce)
admin.site.register(models.Consumer)
-admin.site.register(models.Token)
+admin.site.register(models.Token, TokenAdmin)
class BlogTests(ApiTest):
def test_get(self):
- self.assertEqual(self.load_json('/api/blog/'), [])
+ self.assertEqual(self.load_json('/api/blog'), [])
class PreviewTests(ApiTest):
from django.conf import settings
from django.http.response import HttpResponseForbidden
-from django.template import RequestContext
from django.template.loader import render_to_string
-from django.shortcuts import render_to_response, get_object_or_404, render, redirect
+from django.shortcuts import get_object_or_404, render, redirect
from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpResponsePermanentRedirect
from django.core.urlresolvers import reverse
from django.db.models import Q, QuerySet
for tag in books_by_author:
if books_by_author[tag]:
books_nav.setdefault(tag.sort_key[0], []).append(tag)
- return render_to_response(template_name, {
+ return render(request, template_name, {
'rendered_nav': render_to_string(nav_template_name, {'books_nav': books_nav}),
'rendered_book_list': render_to_string(list_template_name, {
'books_by_author': books_by_author,
'orphans': orphans,
'books_by_parent': books_by_parent,
})
- }, context_instance=RequestContext(request))
+ })
def daisy_list(request):
'url_args': '/'.join((beginning, tag.url_chunk, unparsed)).strip('/'),
'tags': [tag]
})
- return render_to_response(
- 'catalogue/differentiate_tags.html', {'tags': tags, 'options': options, 'unparsed': ambiguous_slugs[1:]},
- context_instance=RequestContext(request))
+ return render(
+ request,
+ 'catalogue/differentiate_tags.html', {'tags': tags, 'options': options, 'unparsed': ambiguous_slugs[1:]})
def object_list(request, objects, fragments=None, related_tags=None, tags=None, list_type='books', extra=None):
}
if extra:
result.update(extra)
- return render_to_response(
+ return render(
+ request,
'catalogue/tagged_object_list.html', result,
- context_instance=RequestContext(request))
+ )
def literature(request):
fragments = Fragment.tagged.with_all([theme]).filter(
Q(book=book) | Q(book__ancestor=book))
- return render_to_response('catalogue/book_fragments.html', {
- 'book': book,
- 'theme': theme,
- 'fragments': fragments,
- 'active_menu_item': 'books',
- }, context_instance=RequestContext(request))
+ return render(
+ request,
+ 'catalogue/book_fragments.html',
+ {
+ 'book': book,
+ 'theme': theme,
+ 'fragments': fragments,
+ 'active_menu_item': 'books',
+ })
def book_detail(request, slug):
except Book.DoesNotExist:
return pdcounter_views.book_stub_detail(request, slug)
- return render_to_response('catalogue/book_detail.html', {
- 'book': book,
- 'book_children': book.children.all().order_by('parent_number', 'sort_key'),
- 'active_menu_item': 'books',
- }, context_instance=RequestContext(request))
+ return render(
+ request,
+ 'catalogue/book_detail.html',
+ {
+ 'book': book,
+ 'book_children': book.children.all().order_by('parent_number', 'sort_key'),
+ 'active_menu_item': 'books',
+ })
# używane w publicznym interfejsie
audiobooks, projects = book.get_audiobooks()
- return render_to_response('catalogue/player.html', {
- 'book': book,
- 'audiobook': '',
- 'audiobooks': audiobooks,
- 'projects': projects,
- }, context_instance=RequestContext(request))
+ return render(
+ request,
+ 'catalogue/player.html',
+ {
+ 'book': book,
+ 'audiobook': '',
+ 'audiobooks': audiobooks,
+ 'projects': projects,
+ })
def book_text(request, slug):
if not book.has_html_file():
raise Http404
- return render_to_response('catalogue/book_text.html', {'book': book}, context_instance=RequestContext(request))
+ return render(request, 'catalogue/book_text.html', {'book': book})
# =========
book = get_object_or_404(Book, id=book_id)
# set language by hand
translation.activate(lang)
- return render_to_response('catalogue/book_info.html', {'book': book}, context_instance=RequestContext(request))
+ return render(request, 'catalogue/book_info.html', {'book': book})
def tag_info(request, tag_id):
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
-from django.shortcuts import render_to_response, get_object_or_404
+from django.shortcuts import render, get_object_or_404
from django.template import RequestContext, Template, TemplateSyntaxError
from infopages.models import InfoPage
except TemplateSyntaxError:
right_column = ''
- return render_to_response('infopages/infopage.html', {
+ return render(request, 'infopages/infopage.html', {
'page': page,
'left_column': left_column,
'right_column': right_column,
- }, context_instance=RequestContext(request))
+ })
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
-from django.shortcuts import render_to_response, get_object_or_404
-from django.template import RequestContext
+from django.shortcuts import render, get_object_or_404
from django.views.decorators import cache
from catalogue.utils import get_random_hash
last = Poem.objects.all().order_by('-created_at')[:10]
shelves = Tag.objects.filter(user__username='lesmianator')
- return render_to_response(
+ return render(
+ request,
'lesmianator/lesmianator.html',
- {"last": last, "shelves": shelves},
- context_instance=RequestContext(request))
-
+ {"last": last, "shelves": shelves})
@cache.never_cache
def new_poem(request):
p = Poem(slug=get_random_hash(text), text=text, created_by=user)
p.save()
- return render_to_response(
+ return render(
+ request,
'lesmianator/poem.html',
- {"poem": p},
- context_instance=RequestContext(request))
+ {"poem": p})
@cache.never_cache
p.created_from = [book.id]
p.save()
- return render_to_response(
+ return render(
+ request,
'lesmianator/poem.html',
- {"poem": p, "books": [book], "book": book},
- context_instance=RequestContext(request))
+ {"poem": p, "books": [book], "book": book})
@cache.never_cache
book = books[0] if len(books) == 1 else None
- return render_to_response(
+ return render(
+ request,
'lesmianator/poem.html',
- {"poem": p, "shelf": tag, "books": books, "book": book},
- context_instance=RequestContext(request))
+ {"poem": p, "shelf": tag, "books": books, "book": book})
def get_poem(request, poem):
else:
books = book = None
- return render_to_response(
+ return render(
+ request,
'lesmianator/poem.html',
- {"poem": p, "books": books, "book": book},
- context_instance=RequestContext(request))
+ {"poem": p, "books": books, "book": book})
-# -*- coding: utf-8 -*-\r
-# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.\r
-# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.\r
-#\r
-from django.shortcuts import render_to_response, get_object_or_404\r
-from django.template import RequestContext\r
-\r
-from libraries.models import Catalog, Library\r
-\r
-\r
-def main_view(request):\r
- context = RequestContext(request)\r
- context['catalogs'] = Catalog.objects.all()\r
- return render_to_response('libraries/main_view.html', context_instance=context)\r
-\r
-\r
-def catalog_view(request, slug):\r
- context = RequestContext(request)\r
- context['catalog'] = get_object_or_404(Catalog.objects.filter(slug=slug).select_related())\r
- return render_to_response('libraries/catalog_view.html', context_instance=context)\r
-\r
-\r
-def library_view(request, catalog_slug, slug):\r
- context = RequestContext(request)\r
- context['library'] = get_object_or_404(Library.objects.filter(slug=slug).filter(catalog__slug=catalog_slug))\r
- return render_to_response('libraries/library_view.html', context_instance=context)\r
+# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from django.shortcuts import render, get_object_or_404
+from libraries.models import Catalog, Library
+
+
+def main_view(request):
+ return render(request, 'libraries/main_view.html', {
+ "catalogs": Catalog.objects.all(),
+ })
+
+
+def catalog_view(request, slug):
+ return render(request, 'libraries/catalog_view.html', {
+ "catalog": get_object_or_404(Catalog.objects.filter(slug=slug).select_related()),
+ })
+
+def library_view(request, catalog_slug, slug):
+ return render(request, 'libraries/library_view.html', {
+ "library": get_object_or_404(Library.objects.filter(slug=slug).filter(catalog__slug=catalog_slug)),
+ })
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from datetime import datetime
-from django.template import RequestContext
-from django.shortcuts import render_to_response, get_object_or_404
+from django.shortcuts import render, get_object_or_404
from django.views.decorators import cache
from suggest.forms import PublishingSuggestForm
from . import models
form = PublishingSuggestForm(initial={"books": u"%s — %s, \n" % (book.author, book.title)})
- return render_to_response('pdcounter/book_stub_detail.html', {
+ return render(request, 'pdcounter/book_stub_detail.html', {
'book': book,
'pd_counter': pd_counter,
'form': form,
- }, context_instance=RequestContext(request))
+ })
@cache.never_cache
form = PublishingSuggestForm(initial={"books": author.name + ", \n"})
- return render_to_response('pdcounter/author_detail.html', {
+ return render(request, 'pdcounter/author_detail.html', {
'author': author,
'pd_counter': pd_counter,
'form': form,
- }, context_instance=RequestContext(request))
+ })
#
from django.conf import settings
from django.contrib.auth.decorators import permission_required
-from django.shortcuts import render_to_response, get_object_or_404, render
-from django.template import RequestContext
+from django.shortcuts import render, get_object_or_404, render
from picture.models import Picture, PictureArea
from catalogue.utils import split_tags
from ssify import ssi_included
pictures = pictures.filter(filter)
if get_filter:
pictures = pictures.filter(get_filter())
- return render_to_response(template_name, {'book_list': list(pictures)}, context_instance=RequestContext(request))
+ return render(request, template_name, {'book_list': list(pictures)})
def picture_detail(request, slug):
theme_things = split_tags(picture.related_themes())
- return render_to_response("picture/picture_detail.html", {
+ return render(request, "picture/picture_detail.html", {
'picture': picture,
'themes': theme_things.get('theme', []),
'things': theme_things.get('thing', []),
'active_menu_item': 'gallery',
- }, context_instance=RequestContext(request))
+ })
def picture_viewer(request, slug):
have_sponsors = Sponsor.objects.filter(name=sponsor)
if have_sponsors.exists():
sponsors.append(have_sponsors[0])
- return render_to_response("picture/picture_viewer.html", {
+ return render(request, "picture/picture_viewer.html", {
'picture': picture,
'sponsors': sponsors,
- }, context_instance=RequestContext(request))
+ })
@ajax(method='get')
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from django.core.urlresolvers import reverse
-from django.shortcuts import get_object_or_404, redirect, render_to_response
-from django.template import RequestContext
+from django.shortcuts import get_object_or_404, redirect, render
from django.views.decorators import cache
from django.views.decorators.http import require_http_methods
poll_item.vote(request.session)
return redirect(redirect_to)
elif request.method == 'GET':
- context = RequestContext(request)
+ context = {}
context['poll'] = poll
context['voted_already'] = poll.voted(request.session)
- return render_to_response('polls/poll.html', context)
+ return render(request, 'polls/poll.html', context)
from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
from django.db.models import Count
-from django.shortcuts import render_to_response
-from django.template import RequestContext
+from django.shortcuts import render
from catalogue.models import Book, BookMedia
from reporting.utils import render_to_pdf, render_to_csv, generated_file_view
(b.extra_info.get('license'), b.extra_info.get('license_description'))
for b in Book.objects.all().iterator() if b.extra_info.get('license'))
- return render_to_response('reporting/main.html', {
+ return render(request, 'reporting/main.html', {
'media_types': media_types,
'licenses': licenses,
- }, context_instance=RequestContext(request))
+ })
@generated_file_view('reports/katalog.pdf', 'application/pdf',
#
from django.conf import settings
from django.http.response import HttpResponseRedirect
-from django.shortcuts import render_to_response
-from django.template import RequestContext
+from django.shortcuts import render
from django.views.decorators import cache
from django.http import HttpResponse, JsonResponse
def main(request):
query = request.GET.get('q', '')
if len(query) < 2:
- return render_to_response(
- 'catalogue/search_too_short.html', {'prefix': query},
- context_instance=RequestContext(request))
+ return render(
+ request, 'catalogue/search_too_short.html',
+ {'prefix': query})
elif len(query) > 256:
- return render_to_response(
- 'catalogue/search_too_long.html', {'prefix': query}, context_instance=RequestContext(request))
+ return render(
+ request, 'catalogue/search_too_long.html',
+ {'prefix': query})
query = prepare_query(query)
pd_authors = search_pd_authors(query)
if not (books or pictures or pd_authors):
form = PublishingSuggestForm(initial={"books": query + ", "})
- return render_to_response(
+ return render(
+ request,
'catalogue/search_no_hits.html',
{
'form': form,
'did_you_mean': suggestion
- },
- context_instance=RequestContext(request))
+ })
if not (books or pictures) and len(pd_authors) == 1:
return HttpResponseRedirect(pd_authors[0].get_absolute_url())
- return render_to_response(
+ return render(
+ request,
'catalogue/search_multiple_hits.html',
{
'pd_authors': pd_authors,
'books': books,
'pictures': pictures,
'did_you_mean': suggestion
- },
- context_instance=RequestContext(request))
-
+ })
def search_books(query):
search = Search()
EntryType('event', _('events'), commentable=False),
)
+MIGDAL_OPTIONAL_LANGUAGES = (
+ ('en', u'English'),
+)
+
REST_FRAMEWORK = {
"DEFAULT_RENDERER_CLASSES": (
'rest_framework.renderers.JSONRenderer',
import re
from django.core.mail import send_mail
from django.http import HttpResponse
-from django.template import RequestContext
from django.template.loader import render_to_string
from django.utils import timezone
from django.conf import settings
try:
res = fun(request, **kwargs)
if res and template:
- res = {'html': render_to_string(template, res, RequestContext(request))}
+ res = {'html': render_to_string(template, res, request=request)}
except AjaxError as e:
res = {'result': e.args[0]}
if 'result' not in res: