def query_list(request): group_tables = {} terms_data = search_data = discrete_data = {} for group in QueryGroup.objects.all(): if group.query_set.count(): prefix = "group_%s_" % group.id group_view = GroupQueryView(request, group, model=Query, table_class=GroupQueryTable) table = GroupQueryTable(group_view.get_table_data(prefix), prefix=prefix) search_data.update(table.prepare_search_data(group_view)) discrete_data.update(table.prepare_discrete_data(group_view)) terms_data.update(table.prepare_terms_data(group_view)) group_tables[group.name] = table config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) prefix = "other_" other_view = OtherQueryView(request, model=Query, table_class=OtherQueryTable) other_query_table = OtherQueryTable(other_view.get_table_data(prefix), prefix=prefix) config = RequestConfig(request, paginate={"per_page": other_query_table.length}) config.configure(other_query_table) search_data.update(other_query_table.prepare_search_data(other_view)) discrete_data.update(other_query_table.prepare_discrete_data(other_view)) terms_data.update(other_query_table.prepare_terms_data(other_view)) prefix = "user_" view = UserQueryView(request, model=Query, table_class=UserQueryTable) user_query_table = UserQueryTable(view.get_table_data(prefix), prefix=prefix) config = RequestConfig(request, paginate={"per_page": user_query_table.length}) config.configure(user_query_table) search_data.update(user_query_table.prepare_search_data(view)) discrete_data.update(user_query_table.prepare_discrete_data(view)) terms_data.update(user_query_table.prepare_terms_data(view)) template = loader.get_template("lava_results_app/query_list.html") return HttpResponse( template.render( { "user_query_table": user_query_table, "other_query_table": other_query_table, "search_data": search_data, "discrete_data": discrete_data, "terms_data": terms_data, "group_tables": group_tables, "bread_crumb_trail": BreadCrumbTrail.leading_to(query_list), "context_help": ["lava-queries-charts"], }, request=request, ))
def query_list(request): group_tables = {} terms_data = search_data = discrete_data = {} for group in QueryGroup.objects.all(): if group.query_set.count(): prefix = "group_%s_" % group.id group_view = GroupQueryView(request, group, model=Query, table_class=GroupQueryTable) table = GroupQueryTable(group_view.get_table_data(prefix), prefix=prefix) search_data.update(table.prepare_search_data(group_view)) discrete_data.update(table.prepare_discrete_data(group_view)) terms_data.update(table.prepare_terms_data(group_view)) group_tables[group.name] = table config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) prefix = "other_" other_view = OtherQueryView(request, model=Query, table_class=OtherQueryTable) other_query_table = OtherQueryTable(other_view.get_table_data(prefix), prefix=prefix) config = RequestConfig(request, paginate={"per_page": other_query_table.length}) config.configure(other_query_table) search_data.update(other_query_table.prepare_search_data(other_view)) discrete_data.update(other_query_table.prepare_discrete_data(other_view)) terms_data.update(other_query_table.prepare_terms_data(other_view)) if request.user.is_authenticated(): prefix = "user_" view = UserQueryView(request, model=Query, table_class=UserQueryTable) user_query_table = UserQueryTable(view.get_table_data(prefix), prefix=prefix) config = RequestConfig(request, paginate={"per_page": user_query_table.length}) config.configure(user_query_table) search_data.update(user_query_table.prepare_search_data(view)) discrete_data.update(user_query_table.prepare_discrete_data(view)) terms_data.update(user_query_table.prepare_terms_data(view)) else: user_query_table = None return render_to_response( 'lava_results_app/query_list.html', { 'user_query_table': user_query_table, 'other_query_table': other_query_table, 'search_data': search_data, "discrete_data": discrete_data, 'terms_data': terms_data, 'group_tables': group_tables, 'bread_crumb_trail': BreadCrumbTrail.leading_to(query_list), 'context_help': BreadCrumbTrail.leading_to(query_list), }, RequestContext(request) )