def get_budget(request): muni = request.GET.get('muni', None) year = request.GET.get('year', None) # FIXME: the convert might be a bug layer = int(request.GET.get('layer', 1)) return HttpResponse(dumps(vis_get_budget(muni, year, layer)), 'application/json')
def get_autocomplete(request): q = request.GET.get('term', '') results = search_code(q) results_dict = {tree['code']: tree for tree in results} results_keys = results_dict.keys() res = [] for key_id, key in enumerate(results_keys): print results_dict[key] res.append({ 'id': key_id, 'label': '', 'value': dumps(results_dict[key]) }) # print res return HttpResponse(dumps(res), 'application/json')
async def buy(self, depth, old_order=False, amount=False, print_info=1): info = self.get_trade_info(depth, 'buy', amount, old_order) if not info: return False api_resp = await self.trade('buy', info) if not api_resp: return False info['api'] = json.loads(utils.dumps(api_resp)) order = await self.add_order(info, depth) info['id'] = order.id if print_info: self.print_order(info, 'buy', old_order) return info
def get_budget_tree(request): muni = request.GET.get('muni') year = request.GET.get('year') layer = request.GET.get('layer', 1000) expense = request.GET.get('expense', None) if expense is not None: if expense == 'true': expense = True elif expense == 'false': expense = False else: expense = None return HttpResponse( dumps(vis_get_budget_tree(muni, year, layer=layer, expense=expense)), 'application/json')
def get_node_subtree(request): node_id = request.GET.get('node_id', None) layer = int(request.GET.get('layer', 1)) return HttpResponse(dumps(vis_get_node_subtree(node_id, layer)), 'application/json')
def get_munis(request): munis = db_get_munis() munis = list(munis.find({})) return HttpResponse(dumps(munis, 'application/json'))