diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | accounts/__init__.py | 0 | ||||
-rw-r--r-- | accounts/models.py | 3 | ||||
-rw-r--r-- | accounts/tests.py | 16 | ||||
-rw-r--r-- | accounts/urls.py | 6 | ||||
-rw-r--r-- | accounts/views.py | 5 | ||||
-rw-r--r-- | codemash/settings.py | 14 | ||||
-rw-r--r-- | codemash/urls.py | 3 | ||||
-rw-r--r-- | templates/accounts/profile.html | 9 | ||||
-rw-r--r-- | templates/index.html | 5 | ||||
-rw-r--r-- | templates/registration/logged_out.html | 6 | ||||
-rw-r--r-- | templates/registration/login.html | 27 |
12 files changed, 86 insertions, 9 deletions
@@ -1 +1,2 @@ | |||
1 | __pycache__/ | 1 | __pycache__/ |
2 | /database.db | ||
diff --git a/accounts/__init__.py b/accounts/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/accounts/__init__.py | |||
diff --git a/accounts/models.py b/accounts/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/accounts/models.py | |||
@@ -0,0 +1,3 @@ | |||
1 | from django.db import models | ||
2 | |||
3 | # Create your models here. | ||
diff --git a/accounts/tests.py b/accounts/tests.py new file mode 100644 index 0000000..501deb7 --- /dev/null +++ b/accounts/tests.py | |||
@@ -0,0 +1,16 @@ | |||
1 | """ | ||
2 | This file demonstrates writing tests using the unittest module. These will pass | ||
3 | when you run "manage.py test". | ||
4 | |||
5 | Replace this with more appropriate tests for your application. | ||
6 | """ | ||
7 | |||
8 | from django.test import TestCase | ||
9 | |||
10 | |||
11 | class SimpleTest(TestCase): | ||
12 | def test_basic_addition(self): | ||
13 | """ | ||
14 | Tests that 1 + 1 always equals 2. | ||
15 | """ | ||
16 | self.assertEqual(1 + 1, 2) | ||
diff --git a/accounts/urls.py b/accounts/urls.py new file mode 100644 index 0000000..ead707a --- /dev/null +++ b/accounts/urls.py | |||
@@ -0,0 +1,6 @@ | |||
1 | from django.conf.urls import patterns, include, url | ||
2 | |||
3 | |||
4 | urlpatterns = patterns('accounts.views', | ||
5 | url(r'^profile/$', 'profile', name='profile'), | ||
6 | ) | ||
diff --git a/accounts/views.py b/accounts/views.py new file mode 100644 index 0000000..2616923 --- /dev/null +++ b/accounts/views.py | |||
@@ -0,0 +1,5 @@ | |||
1 | from django.shortcuts import render | ||
2 | |||
3 | |||
4 | def profile(request): | ||
5 | return render(request, "accounts/profile.html") | ||
diff --git a/codemash/settings.py b/codemash/settings.py index 23b1b93..0285da9 100644 --- a/codemash/settings.py +++ b/codemash/settings.py | |||
@@ -11,20 +11,15 @@ ADMINS = ( | |||
11 | 11 | ||
12 | MANAGERS = ADMINS | 12 | MANAGERS = ADMINS |
13 | 13 | ||
14 | PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) | ||
15 | |||
14 | DATABASES = { | 16 | DATABASES = { |
15 | 'default': { | 17 | 'default': { |
16 | 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. | 18 | 'ENGINE': 'django.db.backends.sqlite3', |
17 | 'NAME': '', # Or path to database file if using sqlite3. | 19 | 'NAME': os.path.join(PROJECT_ROOT, "database.db"), |
18 | # The following settings are not used with sqlite3: | ||
19 | 'USER': '', | ||
20 | 'PASSWORD': '', | ||
21 | 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. | ||
22 | 'PORT': '', # Set to empty string for default. | ||
23 | } | 20 | } |
24 | } | 21 | } |
25 | 22 | ||
26 | PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) | ||
27 | |||
28 | # Local time zone for this installation. Choices can be found here: | 23 | # Local time zone for this installation. Choices can be found here: |
29 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | 24 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name |
30 | # although not all choices may be available on all operating systems. | 25 | # although not all choices may be available on all operating systems. |
@@ -133,6 +128,7 @@ INSTALLED_APPS = ( | |||
133 | # 'django.contrib.admindocs', | 128 | # 'django.contrib.admindocs', |
134 | 129 | ||
135 | 'contact', | 130 | 'contact', |
131 | 'accounts', | ||
136 | ) | 132 | ) |
137 | 133 | ||
138 | # A sample logging configuration. The only tangible logging | 134 | # A sample logging configuration. The only tangible logging |
diff --git a/codemash/urls.py b/codemash/urls.py index 0431c65..567499c 100644 --- a/codemash/urls.py +++ b/codemash/urls.py | |||
@@ -6,6 +6,9 @@ from django.conf.urls import patterns, include, url | |||
6 | 6 | ||
7 | urlpatterns = patterns('', | 7 | urlpatterns = patterns('', |
8 | (r'^contact/', include('contact.urls', namespace='contact')), | 8 | (r'^contact/', include('contact.urls', namespace='contact')), |
9 | (r'^accounts/', include('django.contrib.auth.urls', namespace='auth')), | ||
10 | (r'^accounts/', include('accounts.urls', namespace='account')), | ||
11 | |||
9 | url(r'^$', 'pages.views.home', name='home'), | 12 | url(r'^$', 'pages.views.home', name='home'), |
10 | 13 | ||
11 | # Uncomment the admin/doc line below to enable admin documentation: | 14 | # Uncomment the admin/doc line below to enable admin documentation: |
diff --git a/templates/accounts/profile.html b/templates/accounts/profile.html new file mode 100644 index 0000000..aa6f3ad --- /dev/null +++ b/templates/accounts/profile.html | |||
@@ -0,0 +1,9 @@ | |||
1 | {% extends "base.html" %} | ||
2 | |||
3 | {% block content %} | ||
4 | <h1>Your Account</h1> | ||
5 | <p>Hello <b>{{ user.email }}</b></p> | ||
6 | <ul> | ||
7 | <li><a href="{% url 'auth:logout' %}">Logout</a></li> | ||
8 | </ul> | ||
9 | {% endblock %} | ||
diff --git a/templates/index.html b/templates/index.html index ff76c3e..1e497a5 100644 --- a/templates/index.html +++ b/templates/index.html | |||
@@ -6,6 +6,11 @@ | |||
6 | <h1>Hello Codemash</h1> | 6 | <h1>Hello Codemash</h1> |
7 | <ul> | 7 | <ul> |
8 | <li><a href="{% url 'contact:form' %}">Contact Us</a></li> | 8 | <li><a href="{% url 'contact:form' %}">Contact Us</a></li> |
9 | {% if user.is_authenticated %} | ||
10 | <li><a href="{% url 'auth:logout' %}">Logout ({{ user.username }})</a></li> | ||
11 | {% else %} | ||
12 | <li><a href="{% url 'auth:login' %}">Login</a></li> | ||
13 | {% endif %} | ||
9 | </ul> | 14 | </ul> |
10 | <p>You've just created your first Django page. Pretty cool, eh?</p> | 15 | <p>You've just created your first Django page. Pretty cool, eh?</p> |
11 | {% endblock %} | 16 | {% endblock %} |
diff --git a/templates/registration/logged_out.html b/templates/registration/logged_out.html new file mode 100644 index 0000000..b6908d4 --- /dev/null +++ b/templates/registration/logged_out.html | |||
@@ -0,0 +1,6 @@ | |||
1 | {% extends "base.html" %} | ||
2 | |||
3 | {% block content %} | ||
4 | <h1>You are logged out</h1> | ||
5 | <p>You can go <a href="{% url 'home' %}">home</a>.</p> | ||
6 | {% endblock %} | ||
diff --git a/templates/registration/login.html b/templates/registration/login.html new file mode 100644 index 0000000..37893a9 --- /dev/null +++ b/templates/registration/login.html | |||
@@ -0,0 +1,27 @@ | |||
1 | {% extends "base.html" %} | ||
2 | |||
3 | {% block content %} | ||
4 | |||
5 | {% if form.errors %} | ||
6 | <p>Your username and password didn't match. Please try again.</p> | ||
7 | {% endif %} | ||
8 | |||
9 | <h1>Login</h1> | ||
10 | <form method="post" action="{% url 'auth:login' %}"> | ||
11 | {% csrf_token %} | ||
12 | <table> | ||
13 | <tr> | ||
14 | <td>{{ form.username.label_tag }}</td> | ||
15 | <td>{{ form.username }}</td> | ||
16 | </tr> | ||
17 | <tr> | ||
18 | <td>{{ form.password.label_tag }}</td> | ||
19 | <td>{{ form.password }}</td> | ||
20 | </tr> | ||
21 | </table> | ||
22 | |||
23 | <input type="submit" value="login" /> | ||
24 | <input type="hidden" name="next" value="{{ next }}" /> | ||
25 | </form> | ||
26 | |||
27 | {% endblock %} | ||