Preparing for Django 1.10
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 15 Feb 2019 14:07:05 +0000 (15:07 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 15 Feb 2019 14:07:05 +0000 (15:07 +0100)
15 files changed:
requirements/requirements.txt
src/ajaxable/utils.py
src/api/piston/admin.py
src/api/tests/tests.py
src/catalogue/views.py
src/infopages/views.py
src/lesmianator/views.py
src/libraries/views.py
src/pdcounter/views.py
src/picture/views.py
src/polls/views.py
src/reporting/views.py
src/search/views.py
src/wolnelektury/settings/contrib.py
src/wolnelektury/utils.py

index fd98553..85e69d1 100644 (file)
@@ -2,16 +2,16 @@
 
 # django
 Django>=1.9,<1.10
 
 # 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
 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-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-allauth>=0.32,<0.33
-django-extensions
+django-extensions==1.7.8
 djangorestframework<3.7
 djangorestframework-xml
 oauthlib>=3.0.1,<3.1
 djangorestframework<3.7
 djangorestframework-xml
 oauthlib>=3.0.1,<3.1
@@ -20,7 +20,7 @@ oauthlib>=3.0.1,<3.1
 pyyaml
 
 polib
 pyyaml
 
 polib
-django-babel==0.5.0
+django-babel==0.6.0
 
 pytz
 
 
 pytz
 
@@ -72,7 +72,7 @@ requests
 paypalrestsdk
 
 django-haystack<2.8.0
 paypalrestsdk
 
 django-haystack<2.8.0
-django-migdal>=0.8.3
+django-migdal==0.8.5
 
 python-slugify
 
 
 python-slugify
 
index 82de847..89dd0e2 100755 (executable)
@@ -5,8 +5,7 @@
 from functools import wraps
 
 from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden
 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
 from django.utils.encoding import force_unicode
 from django.utils.functional import Promise
 from django.utils.http import urlquote_plus
@@ -153,7 +152,7 @@ class AjaxableFormView(object):
                 "view_kwargs": kwargs,
             }
         context.update(self.extra_context(request, obj))
                 "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
 
     def validate_object(self, obj, request):
         return None
index 792f196..c931db0 100644 (file)
@@ -2,6 +2,10 @@ from django.contrib import admin
 from . import models
 
 
 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.Nonce)
 admin.site.register(models.Consumer)
-admin.site.register(models.Token)
+admin.site.register(models.Token, TokenAdmin)
index 3b4d4c5..8dd29a5 100644 (file)
@@ -230,7 +230,7 @@ class BooksTests(ApiTest):
 
 class BlogTests(ApiTest):
     def test_get(self):
 
 class BlogTests(ApiTest):
     def test_get(self):
-        self.assertEqual(self.load_json('/api/blog/'), [])
+        self.assertEqual(self.load_json('/api/blog'), [])
 
 
 class PreviewTests(ApiTest):
 
 
 class PreviewTests(ApiTest):
index 2e43bd0..1f2db19 100644 (file)
@@ -7,9 +7,8 @@ import random
 
 from django.conf import settings
 from django.http.response import HttpResponseForbidden
 
 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.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
 from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpResponsePermanentRedirect
 from django.core.urlresolvers import reverse
 from django.db.models import Q, QuerySet
@@ -52,14 +51,14 @@ def book_list(request, filters=None, template_name='catalogue/book_list.html',
     for tag in books_by_author:
         if books_by_author[tag]:
             books_nav.setdefault(tag.sort_key[0], []).append(tag)
     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,
         })
         '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):
 
 
 def daisy_list(request):
@@ -80,9 +79,9 @@ def differentiate_tags(request, tags, ambiguous_slugs):
             'url_args': '/'.join((beginning, tag.url_chunk, unparsed)).strip('/'),
             'tags': [tag]
         })
             '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):
 
 
 def object_list(request, objects, fragments=None, related_tags=None, tags=None, list_type='books', extra=None):
@@ -133,9 +132,10 @@ def object_list(request, objects, fragments=None, related_tags=None, tags=None,
     }
     if extra:
         result.update(extra)
     }
     if extra:
         result.update(extra)
-    return render_to_response(
+    return render(
+        request,
         'catalogue/tagged_object_list.html', result,
         'catalogue/tagged_object_list.html', result,
-        context_instance=RequestContext(request))
+    )
 
 
 def literature(request):
 
 
 def literature(request):
@@ -258,12 +258,15 @@ def book_fragments(request, slug, theme_slug):
     fragments = Fragment.tagged.with_all([theme]).filter(
         Q(book=book) | Q(book__ancestor=book))
 
     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):
 
 
 def book_detail(request, slug):
