def getDataCount(self, widget): data = Datum.objects.all().filter(widget=widget).filter(name="default")[:1] if len(data) > 0: data = data[0].data_float else: data = 0 return { 'count': splitThousands(str(data)), }
def getDataProgress(self, widget): data = Datum.objects.all().filter(widget=widget) current_data = data.filter(name='current')[:1] goal_data = data.filter(name='goal')[:1] if len(goal_data) > 0 and len(current_data) > 0: current_data = current_data[0].data_float goal_data = goal_data[0].data_float percent = (current_data/goal_data)*100 else: current_data = 0 goal_data = 0 percent = 0 return { 'current': splitThousands(str(current_data)), 'goal': splitThousands(str(goal_data)), 'percent': percent, }