summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2013-01-25 14:52:22 +0100
committerAurélien Bompard <aurelien@bompard.org>2013-01-25 14:52:22 +0100
commit9e179cd7889ab9f47c41cee8ae9025ddf81aea04 (patch)
treeec89886d3c49fd41de4844b6e7f37bf4fabe0431
parent431677576603b58c42fc488f174ef0254a7a430c (diff)
downloadhyperkitty-9e179cd7889ab9f47c41cee8ae9025ddf81aea04.tar.gz
hyperkitty-9e179cd7889ab9f47c41cee8ae9025ddf81aea04.tar.xz
hyperkitty-9e179cd7889ab9f47c41cee8ae9025ddf81aea04.zip
Fixes on the login form
-rw-r--r--hyperkitty/static/css/hyperkitty.css26
-rw-r--r--hyperkitty/templates/login.html9
-rw-r--r--hyperkitty/urls.py3
-rw-r--r--hyperkitty/views/accounts.py31
4 files changed, 33 insertions, 36 deletions
diff --git a/hyperkitty/static/css/hyperkitty.css b/hyperkitty/static/css/hyperkitty.css
index f00baa1..53df5c1 100644
--- a/hyperkitty/static/css/hyperkitty.css
+++ b/hyperkitty/static/css/hyperkitty.css
@@ -72,12 +72,14 @@ ul.lists li a:hover {
/* Login form */
-.center {
- text-align: center;
-}
#loginform {
- display: inline-block;
text-align: left;
+ width: 40em;
+ margin: 0 auto;
+}
+#loginform h2 {
+ margin-bottom: 1.5em;
+ text-align: center;
}
.socialLogin {
list-style: none;
@@ -88,6 +90,22 @@ ul.lists li a:hover {
padding: 5px;
}
+/* from Bootstrap's alert class */
+.errorlist {
+ list-style-type: none;
+ margin: 0 0 20px 0;
+ padding: 8px 35px 8px 14px;
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
+ border: 1px solid #eed3d7;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ color: #b94a48;
+ background-color: #f2dede;
+}
+
+
+/* ******************* */
.right {
text-align: right;
diff --git a/hyperkitty/templates/login.html b/hyperkitty/templates/login.html
index 6c708bf..3a3bfa6 100644
--- a/hyperkitty/templates/login.html
+++ b/hyperkitty/templates/login.html
@@ -8,15 +8,14 @@
{% block content %}
-<div class="center">
<div id="loginform">
<h2>Login with username and password</h2>
-<form action="" method="post" class="login mm_clear">
+
+<form action="{{ request.path }}?next={{ next }}" method="post" class="login mm_clear">
{% csrf_token %}
{{ form.as_p }}
- <input type="hidden" name="next" value="{{ next }}" />
<div class="field">
<button class="btn btn-primary" type="submit">
{% trans "Login" %}
@@ -41,7 +40,6 @@
</ul>
</div>
-</div>
{% endblock %}
@@ -66,6 +64,9 @@
});
</script>
<!-- end browserid stuff -->
+<script type="text/javascript">
+ document.getElementById('id_username').focus();
+</script>
{% endblock additionaljs %}
{# vim: set noet: #}
diff --git a/hyperkitty/urls.py b/hyperkitty/urls.py
index 355455c..45cfaad 100644
--- a/hyperkitty/urls.py
+++ b/hyperkitty/urls.py
@@ -26,6 +26,7 @@ from django.views.generic.simple import direct_to_template
from api import EmailResource, ThreadResource, SearchResource
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+from django.contrib.auth.views import login as login_view
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
@@ -33,7 +34,7 @@ admin.autodiscover()
urlpatterns = patterns('hyperkitty.views',
# Account
- url(r'^accounts/login/$', 'accounts.user_login', name='user_login'),
+ url(r'^accounts/login/$', login_view, {'template_name': 'login.html'}, name='user_login'),
url(r'^accounts/logout/$', 'accounts.user_logout', name='user_logout'),
url(r'^accounts/profile/$', 'accounts.user_profile', name='user_profile'),
url(r'^accounts/register/$', 'accounts.user_registration', name='user_registration'),
diff --git a/hyperkitty/views/accounts.py b/hyperkitty/views/accounts.py
index f06a242..69db991 100644
--- a/hyperkitty/views/accounts.py
+++ b/hyperkitty/views/accounts.py
@@ -22,6 +22,8 @@
import re
import sys
import logging
+from urllib2 import HTTPError
+from urlparse import urlparse
from django.conf import settings
from django.contrib import messages
@@ -30,17 +32,15 @@ from django.contrib.auth.decorators import (login_required,
permission_required,
user_passes_test)
from django.contrib.auth.forms import AuthenticationForm
-from hyperkitty.models import UserProfile, Rating
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response, redirect
from django.template import Context, loader, RequestContext
from django.utils.translation import gettext as _
-from urllib2 import HTTPError
-from urlparse import urlparse
-from forms import RegistrationForm
+from hyperkitty.models import UserProfile, Rating
+from hyperkitty.views.forms import RegistrationForm
from hyperkitty.lib import get_store
@@ -51,29 +51,6 @@ def user_logout(request):
logout(request)
return redirect('user_login')
-def user_login(request, template='login.html'):
-
- user = None
- parse_r = urlparse(request.META.get('HTTP_REFERER', 'index'))
- previous = '%s%s' % (parse_r.path, parse_r.query)
-
- next_var = request.POST.get('next', request.GET.get('next', previous))
-
- if request.method == 'POST':
- form = AuthenticationForm(request.POST)
- user = authenticate(username=request.POST.get('username'),
- password=request.POST.get('password'))
-
- if user is not None:
- logger.debug(user)
- if user.is_active:
- login(request, user)
- return redirect(next_var)
-
- else:
- form = AuthenticationForm()
- return render_to_response(template, {'form': form, 'next' : next_var},
- context_instance=RequestContext(request))
@login_required
def user_profile(request, user_email=None):