def main(job_id, session): job = session.query(Job).get(job_id) if not job: die("Job ({}) does not exist.".format(job_id)) print isinstance(job.title, unicode) print "You're reviewing the following listing:" print make_summary(job).encode('utf-8') action = 'publish' if not job.published else 'unpublish' if prompt("Do you want to {} this listing?".format(blue(action)), yesno=True): job.published = not job.published session.commit() print green('Job {}ed!'.format(action)) if action == 'unpublish': return if prompt(blue('Do you want to send a confirmation email?'), yesno=True): send_confirmation_email(job) print green('Confirmation email sent!') else: die('Bye.')
def main(session, app): kwargs = dict() next = 'title' while next: field = field_schema[next] message = field['prompt'] handler = field.get('handler') value = prompt(message) if handler: value = handler(value, session) kwargs[next] = value next = field.get('next') if hasattr(next, '__call__'): next = next(value) job = Job(**kwargs) session.add(job)