Browse Source

Add a login form

Jocelyn Delande 9 years ago
parent
commit
a2e0d7ae95

+ 2 - 0
transparency/settings.py

@@ -102,6 +102,8 @@ USE_TZ = True
 
 STATIC_URL = '/static/'
 
+LOGIN_REDIRECT_URL="list-documents"
+
 ## Non-technic Specifics
 
 

+ 1 - 0
transparency/templates/base.html

@@ -18,6 +18,7 @@
   <link rel="stylesheet" type="text/css" href="{% static "costs/3rd/semantic/components/button.css" %}" >
   <link rel="stylesheet" type="text/css" href="{% static "costs/3rd/semantic/components/container.css" %}" >
   <link rel="stylesheet" type="text/css" href="{% static "costs/3rd/semantic/components/divider.css" %}" >
+  <link rel="stylesheet" type="text/css" href="{% static "costs/3rd/semantic/components/form.css" %}" >
   <link rel="stylesheet" type="text/css" href="{% static "costs/3rd/semantic/components/grid.css" %}" >
   <link rel="stylesheet" type="text/css" href="{% static "costs/3rd/semantic/components/header.css" %}" >
   <link rel="stylesheet" type="text/css" href="{% static "costs/3rd/semantic/components/icon.css" %}" >

+ 6 - 0
transparency/templates/registration/logged_out.html

@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+{% block content %}
+<p class="ui message">
+  Vous avez été deconnecté ; vous pouvez <a href="{% url 'login' %}">vous reconnecter</a>.
+</p>
+{% endblock %}

+ 19 - 0
transparency/templates/registration/login.html

@@ -0,0 +1,19 @@
+{% extends "base.html" %}
+{% block content %}
+{% if form.errors %}
+<p class="ui message">Mauvais utilisateur / mot de passe, essaye encore..</p>
+{% endif %}
+<form method="post" class="ui form" action="{% url 'django.contrib.auth.views.login' %}">
+{% csrf_token %}
+  <div class="field">
+    <label>{{ form.username.label_tag }}</label>
+    {{ form.username }}
+  </div>
+  <div class="field">
+    <label>{{ form.password.label_tag }}</label>
+    {{ form.password }}
+  </div>
+<input class="ui button" type="submit" value="Se connnecter" />
+<input type="hidden" name="next" value="{{ next }}" />
+</form>
+{% endblock %}

+ 4 - 2
transparency/urls.py

@@ -14,7 +14,6 @@ Including another URLconf
     2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
 """
 from django.conf.urls import include, url
-from django.contrib import admin
 from transparency.admin import admin_site
 import costs.urls
 import publicsite.urls
@@ -23,8 +22,11 @@ from django.views.generic import RedirectView
 
 urlpatterns = [
     url(r'^admin/', include(admin_site.urls)),
+    url(r'^accounts/login/$', 'django.contrib.auth.views.login', name='login'),
+    url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', name='logout'),
+#    url(r'^admin/', include(admin_site.urls)),
     url(r'^costs/', include(costs.urls)),
-    url(r'public/', include(publicsite.urls)),
+    url(r'^public/', include(publicsite.urls)),
     url(r'^$', RedirectView.as_view(
         pattern_name='public-index', permanent=False)),
 ]