moved library list generation into a template tag
previously, if you created or updated a library, the list (/libraryauth/list/ )would not get updatedpull/1/head
parent
8091ba1846
commit
8c974ca343
|
@ -1,4 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load librarylist %}
|
||||
{% block title %} Libraries {% endblock %}
|
||||
{% block extra_css %}
|
||||
<link type="text/css" rel="stylesheet" href="/static/css/supporter_layout.css" />
|
||||
|
@ -33,6 +34,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% librarylist %}
|
||||
<div id="main-container">
|
||||
<div class="js-main">
|
||||
<div id="js-leftcol">
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
from django import template
|
||||
from .. import models
|
||||
register = template.Library()
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def librarylist(context):
|
||||
libraries_to_show = context.get('libraries_to_show', 'approved')
|
||||
if libraries_to_show == 'approved':
|
||||
context['libraries'] = models.Library.objects.filter(approved=True).order_by('name')
|
||||
elif libraries_to_show == 'new':
|
||||
context['libraries'] = models.Library.objects.filter(approved=False).order_by('name')
|
||||
else:
|
||||
context['libraries'] = models.Library.objects.order_by('name')
|
||||
return ''
|
|
@ -14,11 +14,11 @@ urlpatterns = patterns(
|
|||
url(r"^libraryauth/create/$", login_required(views.CreateLibraryView.as_view()), name="library_create"),
|
||||
url(r"^libraryauth/list/$", direct_to_template, {
|
||||
'template':'libraryauth/list.html',
|
||||
'extra_context':{'libraries':models.Library.objects.filter(approved=True).order_by('name')}
|
||||
}, name="library_list"),
|
||||
'extra_context':{'libraries_to_show':'approved'}},
|
||||
name="library_list"),
|
||||
url(r"^libraryauth/unapproved/$", direct_to_template, {
|
||||
'template':'libraryauth/list.html',
|
||||
'extra_context':{'libraries':models.Library.objects.filter(approved=False).order_by('name')}
|
||||
}, name="new_libraries"),
|
||||
'extra_context':{'libraries_to_show':'new'}},
|
||||
name="new_libraries"),
|
||||
url(r'^accounts/superlogin/$', views.superlogin, name='superlogin'),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue