def LevelCheck(user, data): user.steps += tools.caloriesToStep(data.calories, user.height, user.weight) user.save() flag = False while user.steps > tools.levelGap[user.level]: user.level += 1 flag = True if flag: url = "%s/basic/redirect/profile?page=3" data = {"level": {"value": str(user.level), "color": "#ff0000"}} wechat_tools.customSendTemplate(user.openId, wechat_tools.template_id["levelUp"], "#000000", data, url)
def MatchsCheck(user, data): matchs = user.user_match_members.filter(finished=0) now = tools.getNow() for match in matchs: if match.startTime < now: continue progress = MatchProgress.objects.filter(match=match, user=user) if progress.count() > 0: progress = progress[0] else: continue progress.value += tools.caloriesToStep(data.calories, user.height, user.weight) progress.save() MatchCheck(user, match, progress)
def PlansCheck(user, data): plans = user.user_plan_members.filter(finished=0) now = tools.getNow() for plan in plans: if plan.startTime < now: continue progress = PlanProgress.objects.filter(plan=plan, user=user) if progress.count() > 0: progress = progress[0] else: continue oldValue = progress.value progress.value += tools.caloriesToStep(data.calories, user.height, user.weight) progress.save() PlanCheck(user, plan, progress, oldValue)
def LevelCheck(user, data): user.steps += tools.caloriesToStep(data.calories, user.height, user.weight) user.save() flag = False while user.steps > tools.levelGap[user.level]: user.level += 1 flag = True if flag: url = "%s/basic/redirect/profile?page=3" data = { "level": { "value": str(user.level), "color": "#ff0000", } } wechat_tools.customSendTemplate(user.openId, wechat_tools.template_id["levelUp"], "#000000", data, url)