Move reverse.js related code to the booking module

This commit is contained in:
Gergely Polonkai 2015-05-27 23:10:26 +02:00
parent 80096d72e4
commit 2ba17dd61e
5 changed files with 20 additions and 19 deletions

View File

@ -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()

View File

@ -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,

View File

@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'booking.css' %}">
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.11.2/themes/ui-lightness/jquery-ui.css">
<script src="{% url 'api:js_reverse' %}" type="text/javascript"></script>
<script src="{% url 'js_reverse' %}" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.min.js"></script>
</head>

View File

@ -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)

View File

@ -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')),