Skip to content

Commit

Permalink
fix #392
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-satish committed May 4, 2017
1 parent 0974817 commit 77133dd
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 40 deletions.
52 changes: 25 additions & 27 deletions hasjob/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,33 @@
from . import models, views # NOQA
from .models import db # NOQA


# Configure the app
def init_for(env):
coaster.app.init_app(app, env)
db.init_app(app)
db.app = app
coaster.app.init_app(app)
db.init_app(app)
db.app = app

app.geoip = None
if 'GEOIP_PATH' in app.config:
if not os.path.exists(app.config['GEOIP_PATH']):
app.logger.warn("GeoIP database missing at " + app.config['GEOIP_PATH'])
else:
app.geoip = geoip2.database.Reader(app.config['GEOIP_PATH'])
app.geoip = None
if 'GEOIP_PATH' in app.config:
if not os.path.exists(app.config['GEOIP_PATH']):
app.logger.warn("GeoIP database missing at " + app.config['GEOIP_PATH'])
else:
app.geoip = geoip2.database.Reader(app.config['GEOIP_PATH'])

RQ(app)
RQ(app)

baseframe.init_app(app, requires=['hasjob'],
ext_requires=['baseframe-bs3',
('jquery.autosize', 'jquery.sparkline', 'jquery.liblink', 'jquery.wnumb', 'jquery.nouislider'),
'baseframe-firasans', 'fontawesome>=4.3.0', 'bootstrap-multiselect', 'nprogress', 'ractive',
'jquery.appear', 'hammer'])
# TinyMCE has to be loaded by itself, unminified, or it won't be able to find its assets
app.assets.register('js_tinymce', assets.require('!jquery.js', 'tinymce.js>=4.0.0', 'jquery.tinymce.js>=4.0.0'))
app.assets.register('css_editor', Bundle('css/editor.css',
filters=['cssrewrite', 'cssmin'], output='css/editor.packed.css'))
baseframe.init_app(app, requires=['hasjob'],
ext_requires=['baseframe-bs3',
('jquery.autosize', 'jquery.sparkline', 'jquery.liblink', 'jquery.wnumb', 'jquery.nouislider'),
'baseframe-firasans', 'fontawesome>=4.3.0', 'bootstrap-multiselect', 'nprogress', 'ractive',
'jquery.appear', 'hammer'])
# TinyMCE has to be loaded by itself, unminified, or it won't be able to find its assets
app.assets.register('js_tinymce', assets.require('!jquery.js', 'tinymce.js>=4.0.0', 'jquery.tinymce.js>=4.0.0'))
app.assets.register('css_editor', Bundle('css/editor.css',
filters=['cssrewrite', 'cssmin'], output='css/editor.packed.css'))

from hasjob.uploads import configure as uploads_configure
uploads_configure()
mail.init_app(app)
redis_store.init_app(app)
lastuser.init_app(app)
lastuser.init_usermanager(UserManager(db, models.User))
from hasjob.uploads import configure as uploads_configure
uploads_configure()
mail.init_app(app)
redis_store.init_app(app)
lastuser.init_app(app)
lastuser.init_usermanager(UserManager(db, models.User))
5 changes: 2 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import hasjob.forms as forms
import hasjob.views as views
from hasjob.models import db
from hasjob import app, init_for
from hasjob import app
from datetime import datetime, timedelta

periodic = Manager(usage="Periodic tasks from cron (with recommended intervals)")
Expand All @@ -16,7 +16,6 @@
@periodic.option('-e', '--env', default='dev', help="runtime env [default 'dev']")
def sessions(env):
"""Sweep user sessions to close all inactive sessions (10m)"""
manager.init_for(env)
es = models.EventSession
# Close all sessions that have been inactive for >= 30 minutes
es.query.filter(es.ended_at == None, # NOQA
Expand All @@ -41,6 +40,6 @@ def impressions(env):

if __name__ == '__main__':
db.init_app(app)
manager = init_manager(app, db, init_for, hasjob=hasjob, models=models, forms=forms, views=views)
manager = init_manager(app, db, hasjob=hasjob, models=models, forms=forms, views=views)
manager.add_command('periodic', periodic)
manager.run()
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ langid>=1.1.4dev
tldextract
unicodecsv
geoip2
Flask-Script==0.5.3
git+https://github.com/hasgeek/coaster
git+https://github.com/hasgeek/flask-lastuser
git+https://github.com/hasgeek/baseframe
git+https://github.com/jace/flask-alembic
2 changes: 1 addition & 1 deletion rq.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

rqworker -c rqdev hasjob
rqworker -c rqinit hasjob
3 changes: 1 addition & 2 deletions rqinit.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from urlparse import urlparse

from hasjob import init_for, app
from hasjob import 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
Expand Down
5 changes: 2 additions & 3 deletions runserver.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from hasjob import app, init_for, models
from hasjob import app, models
from hasjob.models import db

if __name__ == '__main__':

import sys
init_for('dev')
# Seed with sample data
with app.test_request_context():
if not models.JobType.query.notempty():
Expand Down Expand Up @@ -36,4 +35,4 @@
db.session.add(models.ReportCode(seq=30, name=u'anon', title=u'Organization is not clearly identified'))
db.session.add(models.ReportCode(seq=40, name=u'unclear', title=u'Job position is not properly described'))
db.session.commit()
app.run('0.0.0.0', debug=True)
app.run('0.0.0.0', debug=True, port=5000)
3 changes: 1 addition & 2 deletions runtestserver.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from baseframe.staticdata import webmail_domains
from hasjob import app, init_for, models
from hasjob import app, 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():
Expand Down

0 comments on commit 77133dd

Please sign in to comment.