Пример #1
0
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.')
Пример #2
0
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.')
Пример #3
0
def db(app, request):
    """Session-wide test database."""
    print blue('\nInitializing test database.')

    # Make sure we delete any existing test database.
    if os.path.exists(TEST_DATABASE_PATH):
        os.unlink(TEST_DATABASE_PATH)

    def teardown():
        print blue('Deleting test database.')
        os.unlink(TEST_DATABASE_PATH)

    print blue('Applying migrations.')
    apply_migrations()

    request.addfinalizer(teardown)
    return _db
Пример #4
0
def db(app, request):
    """Session-wide test database."""
    print blue('\nInitializing test database.')

    # Make sure we delete any existing test database.
    if os.path.exists(TEST_DATABASE_PATH):
        os.unlink(TEST_DATABASE_PATH)

    def teardown():
        print blue('Deleting test database.')
        os.unlink(TEST_DATABASE_PATH)

    print blue('Applying migrations.')
    apply_migrations()

    request.addfinalizer(teardown)
    return _db
Пример #5
0
def main(should_create, index_all, session):
    name = settings.SEARCH_INDEX_NAME
    directory = settings.SEARCH_INDEX_DIRECTORY

    if should_create:
        print blue("You've asked to (re)create index '{}'.".format(name))
        IndexManager.create(Schema, name, directory)

    if not IndexManager.exists(name, directory):
        die('Search index does not exist!')

    index = Index()

    start = time.time()

    kwargs = {} if index_all else {'published': True}
    jobs = session.query(Job).filter_by(**kwargs).all()

    index.add_document_bulk([job.to_document() for job in jobs])
    duration = time.time() - start

    print green("{0} documents added okay in {1:.2f} ms.".format(len(jobs), duration))
Пример #6
0
def main(should_create, index_all, session):
    name = settings.SEARCH_INDEX_NAME
    directory = settings.SEARCH_INDEX_DIRECTORY

    if should_create:
        print blue("You've asked to (re)create index '{}'.".format(name))
        IndexManager.create(Schema, name, directory)

    if not IndexManager.exists(name, directory):
        die('Search index does not exist!')

    index = Index()

    start = time.time()

    kwargs = {} if index_all else {'published': True}
    jobs = session.query(Job).filter_by(**kwargs).all()

    index.add_document_bulk([job.to_document() for job in jobs])
    duration = time.time() - start

    print green("{0} documents added okay in {1:.2f} ms.".format(
        len(jobs), duration))
Пример #7
0
 def teardown():
     print blue('Deleting test database.')
     os.unlink(TEST_DATABASE_PATH)
Пример #8
0
 def teardown():
     print blue('Deleting test database.')
     os.unlink(TEST_DATABASE_PATH)