From 2ba17dd61e3d52f1d986dbe8bde8f197c0259a9e Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 27 May 2015 23:10:26 +0200 Subject: [PATCH] Move reverse.js related code to the booking module --- api/tests.py | 9 --------- api/urls.py | 7 ------- booking/templates/front_template.html | 2 +- booking/tests.py | 13 +++++++++++-- duckbook/urls.py | 8 ++++++++ 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/api/tests.py b/api/tests.py index 69e4781..9e1c1bd 100644 --- a/api/tests.py +++ b/api/tests.py @@ -1,5 +1,4 @@ from django.test import TestCase, Client -from django.core.urlresolvers import reverse from django.contrib.auth.models import User from django.conf import settings @@ -16,14 +15,6 @@ def get_response_encoding(response): return encoding -class ReverseTest(TestCase): - def setUp(self): - self.client = Client() - - def test_reverse_js(self): - response = self.client.get(reverse('api:js_reverse')) - self.assertEqual(response.status_code, 200) - class ApiTest(TestCase): def setUp(self): self.client = Client() diff --git a/api/urls.py b/api/urls.py index 99b437c..b626ee7 100644 --- a/api/urls.py +++ b/api/urls.py @@ -1,16 +1,9 @@ from django.conf.urls import patterns, url -from django.views.decorators.cache import cache_page -from django_js_reverse.views import urls_js from . import views urlpatterns = patterns( '', - url( - r'^reverse.js$', - cache_page(3600)(urls_js), - name = 'js_reverse' - ), url( r'^duck/book/$', views.duck_book, diff --git a/booking/templates/front_template.html b/booking/templates/front_template.html index fb910de..9a3fd87 100644 --- a/booking/templates/front_template.html +++ b/booking/templates/front_template.html @@ -7,7 +7,7 @@ - + diff --git a/booking/tests.py b/booking/tests.py index 5a7a10e..b36b23a 100644 --- a/booking/tests.py +++ b/booking/tests.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- -from django.test import TestCase, Client -from django.utils import timezone from django.conf import settings from django.contrib.auth.models import User +from django.core.urlresolvers import reverse +from django.test import TestCase, Client +from django.utils import timezone import datetime @@ -296,3 +297,11 @@ class BookingTest(TestCase): def test_unbooked_duck(self): self.assertEqual(self.unbooked_duck.booked_by(), None) + +class ReverseTest(TestCase): + def setUp(self): + self.client = Client() + + def test_reverse_js(self): + response = self.client.get(reverse('js_reverse')) + self.assertEqual(response.status_code, 200) diff --git a/duckbook/urls.py b/duckbook/urls.py index d7cf217..67af7c1 100644 --- a/duckbook/urls.py +++ b/duckbook/urls.py @@ -1,6 +1,9 @@ from django.conf.urls import patterns, include, url from django.contrib import admin from django.conf import settings +from django.views.decorators.cache import cache_page + +from django_js_reverse.views import urls_js admin.autodiscover() @@ -11,6 +14,11 @@ urlpatterns = patterns( 'django.views.static.serve', {'document_root': settings.STATIC_ROOT} ), + url( + r'^reverse.js$', + cache_page(3600)(urls_js), + name = 'js_reverse' + ), url(r'^admin/', include(admin.site.urls)), url(r'^accounts/', include('accounts.urls', namespace = 'accounts')), url(r'^api/', include('api.urls', namespace = 'api')),