added admin page with all (even non-public) polls and their admin links

This commit is contained in:
lars 2010-05-07 16:28:50 +00:00
parent ff177974be
commit 03f68579bf

View file

@ -418,10 +418,26 @@ def base():
@bobo.query('/')
def show_frontpage(page=None):
return show_poll_list("frontpage.html", 10, page)
@bobo.query('/admin')
@bobo.query('/admin/')
def show_admin_page(page=None, page_size=20):
try:
page_size = int(page_size)
except ValueError:
page_size = 20
return show_poll_list("admin.html", page_size, page, filter_private=False)
def show_poll_list(render_file, page_size, page=None, filter_private=True):
value_dict = get_default_values()
polls = Poll.select().orderBy("-timestamp_creation")
# TODO: speed the filtering up by using SQL statements (see sqlobject "filter")
if filter_private:
polls = [poll for poll in polls if poll.get_settings()["public"]]
else:
# convert the sql query into a list (probably an expensive operation)
polls = [poll for poll in polls]
if page is None:
page = 1
else:
@ -429,7 +445,6 @@ def show_frontpage(page=None):
page = int(page)
except ValueError:
page = 1
page_size = 10
start = (page - 1) * page_size
if start >= len(polls):
start = 0
@ -441,7 +456,7 @@ def show_frontpage(page=None):
value_dict["show_next_link"] = (end + 1 < len(polls))
value_dict["show_previous_link"] = (start > 0)
value_dict["page"] = page
return render("frontpage.html", **value_dict)
return render(render_file, **value_dict)
def render_poll_admin(poll, add_related, del_related):
value_dict = get_default_values()