aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Bacherikov <slava@bacher09.org>2012-08-11 21:22:38 +0300
committerSlava Bacherikov <slava@bacher09.org>2012-08-11 21:22:38 +0300
commita5df0c3770038f1d407b9d7844773614a06dc9d6 (patch)
tree218ac30e0c3012ff046c405683950216259e9a51
parentImprove ebuild_table template (diff)
downloadgentoo-packages-a5df0c3770038f1d407b9d7844773614a06dc9d6.tar.gz
gentoo-packages-a5df0c3770038f1d407b9d7844773614a06dc9d6.tar.bz2
gentoo-packages-a5df0c3770038f1d407b9d7844773614a06dc9d6.zip
Extend filtering view
-rw-r--r--gpackages/apps/generic/views.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/gpackages/apps/generic/views.py b/gpackages/apps/generic/views.py
index 165633d..575f90b 100644
--- a/gpackages/apps/generic/views.py
+++ b/gpackages/apps/generic/views.py
@@ -5,6 +5,7 @@ from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed, rfc3339_date
from django.utils import tzinfo
from django.utils.timezone import is_naive
+from django.http import Http404
class ContextView(object):
extra_context = {}
@@ -71,6 +72,7 @@ def dynamic_order(args_list, allowed_list, reverse = None):
class MultipleFilterListViewMixin(object):
allowed_filter = {}
allowed_order = {}
+ boolean_filters = ()
# allowed_many = {'name': int_count}
allowed_many = {}
m2m_filter = set()
@@ -93,6 +95,8 @@ class MultipleFilterListViewMixin(object):
vm = v.split(',')
if len(vm)>1:
v = cut_to_len(vm, self.allowed_many[k])
+ elif k in self.boolean_filters:
+ v = True if v == 'yes' else False
newqs[k] = v
self.queries_dict = newqs
return newqs
@@ -134,9 +138,13 @@ class MultipleFilterListViewMixin(object):
@classmethod
def get_url_part(cls):
t = "(?:{0}/(?P<{0}>[^/]+)/)?"
+ t_bool = "(?:{0}/(?P<{0}>yes|no)/)?"
l =[]
for key in cls.allowed_filter.iterkeys():
- l.append(t.format(re.escape(key)))
+ if key in cls.boolean_filters:
+ l.append(t_bool.format(re.escape(key)))
+ else:
+ l.append(t.format(re.escape(key)))
return ''.join(l) + "(?:order/(?P<order>[a-z]*)/)?(?P<rev>rev/)?"