def recently_called(self): from calling.models import Call an_hour_ago = datetime.datetime.now() - datetime.timedelta(hours=1) calls = Call.all() calls.filter('user ='******'created >', an_hour_ago) return calls.count() != 0
def get(self, phone_number): """ Show a calendar summary of the user's responses to wakeup calls !! This will explode in 2012 """ user = User.all().filter('phone_number =', "+%s" % phone_number).get() if user is None: return self.http404() history = {} calls = Call.all().filter('user ='******'day': d, 'correct_response': False } for d in cal.itermonthdays2(2011, call.created.month)] for day_history in month_history: if day_history['day'][0] == call.created.day: day_history['correct_response'] = True break # If there is nothing in the history, add the current month to # ensure that at least one month is rendered if len(history) == 0: now = datetime.datetime.now() history[now.strftime("%B")] = [{ 'day': d, 'correct_response': False } for d in cal.itermonthdays2(2011, now.month)] context = {'user': user, 'history': history} path = os.path.join(TEMPLATE_DIR, 'results.html') self.response.out.write(template.render(path, context))
def get(self, phone_number): """ Show a calendar summary of the user's responses to wakeup calls !! This will explode in 2012 """ user = User.all().filter('phone_number =', "+%s" % phone_number).get() if user is None: return self.http404() history = {} calls = Call.all().filter('user ='******'day': d, 'correct_response': False} for d in cal.itermonthdays2(2011, call.created.month) ] for day_history in month_history: if day_history['day'][0] == call.created.day: day_history['correct_response'] = True break # If there is nothing in the history, add the current month to # ensure that at least one month is rendered if len(history) == 0: now = datetime.datetime.now() history[now.strftime("%B")] = [ {'day': d, 'correct_response': False} for d in cal.itermonthdays2(2011, now.month) ] context = {'user': user, 'history': history} path = os.path.join(TEMPLATE_DIR, 'results.html') self.response.out.write(template.render(path, context))