def get_goal_id_name_mapping_for_user(id): data = dict() try: goal_list = dict() goal_objs = Goal.objects.filter(user=id) for goal_obj in goal_objs: goal_list[goal_obj.id] = goal_obj.name ext_user = get_ext_user(id) for u in get_users(ext_user): if u.id == int(id): continue gos = Goal.objects.filter(user=u.id) for go in gos: goal_list[go.id] = '* ' + go.name return goal_list except Exception as e: print(e) return data
def get(self, request, format=None, user=None): data = dict() data['goal_list'] = list() if not user: return Response(data) print('user is', user) try: goal_list = dict() goal_objs = Goal.objects.filter(user=user) for goal_obj in goal_objs: goal_list[goal_obj.id] = goal_obj.name ext_user = get_ext_user(user) for u in get_users(ext_user): if u.id == int(user): continue gos = Goal.objects.filter(user=u.id) for go in gos: goal_list[go.id] = '* ' + go.name data['goal_list'] = goal_list except Exception as e: print(e) finally: print(data) return Response(data)
def get_loan_amount_for_all_users(self, ext_user): from users.user_interface import get_users amt = 0 for u in get_users(ext_user): amt += self.get_loan_amount_for_user(u.id) return amt