Merge pull request #222 from Gluejar/library_users_list

list of library users
pull/1/head
Raymond Yee 2013-10-29 14:09:16 -07:00
commit 775aa61acb
5 changed files with 95 additions and 2 deletions

View File

@ -54,6 +54,9 @@
<a href="{% url supporter ungluer %}"><span class="ungluer-name">{{ungluer|truncatechars:20}}</span> <a href="{% url supporter ungluer %}"><span class="ungluer-name">{{ungluer|truncatechars:20}}</span>
</a></li> </a></li>
{% endfor %} {% endfor %}
{% if library %}
<li class="first"><a href="{% url library_users library %}"><span>More from {{ library }}</span></a></li>
{% endif %}
</ul> </ul>
</li> </li>
{% endif %} {% endif %}

View File

@ -1,5 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %} Comments {% endblock %} {% block title %} Libraries {% endblock %}
{% block extra_css %} {% block extra_css %}
<link type="text/css" rel="stylesheet" href="/static/css/supporter_layout.css" /> <link type="text/css" rel="stylesheet" href="/static/css/supporter_layout.css" />
<link type="text/css" rel="stylesheet" href="/static/css/liblist.css" /> <link type="text/css" rel="stylesheet" href="/static/css/liblist.css" />

View File

@ -0,0 +1,78 @@
{% extends "base.html" %}
{% block title %} Users of {{ library }} {% endblock %}
{% block extra_css %}
<link type="text/css" rel="stylesheet" href="/static/css/supporter_layout.css" />
<link type="text/css" rel="stylesheet" href="/static/css/liblist.css" />
{% endblock %}
{% block extra_head %}
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
{% endblock %}
{% block topsection %}
<div id="js-topsection">
<div class="js-main">
<div class="js-topnews">
<div class="js-topnews1">
<div class="js-topnews2">
<div class="js-topnews3">
<div class="user-block">
<div id="user-block1">
<div id="block-intro-text"><span class="special-user-name">{{ library }} </span> </div>
</div>
<div class="user-block24"><span class="user-short-info">These ungluers are are using <a href="{% url library library %}">{{ library }}</a>. </span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block content %}
<div id="main-container">
<div class="js-main">
<div id="js-leftcol">
{% include "explore.html" %}
</div>
<div id="js-maincol-fr">
<div class="js-maincol-inner">
<div id="content-block">
<div id="content-block-content">
<div style="height:46px;"></div>
{% if is_member %}
{% for libuser in library.library_users.all %}
<div class="items {% cycle 'row1' 'row2' %}">
<div class="avatar">
<a href="{% url supporter libuser.user.username %}">
<img class="user-avatar" src="{{ libuser.user.profile.avatar_url }}" height="50" width="50" alt="Avatar for {{ libuser.user.username }}" title="{{ libuser.user }}" />
</a>
</div>
<div class="nonavatar">
<div class="libname"><a href="{% url supporter libuser.user.username %}">{{ libuser.user.username }}</a> {{ libuser.user.profile.tagline }}</div>
<div class="libstat">{{ libuser.user.wishlist.works.count }} books on list</div>
{% if is_admin %}
<div class="libstat">authorized {{ libuser.date_modified|date:"M j, Y" }}</div>
<div class="libstat">credential: {{ libuser.credential }}</div>
<div class="libstat"></div>
{% endif %}
</div>
</div>
{% empty %}
No users yet.
{% endfor %}
{% else %}
You need to be a member of {{ library }} to see all its members. They can borrow and donate books. Perhaps you'd like to <a href="{% url join_library library %}">join them</a>?
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -7,6 +7,7 @@ urlpatterns = patterns(
"", "",
url(r"^libraryauth/(?P<library>[^/]+)/join/$", views.join_library, name="join_library"), url(r"^libraryauth/(?P<library>[^/]+)/join/$", views.join_library, name="join_library"),
url(r"^libraryauth/(?P<library>[^/]+)/deny/$", direct_to_template, {'template':'libraryauth/denied.html'}, name="bad_library"), url(r"^libraryauth/(?P<library>[^/]+)/deny/$", direct_to_template, {'template':'libraryauth/denied.html'}, name="bad_library"),
url(r"^libraryauth/(?P<library>[^/]+)/users/$", views.library, {'template':'libraryauth/users.html'}, name="library_users"),
url(r"^libraryauth/list/$", direct_to_template, { url(r"^libraryauth/list/$", direct_to_template, {
'template':'libraryauth/list.html', 'template':'libraryauth/list.html',
'extra_context':{'libraries':models.Library.objects.order_by('user__username')} 'extra_context':{'libraries':models.Library.objects.order_by('user__username')}

View File

@ -1,6 +1,6 @@
import logging import logging
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404, render
from django.contrib.auth.views import login from django.contrib.auth.views import login
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from . import backends from . import backends
@ -10,6 +10,17 @@ from .forms import AuthForm
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def library(request, library,
extra_context={},
template='libraryauth/library.html',
**kwargs):
library=get_object_or_404(Library, user__username=library)
context={ 'library':library,
'is_admin': request.user.is_staff or request.user==library.user,
'is_member': request.user.is_staff or library.has_user(request.user),
}
context.update(extra_context)
return render(request, template, context)
def join_library(request, library): def join_library(request, library):
library=get_object_or_404(Library, user__username=library) library=get_object_or_404(Library, user__username=library)