Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Adding a login form and REGISTER_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Craciunoiu committed May 26, 2010
1 parent 66c2c5c commit 26e2d76
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 14 deletions.
11 changes: 3 additions & 8 deletions apps/sumo/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
from django.conf import settings


def title(request):
"""Adds site title to the context."""
return {'SITE_TITLE': settings.SITE_TITLE}


def auth(request):
"""Adds auth-related urls to the context."""
return {'LOGIN_URL': settings.LOGIN_URL, 'LOGOUT_URL': settings.LOGOUT_URL}
def global_settings(request):
"""Adds settings to the context."""
return {'settings': settings}
2 changes: 1 addition & 1 deletion apps/sumo/templates/handlers/403.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h2>{{ title }}</h2>
<p>{{ _('You do not have permission to access this page.') }}</p>

{% if not user.is_authenticated() %}
<p><a href="{{ LOGIN_URL }}">{{ _('Click here to log in') }}</a></p>
{% include "layout/login.html" %}
{% endif %}

{% endblock %}
22 changes: 22 additions & 0 deletions media/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,28 @@ h2 {
}
/* end orange buttons */

/* Login form */
#login-form {
margin: 1em 0;
}

#login-form h3 {
color: #afaba3;
font-size: 150%;
margin-bottom: .5em;
}

#login-form label {
color: #807970;
display: block;
margin: .3em 0;
}

#login-form input {
margin: .3em 0;
}
/* End login form */

/* Paginators */
ol.pagination {
margin: 0 auto 1em;
Expand Down
5 changes: 3 additions & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'sumo.context_processors.title',
'sumo.context_processors.auth',

'sumo.context_processors.global_settings',
)

MIDDLEWARE_CLASSES = (
Expand Down Expand Up @@ -293,3 +293,4 @@ def JINJA_CONFIG():
# TODO: Once we can log in through Kitsune, change this.
LOGIN_URL = '/tiki-login.php'
LOGOUT_URL = '/tiki-logout.php'
REGISTER_URL = '/tiki-register.php'
2 changes: 1 addition & 1 deletion templates/layout/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html lang="{{ request.locale }}" dir="{{ dir }}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{ title }} | {{ SITE_TITLE }}</title>
<title>{{ title }} | {{ settings.SITE_TITLE }}</title>

<link rel="shortcut icon" type="image/x-icon" href="{{ MEDIA_URL }}img/favicon.ico"/>
<link rel="search" type="application/opensearchdescription+xml" title="Firefox Support" href="/search.xml"/>
Expand Down
33 changes: 33 additions & 0 deletions templates/layout/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% block login %}

<div id="login-form">
<h3>{{ _('Log in') }}</h3>

{# TODO: Use reverse for the login url once it's off TikiWiki #}
<form action="https://{{ request.META['HTTP_HOST'] }}{{ settings.LOGIN_URL }}" method="POST">
<label for="id_username">{{ _('Username:') }}</label>
<input type="text" id="id_username" name="user"/>

<label for="id_password">{{ _('Password:') }}</label>
<input type="password" id="id_password" name="pass"/>

<label for="id_remember">
<input type="checkbox" value="on" id="id_remember" name="rme">
{{ _('Remember me') }}
</label>

<div>
<input type="submit" name="login" value="{{ _('Log in') }}"/>
</div>

[ <a title="{{ _('Click here to register') }}" href="{{ settings.REGISTER_URL }}">
{{ _('Register') }}
</a>
| <a title="{{ _("Click here if you've forgotten your password") }}" href="/tiki-remind_password.php">{{ _('I forgot my password') }}</a> ]

<input type="hidden" value="y" name="stay_in_ssl_mode"/>
</form>
</div>{# /login-form #}

{% endblock %}
4 changes: 2 additions & 2 deletions templates/layout/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<li><a href="/kb/How+to+contribute">{{ _('How to Contribute') }}</a></li>
{% if user.is_authenticated() %}
<li><a href="/tiki-user_preferences.php">{{ _('My Account') }}</a></li>
<li><a href="{{ LOGOUT_URL }}">{{ _('Log Out') }}</a></li>
<li><a href="{{ settings.LOGOUT_URL }}">{{ _('Log Out') }}</a></li>
{% else %}
<li><a href="{{ LOGIN_URL }}">{{ _('Log In') }}</a></li>
<li><a href="{{ settings.LOGIN_URL }}">{{ _('Log In') }}</a></li>
{% endif %}
</ul>
{% endblock %}

0 comments on commit 26e2d76

Please sign in to comment.