fmartingr
/
shelfzilla
Archived
1
0
Fork 0

+ Improved login form layout

+ Login will redirect to / if the user is already authenticated
This commit is contained in:
Felipe Martin 2014-03-26 16:33:57 +01:00
parent 5748c7dc3a
commit d6796cb108
6 changed files with 47 additions and 9 deletions

View File

@ -44,9 +44,9 @@ module.exports = (grunt) ->
dest: "shelfzilla/themes/bootflat/static/js/site.js"
css:
src: [
"shelfzilla/themes/bootflat/static/css/app.css",
"static_components/css/bootstrap.min.css",
"static_components/css/bootflat.min.css",
"shelfzilla/themes/bootflat/static/css/app.css",
]
dest: "shelfzilla/themes/bootflat/static/css/style.css"
@ -78,10 +78,10 @@ module.exports = (grunt) ->
tasks: []
less:
files: ['shelfzilla/themes/bootflat/static/less/*.less']
tasks: ['less']
tasks: ['less', 'concat:css']
coffee:
files: ['shelfzilla/themes/bootflat/static/coffee/*.coffee']
tasks: ['coffee', 'concat', 'clean:development']
tasks: ['coffee', 'concat:js', 'clean:development']
# Modules

View File

@ -14,6 +14,9 @@ class LoginView(View):
template = 'users/login.html'
def get(self, request):
if request.user.is_authenticated():
return HttpResponseRedirect('/')
context = {
'login_form': LoginForm()
}
@ -22,6 +25,9 @@ class LoginView(View):
return render_to_response(self.template, context_instance=ctx)
def post(self, request):
if request.user.is_authenticated():
return HttpResponseRedirect('/')
login_form = LoginForm(request.POST)
if login_form.is_valid():

View File

@ -0,0 +1 @@
@import "layout.less";

View File

@ -0,0 +1,14 @@
/* Login panel */
.panel-login {
@height: 180px;
@width: 300px;
left: 50%;
margin: 0 auto;
margin-left: @width/2*-1px;
margin-top: @height/2*-1px;
position: absolute;
text-align: center;
top: 50%;
width: 300px;
}

View File

@ -1,9 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>{% block page_title %}{% endblock %}</title>
<link rel="stylesheet" href="/static/css/style.css" />
{% block extra_css %}{% endblock %}
<title>{% block page_title %}Shelfzilla{% endblock %}</title>
</head>
<body>

View File

@ -1,9 +1,26 @@
{% extends "_layout.html" %}
{% load i18n %}
{% block page_title %}{{ block.super }} | Login{% endblock %}
{% block main_content %}
<form method="post" class="form">
{% csrf_token %}
{{ login_form.as_p }}
<button class="btn btn-primary" type="submit">Login</button>
</form>
<div class="panel panel-primary panel-login">
<div class="panel-heading">
<h3 class="panel-title">{% trans "Access the site" %}</h3>
</div>
<div class="panel-body">
<form method="post" class="form form-horizontal">
{% csrf_token %}
{% for field in login_form %}
<div class="form-group">
<label class="col-sm-2 control-label">{{ field.label }}</label>
<div class="col-sm-10">
{{ field }}
</div>
</div>
{% endfor %}
<button class="btn btn-primary" type="submit">{% trans "Login" %}</button>
</form>
</div>
</div>
{% endblock %}