Automated merge with ssh://openslides.org/openslides

This commit is contained in:
Emanuel Schuetze 2012-04-18 22:01:06 +02:00
commit 236bbfd3bc
3 changed files with 49 additions and 17 deletions

View File

@ -27,17 +27,17 @@
</select>
</form>
</p>
{{ applications|length }} {% trans "Applications" %}
{{ applications.exist }} {% trans "Applications" %}
<table>
<tr>
<th><a href="?sort=number{% if 'number' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Number" %}</a></th>
<th><a href="?sort=aversion__title{% if 'aversion__title' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Application title" %}</a></th>
<th><a href="?sort=title{% if 'title' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Application title" %}</a></th>
{% if min_supporters > 0 %}
<th><a href="?sort=supporter{% if 'supporter' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Number of supporters" %}</a></th>
{% endif %}
<th><a href="?sort=status{% if 'status' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Status" %}</a></th>
<th><a href="?sort=submitter{% if 'submitter' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Submitter" %}</a></th>
<th><a href="?sort=aversion__time{% if 'aversion__time' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Creation Time" %}<a></th>
<th><a href="?sort=time{% if 'time' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{%trans "Creation Time" %}<a></th>
</tr>
{% for application in applications %}
<tr class="{% cycle '' 'odd' %}">

View File

@ -15,6 +15,12 @@ import csv
import utils.csv_ext
import os
from urllib import urlencode
try:
from urlparse import parse_qs
except ImportError: # python <= 2.5
from cgi import parse_qs
from django.shortcuts import redirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required
@ -62,28 +68,51 @@ def overview(request):
"""
View all applications
"""
query = Application.objects
if 'number' in request.GET:
query = query.filter(number=None)
if 'status' in request.GET:
if 'statusvalue' in request.GET and 'on' in request.GET['status']:
query = query.filter(status__iexact=request.GET['statusvalue'])
try:
sort = request.GET['sort']
if sort in ['number', 'supporter', 'status', 'submitter', \
'aversion__time', 'aversion__title']:
query = query.order_by(sort)
sortfilter = parse_qs(request.COOKIES['votecollector_sortfilter'])
for value in sortfilter:
sortfilter[value] = sortfilter[value][0]
except KeyError:
query = query.order_by("number")
if 'reverse' in request.GET:
sortfilter = {}
for value in [u'sort', u'reverse', u'number', u'status', u'needsup', u'statusvalue']:
if value in request.REQUEST:
if request.REQUEST[value] == '0':
try:
del sortfilter[value]
except KeyError:
pass
else:
sortfilter[value] = request.REQUEST[value]
query = Application.objects.all()
if 'number' in sortfilter:
query = query.filter(number=None)
if 'status' in sortfilter:
if 'statusvalue' in sortfilter and 'on' in sortfilter['status']:
query = query.filter(status__iexact=sortfilter['statusvalue'])
if 'sort' in sortfilter:
if sortfilter['sort'] == 'title':
sort = 'aversion__title'
elif sortfilter['sort'] == 'time':
sort = 'aversion__time'
else:
sort = sortfilter['sort']
query = query.order_by(sort)
if 'reverse' in sortfilter:
query = query.reverse()
if 'needsup' in request.GET:
# todo: rewrite this with a .filter()
if 'needsup' in sortfilter:
applications = []
for application in query.all():
if not application.enough_supporters:
applications.append(application)
else:
applications = query.all()
applications = query
return {
'applications': applications,
'min_supporters': int(config['application_min_supporters']),

View File

@ -230,6 +230,9 @@ class PDFView(PermissionMixin, View):
def get_document_title(self):
return self.document_title
def get_get_filename(self):
return self.filename
def render_to_response(self, filename):
response = HttpResponse(mimetype='application/pdf')
filename = u'filename=%s.pdf;' % self.get_filename()