Added Tenant model

This commit is contained in:
Jarret Raim 2013-02-17 14:58:14 -06:00
parent aeaae4fbdc
commit 6eb2e0f651
3 changed files with 21 additions and 2 deletions

View File

@ -20,7 +20,7 @@ from flask.ext import login, wtf
from flask.ext.login import login_user
from barbican_api import api
from database import db_session, init_db
from models import User
from models import User, Tenant
app = Flask(__name__)
@ -29,6 +29,7 @@ app.register_blueprint(api)
admin = Admin(app, name="Barbican Admin")
admin.add_view(ModelView(User, db_session))
admin.add_view(ModelView(Tenant, db_session))
login_manager = login.LoginManager()
login_manager.init_app(app)
@ -38,7 +39,7 @@ login_manager.login_view = 'login'
@app.route("/")
@login.login_required
def hello():
return "Hello world!"
return render_template("index.html")
#

View File

@ -8,6 +8,7 @@
:copyright: (c) 2013 by Jarret Raim
:license: Apache 2.0, see LICENSE for details
"""
from uuid import uuid4
from sqlalchemy import Column, Integer, String
from database import Base
@ -38,3 +39,16 @@ class User(Base):
def __repr__(self):
return '<User %r>' % self.name
class Tenant(Base):
__tablename__ = 'tenants'
id = Column(Integer, primary_key=True)
uuid = Column(String(36), unique=True)
def __init__(self, uuid=None):
if uuid is None:
self.uuid = str(uuid4())
def __repr__(self):
return '<Tenant %s>' % self.uuid

4
templates/index.html Normal file
View File

@ -0,0 +1,4 @@
{% extends 'layout.html' %}
{% block body %}
{% endblock %}