Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Fix #204 (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
jace authored May 4, 2017
1 parent 0788787 commit 5b63aa0
Showing 12 changed files with 52 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ before_script:
- psql -c 'create database lastuser_test_app;' -U postgres

script:
- nosetests --with-timer
- ./runtests.sh

notifications:
email: false
3 changes: 3 additions & 0 deletions instance/settings-sample.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
from flask import Markup

#: Debug mode (put this value in development.py only, never in settings.py)
DEBUG = True

#: The title of this site
SITE_TITLE = 'Lastuser'

73 changes: 36 additions & 37 deletions lastuserapp/__init__.py
Original file line number Diff line number Diff line change
@@ -26,42 +26,41 @@
assets['lastuser-oauth.js'][version] = lastuser_oauth.lastuser_oauth_js,
assets['lastuser-oauth.css'][version] = lastuser_oauth.lastuser_oauth_css

# Configure the app
coaster.app.init_app(app)
db.init_app(app)
db.app = app # To make it work without an app context
RQ(app) # Pick up RQ configuration from the app
baseframe.init_app(app, requires=['lastuser-oauth'],
ext_requires=['baseframe-bs3', 'fontawesome>=4.0.0', 'jquery.cookie', 'timezone'])

def init_for(env):
coaster.app.init_app(app, env)
db.init_app(app)
db.app = app # To make it work without an app context
RQ(app) # Pick up RQ configuration from the app
baseframe.init_app(app, requires=['lastuser-oauth'],
ext_requires=['baseframe-bs3', 'fontawesome>=4.0.0', 'jquery.cookie', 'timezone'])
lastuser_oauth.lastuser_oauth.init_app(app)
lastuser_oauth.mailclient.mail.init_app(app)
lastuser_oauth.views.login.oid.init_app(app)

lastuser_oauth.lastuser_oauth.init_app(app)
lastuser_oauth.mailclient.mail.init_app(app)
lastuser_oauth.views.login.oid.init_app(app)

# Register some login providers
if app.config.get('OAUTH_TWITTER_KEY') and app.config.get('OAUTH_TWITTER_SECRET'):
login_registry['twitter'] = providers.TwitterProvider('twitter', 'Twitter',
at_login=True, priority=True, icon='twitter',
key=app.config['OAUTH_TWITTER_KEY'],
secret=app.config['OAUTH_TWITTER_SECRET'],
access_key=app.config.get('OAUTH_TWITTER_ACCESS_KEY'),
access_secret=app.config.get('OAUTH_TWITTER_ACCESS_SECRET'))
if app.config.get('OAUTH_GOOGLE_KEY') and app.config.get('OAUTH_GOOGLE_SECRET'):
login_registry['google'] = providers.GoogleProvider('google', 'Google',
client_id=app.config['OAUTH_GOOGLE_KEY'],
secret=app.config['OAUTH_GOOGLE_SECRET'],
scope=app.config.get('OAUTH_GOOGLE_SCOPE', ['email', 'profile']),
at_login=True, priority=True, icon='google')
if app.config.get('OAUTH_LINKEDIN_KEY') and app.config.get('OAUTH_LINKEDIN_SECRET'):
login_registry['linkedin'] = providers.LinkedInProvider('linkedin', 'LinkedIn',
at_login=True, priority=False, icon='linkedin',
key=app.config['OAUTH_LINKEDIN_KEY'],
secret=app.config['OAUTH_LINKEDIN_SECRET'])
if app.config.get('OAUTH_GITHUB_KEY') and app.config.get('OAUTH_GITHUB_SECRET'):
login_registry['github'] = providers.GitHubProvider('github', 'GitHub',
at_login=True, priority=False, icon='github',
key=app.config['OAUTH_GITHUB_KEY'],
secret=app.config['OAUTH_GITHUB_SECRET'])
login_registry['openid'] = providers.OpenIdProvider('openid', 'OpenID',
at_login=True, priority=False, icon='openid')
# Register some login providers
if app.config.get('OAUTH_TWITTER_KEY') and app.config.get('OAUTH_TWITTER_SECRET'):
login_registry['twitter'] = providers.TwitterProvider('twitter', 'Twitter',
at_login=True, priority=True, icon='twitter',
key=app.config['OAUTH_TWITTER_KEY'],
secret=app.config['OAUTH_TWITTER_SECRET'],
access_key=app.config.get('OAUTH_TWITTER_ACCESS_KEY'),
access_secret=app.config.get('OAUTH_TWITTER_ACCESS_SECRET'))
if app.config.get('OAUTH_GOOGLE_KEY') and app.config.get('OAUTH_GOOGLE_SECRET'):
login_registry['google'] = providers.GoogleProvider('google', 'Google',
client_id=app.config['OAUTH_GOOGLE_KEY'],
secret=app.config['OAUTH_GOOGLE_SECRET'],
scope=app.config.get('OAUTH_GOOGLE_SCOPE', ['email', 'profile']),
at_login=True, priority=True, icon='google')
if app.config.get('OAUTH_LINKEDIN_KEY') and app.config.get('OAUTH_LINKEDIN_SECRET'):
login_registry['linkedin'] = providers.LinkedInProvider('linkedin', 'LinkedIn',
at_login=True, priority=False, icon='linkedin',
key=app.config['OAUTH_LINKEDIN_KEY'],
secret=app.config['OAUTH_LINKEDIN_SECRET'])
if app.config.get('OAUTH_GITHUB_KEY') and app.config.get('OAUTH_GITHUB_SECRET'):
login_registry['github'] = providers.GitHubProvider('github', 'GitHub',
at_login=True, priority=False, icon='github',
key=app.config['OAUTH_GITHUB_KEY'],
secret=app.config['OAUTH_GITHUB_SECRET'])
login_registry['openid'] = providers.OpenIdProvider('openid', 'OpenID',
at_login=True, priority=False, icon='openid')
4 changes: 2 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
@@ -8,10 +8,10 @@
import lastuserapp
import lastuser_core.models as models
from lastuser_core.models import db
from lastuserapp import app, init_for
from lastuserapp import app


