Code refactor

This commit is contained in:
Gabriel Augendre 2016-06-04 12:44:21 +02:00
parent 15da1c8b51
commit d7e3f0132f
No known key found for this signature in database
GPG key ID: D2B6A5B41FC438B1
3 changed files with 28 additions and 27 deletions

View file

@ -2,7 +2,7 @@
{% load crispy_forms_filters %}
{% block content %}
<h1>{% block title %}Change password{% endblock %}</h1>
<h1>{% block title %}{{ title }}{% endblock %}</h1>
<div id="login">
<form method="post">
@ -11,7 +11,7 @@
{% endif %}
{% csrf_token %}
{{ form|crispy }}
<button type="submit" class="btn btn-primary">Change password</button>
<button type="submit" class="btn btn-primary">{{ action }}</button>
</form>
</div>
{% endblock %}

View file

@ -1,18 +0,0 @@
{% extends 'base.html' %}
{% load staticfiles %}
{% load crispy_forms_filters %}
{% block content %}
<h1>{% block title %}Login{% endblock %}</h1>
<div id="login">
<form name="LoginForm" action="{% url 'auth_login' %}" method="post">
{% if next %}
<input type="hidden" name="next" value="{{ next }}"/>
{% endif %}
{% csrf_token %}
{{ form|crispy }}
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>
{% endblock %}

View file

@ -1,18 +1,37 @@
from authentication.views import password_change_done
from django.conf.urls import url
from django.contrib.auth.views import login, logout, password_change
from authentication.views import password_change_done
urlpatterns = [
url(r'^login/$',
url(
r'^login/$',
login,
{'template_name': 'authentication/login.html'},
{
'template_name': 'authentication/auth_form.html',
'extra_context': {
'title': 'Login',
'action': 'Login'
}
},
name='auth_login'
),
url(r'^logout/$',
),
url(
r'^logout/$',
logout,
{'next_page': 'home'},
name='auth_logout'
),
url(r'^password/change/$', password_change, {'template_name': 'authentication/change_password.html'}, name='password_change'),
),
url(
r'^password/change/$',
password_change,
{
'template_name': 'authentication/auth_form.html',
'extra_context': {
'title': 'Change password',
'action': 'Change password'
}
},
name='password_change'
),
url(r'^password/change/done/$', password_change_done, name='password_change_done'),
]