Activate login / logout links / list available users for demo

This commit is contained in:
Yohan Boniface 2012-12-12 13:13:14 +01:00
parent 214921bdea
commit e4339ff9d4
5 changed files with 29 additions and 9 deletions

View file

@ -25,7 +25,6 @@ LANGUAGES = (
SECRET_KEY = 'j6fly6aomgo6!3_$v#9kvhw-%wgs1@1l6x+4nr73tmn40=&_@&'
INSTALLED_APPS = (
# 'youmap.apps.',
'chickpea',
'foundation',
'endless_pagination',

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>{% block head_title %}YouMap{% endblock %}</title>
<title>{% block head_title %}u{Map}{% endblock %}</title>
<meta charset="utf-8">
<!-- Included CSS Files (Compressed) -->
<link rel="stylesheet" href="{{ STATIC_URL }}foundation/stylesheets/foundation.css">

View file

@ -53,8 +53,6 @@
<div class="four columns hide-for-small">
<h4>Action!</h4><hr/>
<a href="{% url map_add %}" class="reveal">
<div class="panel radius callout" align="center">
<strong>Test it and create a map</strong>
@ -66,6 +64,11 @@
<strong>Fork it</strong>
</div>
</a>
<div class="panel">
<p>
Users to play with (password: <span class="label">123123</span>): {% for u in users %}<a href="{% url user_maps u.username %}">{{ u }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}
</p>
</div>
</div>
@ -118,5 +121,21 @@
{% block bottom_js %}
{{ block.super }}
<script>$.endlessPaginate({paginateOnScroll: true});</script>
<script type="text/javascript">
$.endlessPaginate({paginateOnScroll: true});
$(document).ready(function(e){
$('a.login_button').click(function (e) {
e.preventDefault();
var $this = $(this);
L.Util.Xhr.login({"login_required": $this.attr('href')});
});
});
$(document).ready(function(e){
$('a.logout_button').click(function (e) {
e.preventDefault();
var $this = $(this);
L.Util.Xhr.logout($this.attr('href'));
});
});
</script>
{% endblock bottom_js %}

View file

@ -7,10 +7,10 @@
<section>
<ul class="left">
{% if user.is_authenticated %}
<li><a href="{% url user_maps user.username %}">My maps</a></li>
<li><a href="#">Log out</a></li>
<li><a href="{% url user_maps user.username %}">My maps ({{ user }})</a></li>
<li><a href="{% url logout %}" class="logout_button">Log out</a></li>
{% else %}
<li><a href="#">Log in</a></li>
<li><a href="{% url login %}" class="login_button">Log in</a></li>
{% endif %}
</ul>

View file

@ -11,8 +11,10 @@ class Home(TemplateView):
def get_context_data(self, **kwargs):
maps = Map.objects.order_by('-modified_at')[:100]
users = User.objects.filter(is_staff=False)[:10]
return {
"maps": maps
"maps": maps,
"users": users
}
def get_template_names(self):