Skip to content

Commit

Permalink
sidebar login
Browse files Browse the repository at this point in the history
  • Loading branch information
zackmdavis committed Nov 1, 2014
1 parent 012eaf5 commit 4e778d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from django.conf import settings
from django.contrib.auth.forms import AuthenticationForm

from core.models import Tag
from core.views.view_utils import tag_cloud_context

def tag_cloud_context_processor(request):
return {'cloud': tag_cloud_context(Tag.objects.all())}

def sidebar_login_form_context_processor(request):
return {'sidebar_login_form': AuthenticationForm() }

def contextual_static_serving_context_processor(request):
if settings.SERVE_STATIC_LIBS_LOCALLY:
jquery_url = "/static/libs/jquery-2.1.1.min.js"
Expand Down
4 changes: 3 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
AUTH_USER_MODEL = "core.FinetoothUser"

AUTH_REDIRECT_URL = "/"
LOGIN_URL = "/login/"

if DEBUG and IS_DEVELOPMENT:
PASSWORD_HASHERS = ('django.contrib.auth.hashers.MD5PasswordHasher',)
Expand All @@ -84,7 +85,8 @@
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'core.context_processors.tag_cloud_context_processor',
'core.context_processors.contextual_static_serving_context_processor'
'core.context_processors.contextual_static_serving_context_processor',
'core.context_processors.sidebar_login_form_context_processor',
)

STATIC_ROOT = 'staticfiles'
Expand Down
9 changes: 9 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
<div class="col-md-3">
{% if user.is_authenticated %}
{% include "includes/sidebar_profile.html" %}
{% else %}
<div id="sidebar-login" class="well">
<form action="/login/" method="POST">
{% csrf_token %}
{{ sidebar_login_form.as_p }}
<input type="hidden" name="next" value="/"/>
<input type="submit" value="log in">
</form>
</div>
{% endif %}
{% include "includes/tag_cloud.html" %}
</div>
Expand Down

0 comments on commit 4e778d2

Please sign in to comment.