Last active
March 26, 2020 14:12
-
-
Save Porter97/1ebb9ed6dd8853296e69a2d820db8d1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask_migrate import Migrate, upgrade | |
from app import create_app, db | |
from app.models import User, Role, Permission, Content, Collection | |
app = create_app(os.getenv('FLASK_CONFIG') or 'default') | |
migrate = Migrate(app, db) | |
@app.shell_context_processor | |
def make_shell_context(): | |
return dict(db=db, User=User, Role=Role, | |
Permission=Permission, Content=Content, | |
Collection=Collection) | |
@app.cli.command() | |
def test(): | |
"""Run the unit tests.""" | |
import unittest | |
tests = unittest.TestLoader().discover('tests') | |
unittest.TextTestRunner(verbosity=2).run(tests) | |
@app.cli.command() | |
def deploy(): | |
"""Run deployment tasks.""" | |
# migrate database to latest revision | |
upgrade() | |
# create or update user roles | |
Role.insert_roles() | |
# ensure all users are following themselves | |
User.add_self_follows() | |
# ensure all users are following their collections | |
User.add_self_collection_follows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment