changeset 1115:d613d25a021e

Convert login, logout, and lost username views to V3 design.
author Brian Neal <bgneal@gmail.com>
date Tue, 12 Jul 2016 21:31:09 -0500
parents 6dd1f0065859
children 85119508e072
files accounts/urls.py accounts/views.py sg101/templates/accounts/login.html sg101/templates/accounts/logout.html sg101/templates/accounts/register_failure.html sg101/templates/accounts/username_query.html sg101/templates/accounts/username_sent.html
diffstat 7 files changed, 92 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/accounts/urls.py	Tue Jul 12 20:44:20 2016 -0500
+++ b/accounts/urls.py	Tue Jul 12 21:31:09 2016 -0500
@@ -20,11 +20,17 @@
 urlpatterns += [
     url(r'^login/$',
         auth_views.login,
-        kwargs={'template_name': 'accounts/login.html'},
+        kwargs={
+            'template_name': 'accounts/login.html',
+            'extra_context': {'V3_DESIGN': True},
+        },
         name='accounts-login'),
     url(r'^logout/$',
         auth_views.logout,
-        kwargs={'template_name': 'accounts/logout.html'},
+        kwargs={
+            'template_name': 'accounts/logout.html',
+            'extra_context': {'V3_DESIGN': True},
+        },
         name='accounts-logout'),
     url(r'^password/$',
         auth_views.password_change,
@@ -56,6 +62,6 @@
         accounts.views.username_query,
         name='accounts-username_query'),
     url(r'^username/sent/$',
-        TemplateView.as_view(template_name='accounts/username_sent.html'),
+        accounts.views.UsernameSentView.as_view(),
         name='accounts-username_sent'),
 ]
--- a/accounts/views.py	Tue Jul 12 20:44:20 2016 -0500
+++ b/accounts/views.py	Tue Jul 12 21:31:09 2016 -0500
@@ -8,6 +8,7 @@
 from django.http import HttpResponse
 from django.shortcuts import render, redirect
 from django.conf import settings
+from django.views.generic import TemplateView
 
 from accounts.models import PendingUser
 from accounts.forms import RegisterForm
@@ -143,4 +144,16 @@
     else:
         form = ForgotUsernameForm()
 
-    return render(request, 'accounts/username_query.html', {'form': form})
+    return render(request, 'accounts/username_query.html', {
+        'form': form,
+        'V3_DESIGN': True,
+    })
+
+
+class UsernameSentView(TemplateView):
+    template_name = 'accounts/username_sent.html'
+
+    def get_context_data(self, **kwargs):
+        context = super(UsernameSentView, self).get_context_data(**kwargs)
+        context['V3_DESIGN'] = True
+        return context
--- a/sg101/templates/accounts/login.html	Tue Jul 12 20:44:20 2016 -0500
+++ b/sg101/templates/accounts/login.html	Tue Jul 12 21:31:09 2016 -0500
@@ -1,21 +1,46 @@
-{% extends 'base.html' %}
+{% extends 'v3/base.html' %}
 {% block title %}Login{% endblock %}
 {% block content %}
 <h2>Login</h2>
 
 <form method="post" action=".">{% csrf_token %}
-<table>
-{{ form.as_table }}
-<tr><td>&nbsp;</td><td><input type="submit" value="Login" /></td></tr>
-</table>
-<input type="hidden" name="next" value="{{ next }}" />
+   {{ form.non_field_errors }}
+   {{ form.username.errors }}
+   <div class="row">
+      <div class="medium-6 columns">
+         <label for="{{ form.username.id_for_label }}">{{ form.username.label }}
+            {{ form.username }}
+         </label>
+      </div>
+   </div>
+   {{ form.password.errors }}
+   <div class="row">
+      <div class="medium-6 columns">
+         <label for="{{ form.password.id_for_label }}">{{ form.password.label }}
+            {{ form.password }}
+         </label>
+      </div>
+   </div>
+   <input type="hidden" name="next" value="{{ next }}" />
+   <input type="submit" value="Login" class="primary button" />
 </form>
 
