Commit c562defd authored by Administrator's avatar Administrator

Merge branch 'samuel'

Integration login page (thx Samuel)
parents 88ad0861 d22c90d5
...@@ -16,6 +16,8 @@ urlpatterns = patterns('', ...@@ -16,6 +16,8 @@ urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^login/', include(admin.site.urls)), url(r'^login/', include(admin.site.urls)),
url(r'^grappelli/', include('grappelli.urls')), url(r'^grappelli/', include('grappelli.urls')),
url(r'^auth/$', views.login_user),
# User Home view # User Home view
url(r'^$', views.home), url(r'^$', views.home),
......
...@@ -27,6 +27,31 @@ from parsing.FileParsers import * ...@@ -27,6 +27,31 @@ from parsing.FileParsers import *
# SOME FUNCTIONS # SOME FUNCTIONS
from django.http import *
from django.shortcuts import render_to_response,redirect
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate, login, logout
def login_user(request):
logout(request)
username = password = ''
print(request)
if request.POST:
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return HttpResponseRedirect('/projects/')
return render_to_response('authentication.html', context_instance=RequestContext(request))
def query_to_dicts(query_string, *query_args): def query_to_dicts(query_string, *query_args):
"""Run a simple query and produce a generator """Run a simple query and produce a generator
that returns the results as a bunch of dictionaries that returns the results as a bunch of dictionaries
......
<html>
<body class="grp-login">
<head>
<link href="/static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" type="text/css" media="screen" />
<link href="/static/grappelli/stylesheets/screen.css" rel="stylesheet" type="text/css" media="screen" />
<link href="/static/grappelli/stylesheets/mueller/grid/output.css" rel="stylesheet" type="text/css" media="screen" />
<script src="/static/grappelli/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
<!-- Grappelli Minified -->
<script src="/static/grappelli/js/grappelli.min.js" type="text/javascript"></script>
</head>
<div id="grp-container">
<!-- HEADER -->
<header id="grp-header" class="">
<!-- NAVIGATION -->
<div id="grp-navigation">
<h1 id="grp-admin-title">Gargantext</h1>
<!-- Nav-Global -->
</div>
</header>
<!-- CONTENT -->
<article id="grp-content" class="">
<!-- CONTENT TITLE -->
<header id="grp-content-title">
<h1>Log in</h1>
</header>
<!-- CONTENT-CONTAINER -->
<div id="grp-content-container">
<div class="g-d-c g-d-10 g-centered">
<form action="/auth/" method="post"><input type='hidden' name='csrfmiddlewaretoken' value='Yopwc8YatA3C68kSevZX9upoXdIcZzPn' />
<fieldset class="grp-module grp-module-login">
<h1>
<span class="grp-admin-title">Gargantext</span>
<span class="grp-current-page">Login</span>
</h1>
<div class="grp-module">
{% block main %}
<div id="login">
<form class="form-horizontal" name="LoginForm" action="/auth/" method="post">
{% csrf_token %}
{% if next %}
<input type="hidden" name="next" value="{{ next }}" />
{% endif %}
<div class="grp-row">
<label class="control-label" for="username">Username</label>
<input type="text" id="username" name="username" placeholder="Username">
</div>
<div class="grp-row grp-connected">
<label class="control-label" for="password">Password</label>
<input type="password" name="password" id="password" placeholder="Password">
</div>
</div>
</fieldset>
<div class="grp-module grp-submit-row">
<ul>
<li><input type="submit" class="grp-button grp-default" value="Log in" /></li>
</ul>
</div>
</form>
</div>
{% endblock %}
</div>
</div>
</article>
</div>
<script type="text/javascript">
(function($) {
$(window).load(function(){ $('#id_username').focus(); });
})(grp.jQuery);
</script>
</body>
</html>
\ No newline at end of file
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a tabindex="-1" href="/admin/logout/">Login</a></li> <li><a tabindex="-1" href="/auth/">Login</a></li>
<li><a tabindex="-1" href="#">Profile</a></li> <li><a tabindex="-1" href="#">Profile</a></li>
<li class="divider"></li> <li class="divider"></li>
<li><a tabindex="-1" href="#">Help</a></li> <li><a tabindex="-1" href="#">Help</a></li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment