diff --git a/accounts/__init__.py b/accounts/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/accounts/templates/accounts/login.html b/accounts/templates/accounts/login.html
new file mode 100644
index 0000000..b487995
--- /dev/null
+++ b/accounts/templates/accounts/login.html
@@ -0,0 +1,17 @@
+{% extends 'front_template.html' %}
+
+{% block body %}
+
+{% if form.errors %}
+
Username/password mismatch. Please try again!
+{% endif %}
+
+
+{% endblock %}
diff --git a/accounts/tests.py b/accounts/tests.py
index ca55c41..cde47a9 100644
--- a/accounts/tests.py
+++ b/accounts/tests.py
@@ -7,6 +7,29 @@ class FrontTest(TestCase):
def setUp(self):
self.client = Client()
+ self.admin = User.objects.create_user(
+ username = 'admin',
+ password = 'password')
+ self.admin.save()
+
+ def test_login_page(self):
+ response = self.client.get('/accounts/login')
+ self.assertEqual(response.status_code, 200)
+
+ def test_login(self):
+ response = self.client.post('/accounts/login', {
+ 'next': '/',
+ 'username': 'admin',
+ 'password': 'password'})
+
+ self.assertRedirects(response, '/')
+
+ def test_logout(self):
+ self.client.login(username = 'admin', password = 'aeou')
+
+ response = self.client.get('/accounts/logout')
+ self.assertRedirects(response, '/')
+
def test_registration_page(self):
response = self.client.get('/accounts/register')
self.assertEqual(response.status_code, 200)
diff --git a/accounts/urls.py b/accounts/urls.py
index 6323ee6..75154f8 100644
--- a/accounts/urls.py
+++ b/accounts/urls.py
@@ -9,4 +9,16 @@ urlpatterns = patterns(
RegistrationFormView.as_view(),
name = 'register'
),
+ url(
+ r'^login$',
+ 'django.contrib.auth.views.login',
+ {'template_name': 'accounts/login.html'},
+ name = 'login'
+ ),
+ url(
+ r'^logout$',
+ 'django.contrib.auth.views.logout',
+ {'next_page': 'booking:list'},
+ name = 'logout'
+ ),
)
diff --git a/accounts/views.py b/accounts/views.py
index 9a97f36..76ccea6 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -18,6 +18,6 @@ class RegistrationFormView(generic.View):
if form.is_valid():
form.save()
- return HttpResponseRedirect(reverse('booking:index'))
+ return HttpResponseRedirect(reverse('booking:list'))
return render(request, self.template_name, {'form': form})
diff --git a/booking/templates/front_template.html b/booking/templates/front_template.html
index 7a32326..8617def 100644
--- a/booking/templates/front_template.html
+++ b/booking/templates/front_template.html
@@ -5,9 +5,16 @@
Rubber Duck Booking Tool
+{% if user.is_authenticated %}
+{% else %}
+
+{% endif %}
Home
Terms and Conditions
Vocabulary
diff --git a/duckbook/urls.py b/duckbook/urls.py
index d5838b9..39233d1 100644
--- a/duckbook/urls.py
+++ b/duckbook/urls.py
@@ -1,5 +1,4 @@
from django.conf.urls import patterns, include, url
-from django.views.generic import TemplateView
urlpatterns = patterns(
'',