1 from unfold.plugin import Plugin
2 from manifold.util.predicate import eq, ne, lt, le, gt, ge, and_, or_, contains, included
4 # NOTE: Python should pass templates to javascript for creating new filters
6 # - or, better, hidden div in the page
7 # In the meantime, templates are duplicated in the javascript code
10 # NOTE: having classes would help
12 class ActiveFilters(Plugin):
14 def __init__ (self, query=None, **settings):
15 Plugin.__init__ (self, **settings)
19 def template_file (self):
20 return "active_filters.html"
22 def template_env (self, request):
24 def get_op_str(predicate):
37 return map[predicate.get_op()]
39 filters = [[f.get_key(), get_op_str(f), f.get_value()] for p in self.query.get_where()]
41 env.update(self.__dict__)
42 env['filters'] = filters
45 def requirements (self):
48 'js/active_filters.js',
51 'css/active_filters.css'
56 def json_settings_list (self):
57 return ['plugin_uuid', 'domid', 'query_uuid']
59 def export_json_settings (self):