-<ul>
-<li>Forgot your username? You can recover it <a href="{% url 'accounts-username_query' %}">here</a>.</li>
-<li>Forgot your password? You can reset it <a href="{% url 'accounts-password_reset' %}">here</a>.</li>
-<li>Don't have an account? Why don't you <a href="{% url 'accounts-register' %}">register</a>?</li>
-<li>Having problems? Please <a href="{% url 'contact-form' %}">contact us</a>.</li>
-</ul>
+<div class="row">
+   <div class="medium-6 columns">
+      <div class="callout">
+         <ul>
+            <li>Forgot your username? You can recover it
+               <a href="{% url 'accounts-username_query' %}">here</a>.</li>
+            <li>Forgot your password? You can reset it
+               <a href="{% url 'accounts-password_reset' %}">here</a>.</li>
+            <li>Don't have an account? Why don't you
+               <a href="{% url 'accounts-register' %}">register</a>?</li>
+            <li>Having problems? Please
+               <a href="{% url 'contact-form' %}?subject=Login%20Problems">contact us</a>.
+               </li>
+         </ul>
+      </div>
+   </div>
+</div>
 
 {% endblock %}
--- a/sg101/templates/accounts/logout.html	Tue Jul 12 20:44:20 2016 -0500
+++ b/sg101/templates/accounts/logout.html	Tue Jul 12 21:31:09 2016 -0500
@@ -1,7 +1,14 @@
-{% extends 'base.html' %}
+{% extends 'v3/base.html' %}
 {% block title %}Logged Out{% endblock %}
 {% block content %}
 <h2>Logged Out</h2>
-<p>You are now logged out of SurfGuitar101.com. Thanks for spending some quality time with us today. Tell all your
-friends about us and we hope we see you soon!</p>
+<div class="success callout">
+   You are now logged out of SurfGuitar101.com. Thanks for spending some
+   quality time with us today. Tell all your friends about us and we hope
+   we see you soon!
+</div>
+<p>
+   <a href="{% url 'accounts-login' %}"
+      class="primary button">I need more surf music, I want to login again.</a>
+</p>
 {% endblock %}
--- a/sg101/templates/accounts/register_failure.html	Tue Jul 12 20:44:20 2016 -0500
+++ b/sg101/templates/accounts/register_failure.html	Tue Jul 12 21:31:09 2016 -0500
@@ -3,7 +3,7 @@
 {% block content %}
 <h2>Registration Error</h2>
 <div class="alert callout">
-   We're sorry, we don't have any registration information available for the 
+   We're sorry, we don't have any registration information available for the
    user <strong>{{ username }}</strong>. Registration information is only good
    for 24 hours, and it may have expired. If you think this may have happened, please
    <a href="{% url 'accounts.views.register' %}">register again</a>.
--- a/sg101/templates/accounts/username_query.html	Tue Jul 12 20:44:20 2016 -0500
+++ b/sg101/templates/accounts/username_query.html	Tue Jul 12 21:31:09 2016 -0500
@@ -1,4 +1,4 @@
-{% extends 'base.html' %}
+{% extends 'v3/base.html' %}
 {% block title %}Forgotten Username{% endblock %}
 {% block content %}
 <h2>Forgotten Username</h2>
@@ -7,7 +7,19 @@
 register with the site below and we'll send your username to you.
 </p>
 <form action="." method="post">{% csrf_token %}
-   {{ form.as_p }}
-   <p><input type="submit" value="Submit" /></p>
+   {{ form.non_field_errors }}
+   {{ form.email.errors }}
+   <div class="row">
+      <div class="medium-6 columns">
+         <label for="{{ form.email.id_for_label }}">{{ form.email.label }}
+            {{ form.email }}
+         </label>
+      </div>
+   </div>
+   <input type="submit" value="Submit" class="primary button" />
 </form>
+<p>
+   Can't remember what email address you used, or maybe it is no longer valid?
+   Please <a href="{% url 'contact-form' %}?subject=Forgotten%20Username">contact us</a>.
+</p>
 {% endblock %}
--- a/sg101/templates/accounts/username_sent.html	Tue Jul 12 20:44:20 2016 -0500
+++ b/sg101/templates/accounts/username_sent.html	Tue Jul 12 21:31:09 2016 -0500
@@ -1,9 +1,12 @@
-{% extends 'base.html' %}
+{% extends 'v3/base.html' %}
 {% block title %}Username Sent{% endblock %}
 {% block content %}
 <h2>Username Sent</h2>
+<div class="success callout">
+   Thank you. We have emailed the username to the email address you
+   provided. If the message doesn't arrive, please check your spam folders.
+</div>
 <p>
-Thank you. We have emailed the associated username to the email address you
-provided. 
+   <a href="{% url 'accounts-login' %}" class="primary button">Login</a>
 </p>
 {% endblock %}