@@ -272,11 +275,14 @@ def book_detail(request, slug):
     except Book.DoesNotExist:
         return pdcounter_views.book_stub_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
 
 
 # używane w publicznym interfejsie
@@ -287,12 +293,15 @@ def player(request, slug):
 
     audiobooks, projects = book.get_audiobooks()
 
 
     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):
 
 
 def book_text(request, slug):
@@ -303,7 +312,7 @@ def book_text(request, slug):
 
     if not book.has_html_file():
         raise Http404
 
     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})
 
 
 # =========
 
 
 # =========
@@ -338,7 +347,7 @@ def book_info(request, book_id, lang='pl'):
     book = get_object_or_404(Book, id=book_id)
     # set language by hand
     translation.activate(lang)
     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):
 
 
 def tag_info(request, tag_id):
index 9f21ed7..fe2db84 100644 (file)
@@ -2,7 +2,7 @@
 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 # 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
 from django.template import RequestContext, Template, TemplateSyntaxError
 
 from infopages.models import InfoPage
@@ -21,8 +21,8 @@ def infopage(request, slug):
     except TemplateSyntaxError:
         right_column = ''
 
     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,
         'page': page,
         'left_column': left_column,
         'right_column': right_column,
-    }, context_instance=RequestContext(request))
+    })
index 35aa078..f814bbc 100644 (file)
@@ -2,8 +2,7 @@
 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 # 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
 from django.views.decorators import cache
 
 from catalogue.utils import get_random_hash
@@ -15,11 +14,10 @@ def main_page(request):
     last = Poem.objects.all().order_by('-created_at')[:10]
     shelves = Tag.objects.filter(user__username='lesmianator')
 
     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',
         'lesmianator/lesmianator.html',
-        {"last": last, "shelves": shelves},
-        context_instance=RequestContext(request))
-
+        {"last": last, "shelves": shelves})
 
 @cache.never_cache
 def new_poem(request):
 
 @cache.never_cache
 def new_poem(request):
@@ -28,10 +26,10 @@ def new_poem(request):
     p = Poem(slug=get_random_hash(text), text=text, created_by=user)
     p.save()
 
     p = Poem(slug=get_random_hash(text), text=text, created_by=user)
     p.save()
 
-    return render_to_response(
+    return render(
+        request,
         'lesmianator/poem.html',
         'lesmianator/poem.html',
-        {"poem": p},
-        context_instance=RequestContext(request))
+        {"poem": p})
 
 
 @cache.never_cache
 
 
 @cache.never_cache
@@ -43,10 +41,10 @@ def poem_from_book(request, slug):
     p.created_from = [book.id]
     p.save()
 
     p.created_from = [book.id]
     p.save()
 
-    return render_to_response(
+    return render(
+        request,
         'lesmianator/poem.html',
         'lesmianator/poem.html',
-        {"poem": p, "books": [book], "book": book},
-        context_instance=RequestContext(request))
+        {"poem": p, "books": [book], "book": book})
 
 
 @cache.never_cache
 
 
 @cache.never_cache
@@ -61,10 +59,10 @@ def poem_from_set(request, shelf):
 
     book = books[0] if len(books) == 1 else None
 
 
     book = books[0] if len(books) == 1 else None
 
-    return render_to_response(
+    return render(
+        request,
         'lesmianator/poem.html',
         '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):
 
 
 def get_poem(request, poem):
@@ -76,7 +74,7 @@ def get_poem(request, poem):
     else:
         books = book = None
 
     else:
         books = book = None
 
-    return render_to_response(
+    return render(
+        request,
         'lesmianator/poem.html',
         'lesmianator/poem.html',
-        {"poem": p, "books": books, "book": book},
-        context_instance=RequestContext(request))
+        {"poem": p, "books": books, "book": book})
index ab4b4b7..98b3634 100644 (file)
@@ -1,26 +1,23 @@
-# -*- 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)),
+    })
index b8a685e..3be24c0 100644 (file)
@@ -3,8 +3,7 @@
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 from datetime import datetime
 # 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
 from django.views.decorators import cache
 from suggest.forms import PublishingSuggestForm
 from . import models
@@ -20,11 +19,11 @@ def book_stub_detail(request, slug):
 
     form = PublishingSuggestForm(initial={"books": u"%s — %s, \n" % (book.author, book.title)})
 
 
     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,
         'book': book,
         'pd_counter': pd_counter,
         'form': form,
-    }, context_instance=RequestContext(request))
+    })
 
 
 @cache.never_cache
 
 
 @cache.never_cache
@@ -37,8 +36,8 @@ def author_detail(request, slug):
 
     form = PublishingSuggestForm(initial={"books": author.name + ", \n"})
 
 
     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,
         'author': author,
         'pd_counter': pd_counter,
         'form': form,
