Merge "general house cleaning and repair of web.py imports"
This commit is contained in:
commit
081f91c398
2
.gitignore
vendored
2
.gitignore
vendored
@ -51,4 +51,6 @@ scripts/members_sponsors_20131030.csv
|
|||||||
|
|
||||||
refstack/client/.smbdeleteAAA9ef44.4
|
refstack/client/.smbdeleteAAA9ef44.4
|
||||||
|
|
||||||
|
openid/*
|
||||||
|
|
||||||
db.sqlite
|
db.sqlite
|
||||||
|
@ -21,15 +21,15 @@ This is our documentation for how we get this set up::
|
|||||||
# `alembic.ini` to get this working
|
# `alembic.ini` to get this working
|
||||||
# PROTIP: if you just want to test this out, use `-n alembic_sqlite` to
|
# PROTIP: if you just want to test this out, use `-n alembic_sqlite` to
|
||||||
# make a local sqlite db
|
# make a local sqlite db
|
||||||
# $ alembic -n alembic_sqlite update head
|
# $ alembic -n alembic_sqlite upgrade head
|
||||||
alembic update head
|
alembic upgrade head
|
||||||
|
|
||||||
# Plug this bad boy into your server infrastructure.
|
# Plug this bad boy into your server infrastructure.
|
||||||
# We use nginx and gunicorn, you may use something else if you are smarter
|
# We use nginx and gunicorn, you may use something else if you are smarter
|
||||||
# than we are.
|
# than we are.
|
||||||
# For the most basic setup that you can try right now, just kick off
|
# For the most basic setup that you can try right now, just kick off
|
||||||
# gunicorn:
|
# gunicorn:
|
||||||
gunicorn refstack.web:app
|
gunicorn -b 0.0.0.0:8000 refstack.web:app
|
||||||
|
|
||||||
# To actually configure this winner, check out the config section and
|
# To actually configure this winner, check out the config section and
|
||||||
# crack open refstack.cfg in vim.
|
# crack open refstack.cfg in vim.
|
||||||
|
18
refstack/extensions.py
Normal file → Executable file
18
refstack/extensions.py
Normal file → Executable file
@ -1,6 +1,18 @@
|
|||||||
# -*- coding: utf-8 -*-
|
#
|
||||||
|
# Copyright (c) 2013 Piston Cloud Computing, Inc.
|
||||||
# This file based on MIT licensed code at: https://github.com/imwilsonxu/fbone
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
from flask.ext.admin import Admin
|
from flask.ext.admin import Admin
|
||||||
admin = Admin()
|
admin = Admin()
|
||||||
|
1
refstack/templates/errors/page_not_found.html
Normal file
1
refstack/templates/errors/page_not_found.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
page not found
|
@ -13,41 +13,27 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
from flask import abort, flash, request, redirect, url_for, \
|
|
||||||
render_template, g, session, flask
|
|
||||||
#from flask_openid import OpenID
|
|
||||||
#from flask.ext.admin import Admin, BaseView, expose, AdminIndexView
|
|
||||||
#from flask.ext.admin.contrib.sqlamodel import ModelView
|
|
||||||
#from flask.ext.security import Security, \
|
|
||||||
# UserMixin, login_required
|
|
||||||
#from wtforms import TextField
|
|
||||||
from flask_mail import Mail
|
|
||||||
|
|
||||||
|
import flask
|
||||||
|
from flask import abort, flash, request, redirect, url_for, \
|
||||||
|
render_template, g, session
|
||||||
|
from flask_mail import Mail
|
||||||
from refstack import app as base_app
|
from refstack import app as base_app
|
||||||
from refstack.extensions import db
|
from refstack.extensions import db
|
||||||
from refstack.extensions import oid
|
from refstack.extensions import oid
|
||||||
#from refstack import api
|
|
||||||
#from refstack.models import ApiKey
|
|
||||||
#from refstack.models import Cloud
|
|
||||||
#from refstack.models import Test
|
|
||||||
#from refstack.models import TestResults
|
|
||||||
#from refstack.models import TestStatus
|
|
||||||
from refstack.models import User
|
from refstack.models import User
|
||||||
from refstack.models import Vendor
|
from refstack.models import Vendor
|
||||||
|
from refstack.models import Cloud
|
||||||
|
|
||||||
|
|
||||||
# TODO(termie): transition all the routes below to blueprints
|
|
||||||
# TODO(termie): use extensions setup from the create_app() call
|
|
||||||
|
|
||||||
app = base_app.create_app()
|
app = base_app.create_app()
|
||||||
|
|
||||||
mail = Mail(app)
|
mail = Mail(app)
|
||||||
|
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def before_request():
|
def before_request():
|
||||||
"""Runs before the request itself."""
|
"""Runs before the request itself."""
|
||||||
flask.g.user = None
|
g.user = None
|
||||||
if 'openid' in session:
|
if 'openid' in session:
|
||||||
flask.g.user = User.query.filter_by(openid=session['openid']).first()
|
flask.g.user = User.query.filter_by(openid=session['openid']).first()
|
||||||
|
|
||||||
@ -57,7 +43,7 @@ def index():
|
|||||||
"""Index view."""
|
"""Index view."""
|
||||||
if g.user is not None:
|
if g.user is not None:
|
||||||
# something else
|
# something else
|
||||||
clouds = db.Cloud.query.filter_by(user_id=g.user.id).all()
|
clouds = Cloud.query.filter_by(user_id=g.user.id).all()
|
||||||
return render_template('home.html', clouds=clouds)
|
return render_template('home.html', clouds=clouds)
|
||||||
else:
|
else:
|
||||||
vendors = Vendor.query.all()
|
vendors = Vendor.query.all()
|
||||||
@ -123,7 +109,7 @@ def create_profile():
|
|||||||
@app.route('/delete-cloud/<int:cloud_id>', methods=['GET', 'POST'])
|
@app.route('/delete-cloud/<int:cloud_id>', methods=['GET', 'POST'])
|
||||||
def delete_cloud(cloud_id):
|
def delete_cloud(cloud_id):
|
||||||
"""Delete function for clouds."""
|
"""Delete function for clouds."""
|
||||||
c = db.Cloud.query.filter_by(id=cloud_id).first()
|
c = Cloud.query.filter_by(id=cloud_id).first()
|
||||||
|
|
||||||
if not c:
|
if not c:
|
||||||
flash(u'Not a valid Cloud ID!')
|
flash(u'Not a valid Cloud ID!')
|
||||||
@ -138,7 +124,7 @@ def delete_cloud(cloud_id):
|
|||||||
|
|
||||||
@app.route('/edit-cloud/<int:cloud_id>', methods=['GET', 'POST'])
|
@app.route('/edit-cloud/<int:cloud_id>', methods=['GET', 'POST'])
|
||||||
def edit_cloud(cloud_id):
|
def edit_cloud(cloud_id):
|
||||||
c = db.Cloud.query.filter_by(id=cloud_id).first()
|
c = Cloud.query.filter_by(id=cloud_id).first()
|
||||||
|
|
||||||
if not c:
|
if not c:
|
||||||
flash(u'Not a valid Cloud ID!')
|
flash(u'Not a valid Cloud ID!')
|
||||||
@ -209,7 +195,7 @@ def create_cloud():
|
|||||||
elif not request.form['admin_key']:
|
elif not request.form['admin_key']:
|
||||||
flash(u'Error: All fields are required')
|
flash(u'Error: All fields are required')
|
||||||
else:
|
else:
|
||||||
c = db.Cloud()
|
c = Cloud()
|
||||||
c.user_id = g.user.id
|
c.user_id = g.user.id
|
||||||
c.label = request.form['label']
|
c.label = request.form['label']
|
||||||
c.endpoint = request.form['endpoint']
|
c.endpoint = request.form['endpoint']
|
||||||
|
Loading…
Reference in New Issue
Block a user