def post(self, task_id, completed_on): completion_date = parsedate(completed_on) task = self.session.query( orm.Task).filter(orm.Task.task_id == task_id).one() if task.last_completed is None or completion_date > task.last_completed: task.complete(self.current_user, parsedate(completed_on)) self.session.commit() else: self.current_user.notify( 'error', "You already completed '{}' on {}".format( task.name, date_str(completion_date)), task.task_id) self.session.commit() self.redirect(Main)
def post(self, task_id, completed_on): completion_date = parsedate(completed_on) task = self.session.query(orm.Task).filter(orm.Task.task_id == task_id).one() if task.last_completed is None or completion_date > task.last_completed: task.complete(self.current_user, parsedate(completed_on)) self.session.commit() else: self.current_user.notify('error', "You already completed '{}' on {}" .format(task.name, date_str(completion_date)), task.task_id) self.session.commit() self.redirect(Main)
def __repr__(self): return '{name} starts on {date} and recurs every {length}'\ .format(name = self.name, date = utils.date_str(self.first_due), length = utils.time_str(self.length.days))