+ Improved login form layout
+ Login will redirect to / if the user is already authenticated
This commit is contained in:
parent
5748c7dc3a
commit
d6796cb108
|
@ -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
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
@import "layout.less";
|
|
@ -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;
|
||||
}
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Reference in New Issue