Skip to content

Instantly share code, notes, and snippets.

@Porter97
Last active March 26, 2020 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Porter97/1ebb9ed6dd8853296e69a2d820db8d1e to your computer and use it in GitHub Desktop.
Save Porter97/1ebb9ed6dd8853296e69a2d820db8d1e to your computer and use it in GitHub Desktop.
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