fixt encoding-error

the new filter-sort-function take use of urllib.urlencode. This function
does not encode unicode-strings. So we have to decode every value in the
sortfilter-dict
This commit is contained in:
Oskar Hahn 2011-09-10 09:40:39 +02:00
parent 97327a3b17
commit f673233a18

View File

@ -36,12 +36,17 @@ from django.db.models import Avg, Max, Min, Count
@permission_required('participant.can_see_participant') @permission_required('participant.can_see_participant')
@template('participant/overview.html') @template('participant/overview.html')
def get_overview(request): def get_overview(request):
def decodedict(dict):
newdict = {}
for key in dict:
newdict[key] = [dict[key][0].encode('utf-8')]
return newdict
try: try:
sortfilter = parse_qs(request.COOKIES['participant_sortfilter']) sortfilter = parse_qs(request.COOKIES['participant_sortfilter'])
except KeyError: except KeyError:
sortfilter = {} sortfilter = {}
for value in ['gender', 'group', 'type', 'committee', 'sort', 'reverse']: for value in [u'gender', u'group', u'type', u'committee', u'sort', u'reverse']:
if value in request.REQUEST: if value in request.REQUEST:
if request.REQUEST[value] == '---': if request.REQUEST[value] == '---':
try: try:
@ -82,7 +87,7 @@ def get_overview(request):
'users': users, 'users': users,
'groups': groups, 'groups': groups,
'committees': committees, 'committees': committees,
'cookie': ['participant_sortfilter', urlencode(sortfilter, doseq=True)], 'cookie': ['participant_sortfilter', urlencode(decodedict(sortfilter), doseq=True)],
'sortfilter': sortfilter, 'sortfilter': sortfilter,
} }