def get(self): next_treat_time = TreatQueue.get_next_treat_time() if next_treat_time: next_treat_time = format_datetime_for_printing(next_treat_time) else: next_treat_time = "No treats scheduled :( Give the next treat!" next_treat_slot = TreatQueue.get_next_open_treat_slot() next_treat_slot = format_datetime_for_printing(next_treat_slot) self.render("templates/index.html", next_treat_time=next_treat_time, next_treat_slot=next_treat_slot)
def add_to_queue(klass, name, phone, treat_time=None): if not treat_time: treat_time = klass.get_next_open_treat_slot() treat_time_string = datetime.datetime.strftime(treat_time, klass.TREAT_TIME_FORMAT) doc = { klass.A_NAME: name, klass.A_PHONE: phone, klass.A_TREAT_TIME: treat_time_string, klass.A_STATUS: klass.STATUS_PENDING } try: klass.mdbc().insert(doc) return format_datetime_for_printing(treat_time) except Exception, e: logging.error("[TreatChewie.add_to_queue] Error: %s" % e) return False