-    }, context_instance=RequestContext(request))
+    })
index 6f02007..a43c095 100644 (file)
@@ -4,8 +4,7 @@
 #
 from django.conf import settings
 from django.contrib.auth.decorators import permission_required
 #
 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
 from picture.models import Picture, PictureArea
 from catalogue.utils import split_tags
 from ssify import ssi_included
@@ -20,7 +19,7 @@ def picture_list_thumb(request, filter=None, get_filter=None, template_name='pic
         pictures = pictures.filter(filter)
     if get_filter:
         pictures = pictures.filter(get_filter())
         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):
 
 
 def picture_detail(request, slug):
@@ -28,12 +27,12 @@ def picture_detail(request, slug):
 
     theme_things = split_tags(picture.related_themes())
 
 
     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',
         '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):
 
 
 def picture_viewer(request, slug):
@@ -43,10 +42,10 @@ def picture_viewer(request, slug):
         have_sponsors = Sponsor.objects.filter(name=sponsor)
         if have_sponsors.exists():
             sponsors.append(have_sponsors[0])
         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,
         'picture': picture,
         'sponsors': sponsors,
-    }, context_instance=RequestContext(request))
+    })
 
 
 @ajax(method='get')
 
 
 @ajax(method='get')
index 0d9590d..ffafd2a 100644 (file)
@@ -3,8 +3,7 @@
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 from django.core.urlresolvers import reverse
 # 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
 
 from django.views.decorators import cache
 from django.views.decorators.http import require_http_methods
 
@@ -30,7 +29,7 @@ def poll(request, slug):
                     poll_item.vote(request.session)
         return redirect(redirect_to)
     elif request.method == 'GET':
                     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)
         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)
index 963440c..cc1bf7e 100644 (file)
@@ -7,8 +7,7 @@ from datetime import date
 from django.conf import settings
 from django.contrib.admin.views.decorators import staff_member_required
 from django.db.models import Count
 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
 
 from catalogue.models import Book, BookMedia
 from reporting.utils import render_to_pdf, render_to_csv, generated_file_view
@@ -30,10 +29,10 @@ def stats_page(request):
         (b.extra_info.get('license'), b.extra_info.get('license_description'))
         for b in Book.objects.all().iterator() if b.extra_info.get('license'))
 
         (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,
         'media_types': media_types,
         'licenses': licenses,
-    }, context_instance=RequestContext(request))
+    })
 
 
 @generated_file_view('reports/katalog.pdf', 'application/pdf',
 
 
 @generated_file_view('reports/katalog.pdf', 'application/pdf',
index 39284c7..3bbe720 100644 (file)
@@ -4,8 +4,7 @@
 #
 from django.conf import settings
 from django.http.response import HttpResponseRedirect
 #
 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
 
 from django.views.decorators import cache
 from django.http import HttpResponse, JsonResponse
 
@@ -108,12 +107,13 @@ def hint(request):
 def main(request):
     query = request.GET.get('q', '')
     if len(query) < 2:
 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:
     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)
 
     query = prepare_query(query)
     pd_authors = search_pd_authors(query)
@@ -123,27 +123,26 @@ def main(request):
 
     if not (books or pictures or pd_authors):
         form = PublishingSuggestForm(initial={"books": 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
             '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())
 
 
     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
         '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()
 
 def search_books(query):
     search = Search()
index f3e7b6b..2fed2f3 100644 (file)
@@ -44,6 +44,10 @@ MIGDAL_TYPES = (
     EntryType('event', _('events'), commentable=False),
 )
 
     EntryType('event', _('events'), commentable=False),
 )
 
+MIGDAL_OPTIONAL_LANGUAGES = (
+    ('en', u'English'),
+)
+
 REST_FRAMEWORK = {
     "DEFAULT_RENDERER_CLASSES": (
         'rest_framework.renderers.JSONRenderer',
 REST_FRAMEWORK = {
     "DEFAULT_RENDERER_CLASSES": (
         'rest_framework.renderers.JSONRenderer',
index 2657a55..142d33f 100644 (file)
@@ -15,7 +15,6 @@ from inspect import getargspec
 import re
 from django.core.mail import send_mail
 from django.http import HttpResponse
 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
 from django.template.loader import render_to_string
 from django.utils import timezone
 from django.conf import settings
@@ -101,7 +100,7 @@ def ajax(login_required=False, method=None, template=None, permission_required=N
                 try:
                     res = fun(request, **kwargs)
                     if res and template:
                 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:
                 except AjaxError as e:
                     res = {'result': e.args[0]}
             if 'result' not in res: