def get_meal_set_url(d, meal_time, quality): # should ask for user to get token year = d.year month = d.month day = d.day token = get_token() q = {True:'True', False:'False'}[quality] u = "/token_set_meal/%.6d/%.4d/%.2d/%.2d/%s/%s/" % (token, year, month, day, meal_time, q) return u
def get_meal_set_url(d, meal_time, quality): # should ask for user to get token year = d.year month = d.month day = d.day token = get_token() q = {True: 'True', False: 'False'}[quality] u = "/token_set_meal/%.6d/%.4d/%.2d/%.2d/%s/%s/" % (token, year, month, day, meal_time, q) return u
def get_today_meal_links(): d = datetime.date.today() year = d.year month = d.month day = d.day token = get_token() urls = [] for meal in ['B', 'L', 'D']: for quality in ['True', 'False']: u = "/token_set_meal/%.6d/%.4d/%.2d/%.2d/%s/%s/" % (token, year, month, day, meal, quality) urls.append(u) return urls
def get_today_meal_links(): d = datetime.date.today() year = d.year month = d.month day = d.day token = get_token() urls = [] for meal in ['B', 'L', 'D']: for quality in ['True', 'False']: u = "/token_set_meal/%.6d/%.4d/%.2d/%.2d/%s/%s/" % ( token, year, month, day, meal, quality) urls.append(u) return urls
def handle(self, *args, **options): ivan = get_ivan() today = datetime.date.today() # check the time for the meal. now = datetime.datetime.now() if now.hour < 10: # don't ask if it is in the morning # assume dinner last night was sent return elif now.hour < 12: meal_time = 'B' elif now.hour < 15: # don't ask about lunch before 3pm return elif now.hour < 17: meal_time = 'L' elif now.hour < 19: # don't ask about dinner before 7pm return else: meal_time = 'D' # check if the meal exists try: m = Meal.objects.filter(user=ivan, date=today, meal_time=meal_time)[0] return except: pass # check if the prompt was already sent try: q = MealQueried.objects.filter(user=ivan, date=today, meal_time=meal_time)[0] return except: # create the record q = MealQueried(user=ivan, date=today, meal_time=meal_time) q.save() token = get_token() year = today.year month = today.month day = today.day good_url = "http://www.wiifapp.com/token_set_meal/%.6d/%.4d/%.2d/%.2d/%s/%s/" % (token, year, month, day, meal_time, 'True') bad_url = "http://www.wiifapp.com/token_set_meal/%.6d/%.4d/%.2d/%.2d/%s/%s/" % (token, year, month, day, meal_time, 'False') meal = {'B':'breakfast', 'L':'lunch', 'D':'dinner'}[meal_time] day_of_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'][today.weekday()] subject = "%s on %s, %.4d/%.2d/%.2d" % (meal, day_of_week, year, month, day) saying = random.choice([ "just f*****g do it", "your next decision is important", "hang in there!", "anyone in the race laps everyone on the couch", "be the change you want to see in the world", "some people die at 25 and aren't buried till 75", "turn down for what", "don't start no shit wont be no shit", ]) html = """<a href="%s">GOOD</a><br/> <br/> <a href="%s">BAD</a><br/> <br/> %s """ % (good_url, bad_url, saying) text = "http://www.wiifapp.com/" send_email('*****@*****.**', subject, text, html)
def handle(self, *args, **options): ivan = get_ivan() today = datetime.date.today() # check the time for the meal. now = datetime.datetime.now() if now.hour < 10: # don't ask if it is in the morning # assume dinner last night was sent return elif now.hour < 12: meal_time = 'B' elif now.hour < 15: # don't ask about lunch before 3pm return elif now.hour < 17: meal_time = 'L' elif now.hour < 19: # don't ask about dinner before 7pm return else: meal_time = 'D' # check if the meal exists try: m = Meal.objects.filter(user=ivan, date=today, meal_time=meal_time)[0] return except: pass # check if the prompt was already sent try: q = MealQueried.objects.filter(user=ivan, date=today, meal_time=meal_time)[0] return except: # create the record q = MealQueried(user=ivan, date=today, meal_time=meal_time) q.save() token = get_token() year = today.year month = today.month day = today.day good_url = "http://www.wiifapp.com/token_set_meal/%.6d/%.4d/%.2d/%.2d/%s/%s/" % ( token, year, month, day, meal_time, 'True') bad_url = "http://www.wiifapp.com/token_set_meal/%.6d/%.4d/%.2d/%.2d/%s/%s/" % ( token, year, month, day, meal_time, 'False') meal = {'B': 'breakfast', 'L': 'lunch', 'D': 'dinner'}[meal_time] day_of_week = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ][today.weekday()] subject = "%s on %s, %.4d/%.2d/%.2d" % (meal, day_of_week, year, month, day) saying = random.choice([ "just f*****g do it", "your next decision is important", "hang in there!", "anyone in the race laps everyone on the couch", "be the change you want to see in the world", "some people die at 25 and aren't buried till 75", "turn down for what", "don't start no shit wont be no shit", ]) html = """<a href="%s">GOOD</a><br/> <br/> <a href="%s">BAD</a><br/> <br/> %s """ % (good_url, bad_url, saying) text = "http://www.wiifapp.com/" send_email('*****@*****.**', subject, text, html)