From 115b50bb9b30943ac8c85e374e69443c6f669c2f Mon Sep 17 00:00:00 2001 From: David Lenwell Date: Mon, 16 Sep 2013 10:39:36 -0700 Subject: [PATCH] more refinement --- .../40d4c6d389ec_adding_cloud_and_use.py | 44 +++++++++---------- refstack.wsgi | 2 +- refstack/app.py | 20 ++++----- refstack/models.py | 3 ++ refstack/runserver.py | 6 ++- refstack/web.py | 20 ++++----- 6 files changed, 48 insertions(+), 47 deletions(-) diff --git a/alembic/versions/40d4c6d389ec_adding_cloud_and_use.py b/alembic/versions/40d4c6d389ec_adding_cloud_and_use.py index 3addd0f4..ef66b9de 100755 --- a/alembic/versions/40d4c6d389ec_adding_cloud_and_use.py +++ b/alembic/versions/40d4c6d389ec_adding_cloud_and_use.py @@ -17,30 +17,30 @@ import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('user', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(length=60), nullable=True), - sa.Column('email', sa.String(length=200), nullable=True), - sa.Column('openid', sa.String(length=200), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('openid') + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=60), nullable=True), + sa.Column('email', sa.String(length=200), nullable=True), + sa.Column('openid', sa.String(length=200), nullable=True), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('openid') ) op.create_table('cloud', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('vendor_id', sa.Integer(), nullable=True), - sa.Column('endpoint', sa.String(length=120), nullable=True), - sa.Column('test_user', sa.String(length=80), nullable=True), - sa.Column('test_key', sa.String(length=80), nullable=True), - sa.Column('admin_endpoint', sa.String(length=120), nullable=True), - sa.Column('admin_user', sa.String(length=80), nullable=True), - sa.Column('admin_key', sa.String(length=80), nullable=True), - sa.ForeignKeyConstraint(['vendor_id'], ['vendor.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('admin_endpoint'), - sa.UniqueConstraint('admin_key'), - sa.UniqueConstraint('admin_user'), - sa.UniqueConstraint('endpoint'), - sa.UniqueConstraint('test_key'), - sa.UniqueConstraint('test_user') + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('vendor_id', sa.Integer(), nullable=True), + sa.Column('endpoint', sa.String(length=120), nullable=True), + sa.Column('test_user', sa.String(length=80), nullable=True), + sa.Column('test_key', sa.String(length=80), nullable=True), + sa.Column('admin_endpoint', sa.String(length=120), nullable=True), + sa.Column('admin_user', sa.String(length=80), nullable=True), + sa.Column('admin_key', sa.String(length=80), nullable=True), + sa.ForeignKeyConstraint(['vendor_id'], ['vendor.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('admin_endpoint'), + sa.UniqueConstraint('admin_key'), + sa.UniqueConstraint('admin_user'), + sa.UniqueConstraint('endpoint'), + sa.UniqueConstraint('test_key'), + sa.UniqueConstraint('test_user') ) ### end Alembic commands ### diff --git a/refstack.wsgi b/refstack.wsgi index 6baf4881..7556fad3 100755 --- a/refstack.wsgi +++ b/refstack.wsgi @@ -17,4 +17,4 @@ import os # os.environ['YOURAPPLICATION_CONFIG'] = '/var/www/yourapplication/application.cfg' -from refstack import web \ No newline at end of file +from refstack.app import app diff --git a/refstack/app.py b/refstack/app.py index f767e88f..677f625d 100755 --- a/refstack/app.py +++ b/refstack/app.py @@ -14,17 +14,17 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import os +from flask import Flask, session +db_path = os.path.abspath( + os.path.join(os.path.basename(__file__), "../")) app = Flask(__name__) -app.config['MAILGUN_KEY'] = 'key-7o9l9dupikfpsdvqi0ewot-se8g1hz64' -app.config['MAILGUN_DOMAIN'] = 'hastwoparents.com' - - -app.config['SECRET_KEY'] = 'GIANT_UGLY-SECRET-GOES-H3r3' -db_path = os.path.abspath( - os.path.join(os.path.basename(__file__), "../")) +app.config['MAILGUN_KEY'] = '#@#@#@#@' +app.config['MAILGUN_DOMAIN'] = 'refstack.org' +app.config['SECRET_KEY'] = '#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@' app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get( 'DATABASE_URL', 'sqlite:///%s/refstack.db' % (db_path)) app.config['DEBUG'] = True @@ -33,9 +33,9 @@ app.config['SECURITY_PASSWORD_SALT'] = app.config['SECRET_KEY'] app.config['SECURITY_POST_LOGIN_VIEW'] = 'dashboard' app.config['SECURITY_RECOVERABLE'] = True app.config['SECURITY_REGISTERABLE'] = True -app.config['SECURITY_EMAIL_SENDER'] = "admin@hastwoparents.com" -app.config['MAIL_SERVER'] = 'smtp.mailgun.org' +app.config['SECURITY_EMAIL_SENDER'] = "refstack.org" +app.config['MAIL_SERVER'] = 'smtp.refstack.org' app.config['MAIL_PORT'] = 465 app.config['MAIL_USE_SSL'] = True -app.config['MAIL_USERNAME'] = 'postmaster@hastwoparents.com' +app.config['MAIL_USERNAME'] = 'postmaster@refstack.org' app.config['MAIL_PASSWORD'] = '1234' diff --git a/refstack/models.py b/refstack/models.py index 20d5e614..d81bbad2 100755 --- a/refstack/models.py +++ b/refstack/models.py @@ -16,6 +16,9 @@ # under the License. from flask.ext.sqlalchemy import SQLAlchemy from sqlalchemy.exc import IntegrityError +from app import app + +db = SQLAlchemy(app) class Vendor(db.Model): diff --git a/refstack/runserver.py b/refstack/runserver.py index 0adb37e9..6ab289d3 100755 --- a/refstack/runserver.py +++ b/refstack/runserver.py @@ -14,7 +14,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - +import os from web import app -app.run() \ No newline at end of file +app.logger.setLevel('DEBUG') +port = int(os.environ.get('PORT', 5000)) +app.run(host='172.16.200.128', port=port, debug=True) \ No newline at end of file diff --git a/refstack/web.py b/refstack/web.py index 97613721..d8ca8d35 100755 --- a/refstack/web.py +++ b/refstack/web.py @@ -14,11 +14,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Simple Refstack website. -""" - import os +import requests from flask import Flask, abort, flash, request, redirect, url_for, \ render_template, g, session from flask_openid import OpenID @@ -29,19 +26,21 @@ from flask.ext.security import Security, SQLAlchemyUserDatastore, \ from wtforms import Form, BooleanField, TextField, \ PasswordField, validators from flask_mail import Mail -import requests -from app inport app + +from app import app +from models import Vendor, Cloud, User, db mail = Mail(app) # setup flask-openid oid = OpenID(app) -db = SQLAlchemy(app) admin = Admin(app) class SecureView(ModelView): + """ """ def is_accessible(self): + """ """ return g.user is not None admin.add_view(SecureView(Vendor, db.session)) @@ -150,13 +149,10 @@ def edit_profile(): @app.route('/logout') def logout(): - """""" + """logout route""" session.pop('openid', None) flash(u'You have been signed out') return redirect(oid.get_next_url()) -if __name__ == '__main__': - app.logger.setLevel('DEBUG') - port = int(os.environ.get('PORT', 5000)) - app.run(host='0.0.0.0', port=port, debug=True) +