general house cleaning and repair of web.py imports

Change-Id: Ia8cc89b5220b51bce8ccfe09f7c459d4dac3bf6b
This commit is contained in:
david 2014-03-01 20:06:30 -08:00
parent 13ecce15f5
commit 4c2650da57
5 changed files with 32 additions and 31 deletions

2
.gitignore vendored
View File

@ -51,4 +51,6 @@ scripts/members_sponsors_20131030.csv
refstack/client/.smbdeleteAAA9ef44.4
openid/*
db.sqlite

View File

@ -13,7 +13,7 @@ Okay, I'm Sold, How Do I Run This Myself?
This is our documentation for how we get this set up::
# Git you clonin'
git clone http://github.com/openstack-ops/refstack
git clone http://github.com/stackforge/refstack
cd refstack
@ -22,15 +22,15 @@ This is our documentation for how we get this set up::
# `alembic.ini` to get this working
# PROTIP: if you just want to test this out, use `-n alembic_sqlite` to
# make a local sqlite db
# $ alembic -n alembic_sqlite update head
alembic update head
# $ alembic -n alembic_sqlite upgrade head
alembic upgrade head
# Plug this bad boy into your server infrastructure.
# We use nginx and gunicorn, you may use something else if you are smarter
# than we are.
# For the most basic setup that you can try right now, just kick off
# 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
# crack open refstack.cfg in vim.

18
refstack/extensions.py Normal file → Executable file
View File

@ -1,6 +1,18 @@
# -*- coding: utf-8 -*-
# This file based on MIT licensed code at: https://github.com/imwilsonxu/fbone
#
# Copyright (c) 2013 Piston Cloud Computing, Inc.
# 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
admin = Admin()

View File

@ -0,0 +1 @@
page not found

View File

@ -13,41 +13,27 @@
# License for the specific language governing permissions and limitations
# 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.extensions import db
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 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()
mail = Mail(app)
@app.before_request
def before_request():
"""Runs before the request itself."""
flask.g.user = None
g.user = None
if 'openid' in session:
flask.g.user = User.query.filter_by(openid=session['openid']).first()
@ -57,7 +43,7 @@ def index():
"""Index view."""
if g.user is not None:
# 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)
else:
vendors = Vendor.query.all()
@ -123,7 +109,7 @@ def create_profile():
@app.route('/delete-cloud/<int:cloud_id>', methods=['GET', 'POST'])
def delete_cloud(cloud_id):
"""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:
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'])
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:
flash(u'Not a valid Cloud ID!')
@ -209,7 +195,7 @@ def create_cloud():
elif not request.form['admin_key']:
flash(u'Error: All fields are required')
else:
c = db.Cloud()
c = Cloud()
c.user_id = g.user.id
c.label = request.form['label']
c.endpoint = request.form['endpoint']