from django.template.loader import render_to_string
+# XXX We need naming helpers in the python Plugin class also, used in template
+
class QueryEditor(Plugin):
def template_file(self):
def requirements (self):
reqs = {
'js_files' : [
+ # XXX datatables
'js/query_editor.js',
] ,
'css_files': [
'css/query_editor.css',
+ 'css/jquery-ui.css',
'css/demo_page.css',
'css/demo_table.css',
]
fields = []
metadata = self.page.get_metadata()
md_fields = metadata.details_by_object('resource')
- print "METADATA FIELDS", md_fields
# XXX use django templating system here
for md_field in md_fields['column']:
v_desc = v.split('-')
options.append(v_desc[0])
- env = {'options': options}
+ env = {
+ 'domid': self.domid,
+ 'options': options
+ }
filter_input = render_to_string('filter_input_string_values.html', env)
else:
- env = {'filter_id': "%s-filter-%s" % (self.domid, md_field['name'])}
+ env = {
+ 'domid': self.domid,
+ 'field': md_field['name']
+ }
filter_input = render_to_string('filter_input_string.html', env)
elif md_field['type'] == 'int':
allowed_values = md_field.get('allowed_values', '0,0').split(',')
- env = {'min': allowed_values[0], 'max': allowed_values[1]}
+ env = {
+ 'domid': self.domid,
+ 'field': md_field['name'],
+ 'min' : allowed_values[0],
+ 'max' : allowed_values[1]
+ }
filter_input = render_to_string('filter_input_integer.html', env)
else:
- env = {'filter_id': "%s-filter-%s" % (self.domid, md_field['name'])}
+ env = {
+ 'domid': self.domid,
+ 'field': md_field['name']
+ }
filter_input = render_to_string('filter_input_others.html', env)
fields.append({
'resource_type': 'N/A',
'filter_input': filter_input,
'header': None,
+ 'checked': md_field['name'] in self.query.get_select()
})
return { 'fields': fields }