#!/usr/bin/env python # -*- coding: utf-8 -*- from hasjob import app, init_for, models from hasjob.models import db from hasjob.search import configure as search_configure from hasjob.uploads import configure as uploads_configure if __name__ == '__main__': import sys init_for('dev') # Seed with sample data with app.test_request_context(): if models.JobType.query.count() == 0: print >> sys.stderr, "Adding some job types" db.session.add(models.JobType(seq=10, name=u'fulltime', title=u'Full-time employment')) db.session.add(models.JobType(seq=20, name=u'contract', title=u'Short-term contract')) db.session.add(models.JobType(seq=30, name=u'freelance', title=u'Freelance or consulting')) db.session.add(models.JobType(seq=40, name=u'volunteer', title=u'Volunteer contributor')) db.session.add(models.JobType(seq=50, name=u'partner', title=u'Partner for a venture')) db.session.commit() if models.JobCategory.query.count() == 0: print >> sys.stderr, "Adding some job categories" db.session.add(models.JobCategory(seq=10, name=u'programming', title=u'Programming')) db.session.add(models.JobCategory(seq=20, name=u'ux', title=u'Interaction Design')) db.session.add(models.JobCategory(seq=30, name=u'design', title=u'Graphic Design')) db.session.add(models.JobCategory(seq=40, name=u'testing', title=u'Testing')) db.session.add(models.JobCategory(seq=50, name=u'sysadmin', title=u'Systems Administration')) db.session.add(models.JobCategory(seq=60, name=u'business', title=u'Business/Management')) db.session.add(models.JobCategory(seq=70, name=u'edit', title=u'Writer/Editor')) db.session.add(models.JobCategory(seq=80, name=u'support', title=u'Customer Support'))
#!/usr/bin/env python """ Get Twitter access key and secret. """ import tweepy from hasjob import app, init_for init_for('dev') auth = tweepy.OAuthHandler(app.config['TWITTER_CONSUMER_KEY'], app.config['TWITTER_CONSUMER_SECRET']) auth_url = auth.get_authorization_url() print("Please authorize: " + auth_url) # noqa: T001 verifier = input('PIN: ').strip() auth.get_access_token(verifier) print("TWITTER_ACCESS_KEY = '%s'" % auth.access_token.key) # noqa: T001 print("TWITTER_ACCESS_SECRET = '%s'" % auth.access_token.secret) # noqa: T001
def drop(env): "Drops database tables" init_for(env) if prompt_bool("Are you sure you want to lose all your data?"): db.drop_all()
def create(env): "Creates database tables from sqlalchemy models" init_for(env) db.create_all()
def handle(self, *args, **kwargs): if "env" in kwargs: init_for(kwargs.pop("env")) super(InitedServer, self).handle(*args, **kwargs)
def run(self, args): if len(args) and not args[0].startswith("-"): init_for(args[0]) super(InitedMigrations, self).run(args[1:])
import sys import os.path sys.path.insert(0, os.path.dirname(__file__)) from coaster import logging from hasjob import init_for, app as application init_for('prod')
#!/usr/bin/env python # -*- coding: utf-8 -*- from baseframe.staticdata import webmail_domains from hasjob import app, init_for, models from hasjob.models import db if __name__ == '__main__': import sys webmail_domains = set(['gmail.com', 'hotmail.com']) init_for('testing') # Seed with sample data with app.test_request_context(): if not models.JobType.query.notempty(): print >> sys.stderr, "Adding some job types" db.session.add(models.JobType(seq=10, name=u'fulltime', title=u'Full-time employment')) db.session.add(models.JobType(seq=20, name=u'contract', title=u'Short-term contract')) db.session.add(models.JobType(seq=30, name=u'freelance', title=u'Freelance or consulting')) db.session.add(models.JobType(seq=40, name=u'volunteer', title=u'Volunteer contributor')) db.session.add(models.JobType(seq=50, name=u'partner', title=u'Partner for a venture')) db.session.commit() if not models.JobCategory.query.notempty(): print >> sys.stderr, "Adding some job categories" db.session.add(models.JobCategory(seq=10, name=u'programming', title=u'Programming')) db.session.add(models.JobCategory(seq=20, name=u'ux', title=u'Interaction Design')) db.session.add(models.JobCategory(seq=30, name=u'design', title=u'Graphic Design')) db.session.add(models.JobCategory(seq=40, name=u'testing', title=u'Testing')) db.session.add(models.JobCategory(seq=50, name=u'sysadmin', title=u'Systems Administration')) db.session.add(models.JobCategory(seq=60, name=u'business', title=u'Business/Management')) db.session.add(models.JobCategory(seq=70, name=u'edit', title=u'Writer/Editor')) db.session.add(models.JobCategory(seq=80, name=u'support', title=u'Customer Support'))
def create_app(self): app.config['TESTING'] = True db.create_all() init_for('testing') return app
from urlparse import urlparse from hasjob import init_for, app init_for('production') REDIS_URL = app.config.get('REDIS_URL', 'redis://localhost:6379/0') # REDIS_URL is not taken by setup_default_arguments function of rq/scripts/__init__.py # so, parse that into pieces and give it r = urlparse(REDIS_URL) REDIS_HOST = r.hostname REDIS_PORT = r.port REDIS_PASSWORD = r.password REDIS_DB = 0
def create_app(self): app.config["TESTING"] = True db.create_all() init_for("testing") return app
#!/usr/bin/env python # -*- coding: utf-8 -*- from baseframe.staticdata import webmail_domains from hasjob import app, init_for, models from hasjob.models import db if __name__ == '__main__': import sys webmail_domains = set(['gmail.com', 'hotmail.com']) init_for('testing') # Seed with sample data with app.test_request_context(): if not models.JobType.query.notempty(): print >> sys.stderr, "Adding some job types" db.session.add( models.JobType(seq=10, name=u'fulltime', title=u'Full-time employment')) db.session.add( models.JobType(seq=20, name=u'contract', title=u'Short-term contract')) db.session.add( models.JobType(seq=30, name=u'freelance', title=u'Freelance or consulting')) db.session.add( models.JobType(seq=40, name=u'volunteer', title=u'Volunteer contributor'))
def configure(env='dev'): """Configure Hasjob's search indexing""" init_for(env) search_configure()