if __name__ == '__main__':
db.init_app(app)
manager = init_manager(app, db, init_for, lastuser_core=lastuser_core, lastuser_oauth=lastuser_oauth, lastuser_ui=lastuser_ui, lastuserapp=lastuserapp, models=models)
manager = init_manager(app, db, lastuser_core=lastuser_core, lastuser_oauth=lastuser_oauth, lastuser_ui=lastuser_ui, lastuserapp=lastuserapp, models=models)
manager.run()
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ Flask-WTF
requests
blinker
Flask-RQ
Flask-Script==0.5.3
tweepy
unicodecsv
oauth2client
@@ -25,4 +24,3 @@ itsdangerous
psycopg2
git+https://github.com/hasgeek/coaster
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 lastuser
rqworker -c rqinit lastuser
15 changes: 0 additions & 15 deletions rqdev.py

This file was deleted.

3 changes: 1 addition & 2 deletions rqinit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from urlparse import urlparse
from lastuserapp import init_for, app
from lastuserapp 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
5 changes: 2 additions & 3 deletions runserver.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
reload(sys)
sys.setdefaultencoding('utf-8')

from lastuserapp import app, init_for
from lastuserapp import app

init_for('dev')
app.run('0.0.0.0', 7000, debug=True)
app.run('0.0.0.0', 7000)
4 changes: 4 additions & 0 deletions runtests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
export FLASK_ENV="TESTING"
coverage run `which nosetests --with-timer`
coverage report
3 changes: 1 addition & 2 deletions runtestserver.py
Original file line number Diff line number Diff line change
@@ -4,10 +4,9 @@
reload(sys)
sys.setdefaultencoding('utf-8')

from lastuserapp import app, init_for, db
from lastuserapp import app, db
from lastuser_core.models import *

init_for('testing')
#incase data exists from previously run tests
db.drop_all()
#create schema again
3 changes: 1 addition & 2 deletions website.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
import os.path
sys.path.insert(0, os.path.dirname(__file__))
from lastuserapp import app as application, init_for
init_for('production')
from lastuserapp import app as application

0 comments on commit 5b63aa0

Please sign in to comment.