Skip to content

Commit

Permalink
hooked up login/logout
Browse files Browse the repository at this point in the history
  • Loading branch information
moltob committed Dec 15, 2016
1 parent cda56c5 commit 3616d35
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ db.sqlite3
__pycache__/
node_modules/
bower_components/
*.mo
*.mo
.cache/
3 changes: 0 additions & 3 deletions bizwiz/account/admin.py

This file was deleted.

21 changes: 21 additions & 0 deletions bizwiz/account/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Crispy helpers for athentication forms."""
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit, Row, Div
from django.utils.translation import ugettext as _

login_helper = FormHelper()
login_helper.layout = Layout(
Row(
Div('username', css_class='col-lg-offset-4 col-lg-4')
),
Row(
Div('password', css_class='col-lg-offset-4 col-lg-4')
),
Row(
Div(
# Translators: This is the button text.
Submit('submit', _('Login'), css_class='btn-block'),
css_class='col-lg-offset-4 col-lg-4'
)
),
)
3 changes: 0 additions & 3 deletions bizwiz/account/models.py

This file was deleted.

15 changes: 15 additions & 0 deletions bizwiz/account/templates/account/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "common/base.html" %}

{% load i18n %}
{% load crispy_forms_tags %}

{% block content %}

{% crispy form helper %}

{% comment %}
{# Assumes you setup the password_reset view in your URLconf #}
<p><a href="{% url 'accounts:password_reset' %}">Lost password?</a></p>
{% endcomment %}

{% endblock %}
3 changes: 0 additions & 3 deletions bizwiz/account/tests.py

This file was deleted.

12 changes: 12 additions & 0 deletions bizwiz/account/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.conf.urls import url, include
from django.contrib.auth import views as auth_views

from bizwiz.account.forms import login_helper

urlpatterns = [
url(r'^login/$', auth_views.login, {
'template_name': 'account/login.html',
'extra_context': {'helper': login_helper},
}, name='login'),
url(r'^logout/$', auth_views.logout, name='logout'),
]
3 changes: 0 additions & 3 deletions bizwiz/account/views.py

This file was deleted.

4 changes: 2 additions & 2 deletions bizwiz/common/templates/common/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<div class="row">
<div class="col-lg-12">
<p>
<a href="{% comment %}{% url 'accounts:logout' %}{% endcomment %}#"
<a href="{% url 'accounts:logout' %}#"
class="btn btn-primary btn-block">{% trans 'Logout' %}</a>
</p>
</div>
Expand All @@ -65,7 +65,7 @@
</li>
{% else %}
<li class="{% if 'login' in request.path %}active{% endif %}">
<a href="{% comment %}{% url 'accounts:login' %}{% endcomment %}#">
<a href="{% url 'accounts:login' %}">
<span class="glyphicon glyphicon-user"></span> 
<strong>{% trans 'Login' %}</strong>
</a>
Expand Down
3 changes: 3 additions & 0 deletions bwsite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@
messages.DEBUG: 'info',
messages.ERROR: 'danger',
}

LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
1 change: 1 addition & 0 deletions bwsite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from django.contrib import admin

urlpatterns = [
url(r'^accounts/', include('bizwiz.account.urls', namespace='accounts')),
url(r'^', include('bizwiz.common.urls', namespace='common')),
url(r'^admin/', admin.site.urls),
]

0 comments on commit 3616d35

Please sign in to comment.