diff --git a/app/app.py b/app/app.py index 8844f8e..31bbd51 100644 --- a/app/app.py +++ b/app/app.py @@ -9,7 +9,7 @@ from flask_debugtoolbar import DebugToolbarExtension from flask_login import LoginManager from flask_migrate import Migrate, MigrateCommand from flask_oauthlib.client import OAuth, OAuthException -from flask_script import Manager +from flask_script import Manager, Server from admin import init_admin from login import init_login @@ -31,7 +31,7 @@ def create_app(): add_template_filters(app) # TODO do we need to return and then run the manager? - return app + return manager def register_plugins(app, debug: bool): @@ -66,6 +66,7 @@ def register_plugins(app, debug: bool): migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) + manager.add_command('runserver', Server(port=8000)) # Add admin interface init_admin(app, db) @@ -144,5 +145,6 @@ def add_template_filters(app): # For usage when you directly call the script with python if __name__ == '__main__': - app = create_app() - app.run(threaded=True, host='0.0.0.0') + manager = create_app() + manager.run() + #app.run(threaded=True, host='0.0.0.0') diff --git a/app/migrations/versions/old_migrations/2d696203e56_.py b/app/migrations/versions/old_migrations/2d696203e56_.py deleted file mode 100644 index 2067c81..0000000 --- a/app/migrations/versions/old_migrations/2d696203e56_.py +++ /dev/null @@ -1,54 +0,0 @@ -"""Make it possible for some columns to be null - -Revision ID: 2d696203e56 -Revises: 354676f60be -Create Date: 2015-06-04 17:25:39.119678 - -""" - -# revision identifiers, used by Alembic. -revision = '2d696203e56' -down_revision = '354676f60be' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.alter_column('location', 'name', - existing_type=sa.VARCHAR(length=120), - nullable=False) - op.alter_column('order_item', 'order_id', - existing_type=sa.INTEGER(), - nullable=False) - op.alter_column('product', 'name', - existing_type=sa.VARCHAR(length=120), - nullable=False) - op.alter_column('product', 'price', - existing_type=sa.INTEGER(), - nullable=False) - op.alter_column('user', 'username', - existing_type=sa.VARCHAR(length=80), - nullable=False) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.alter_column('user', 'username', - existing_type=sa.VARCHAR(length=80), - nullable=True) - op.alter_column('product', 'price', - existing_type=sa.INTEGER(), - nullable=True) - op.alter_column('product', 'name', - existing_type=sa.VARCHAR(length=120), - nullable=True) - op.alter_column('order_item', 'order_id', - existing_type=sa.INTEGER(), - nullable=True) - op.alter_column('location', 'name', - existing_type=sa.VARCHAR(length=120), - nullable=True) - ### end Alembic commands ### diff --git a/app/migrations/versions/old_migrations/3243c3538fc_.py b/app/migrations/versions/old_migrations/3243c3538fc_.py deleted file mode 100644 index 3d8f9c2..0000000 --- a/app/migrations/versions/old_migrations/3243c3538fc_.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Add telephone number - -Revision ID: 3243c3538fc -Revises: 2d696203e56 -Create Date: 2015-06-04 18:39:54.895177 - -""" - -# revision identifiers, used by Alembic. -revision = '3243c3538fc' -down_revision = '2d696203e56' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.add_column('location', sa.Column('telephone', sa.String(length=20), nullable=True)) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_column('location', 'telephone') - ### end Alembic commands ### diff --git a/app/migrations/versions/old_migrations/354676f60be_.py b/app/migrations/versions/old_migrations/354676f60be_.py deleted file mode 100644 index 34d8e13..0000000 --- a/app/migrations/versions/old_migrations/354676f60be_.py +++ /dev/null @@ -1,74 +0,0 @@ -"""Initial configuration - -Revision ID: 354676f60be -Revises: None -Create Date: 2015-06-04 17:17:28.933840 - -""" - -# revision identifiers, used by Alembic. -revision = '354676f60be' -down_revision = None - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.create_table('location', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(length=120), nullable=True), - sa.Column('address', sa.String(length=254), nullable=True), - sa.Column('website', sa.String(length=120), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('user', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('username', sa.String(length=80), nullable=True), - sa.Column('admin', sa.Boolean(), nullable=True), - sa.Column('bias', sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('username') - ) - op.create_table('product', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('location_id', sa.Integer(), nullable=True), - sa.Column('name', sa.String(length=120), nullable=True), - sa.Column('price', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['location_id'], ['location.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('order', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('courrier_id', sa.Integer(), nullable=True), - sa.Column('location_id', sa.Integer(), nullable=True), - sa.Column('starttime', sa.DateTime(), nullable=True), - sa.Column('stoptime', sa.DateTime(), nullable=True), - sa.Column('public', sa.Boolean(), nullable=True), - sa.ForeignKeyConstraint(['courrier_id'], ['user.id'], ), - sa.ForeignKeyConstraint(['location_id'], ['location.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('order_item', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=True), - sa.Column('order_id', sa.Integer(), nullable=True), - sa.Column('product_id', sa.Integer(), nullable=True), - sa.Column('name', sa.String(length=120), nullable=True), - sa.ForeignKeyConstraint(['order_id'], ['order.id'], ), - sa.ForeignKeyConstraint(['product_id'], ['product.id'], ), - sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), - sa.PrimaryKeyConstraint('id') - ) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_table('order_item') - op.drop_table('order') - op.drop_table('product') - op.drop_table('user') - op.drop_table('location') - ### end Alembic commands ### diff --git a/app/migrations/versions/old_migrations/42709384216_.py b/app/migrations/versions/old_migrations/42709384216_.py deleted file mode 100644 index 4fa051d..0000000 --- a/app/migrations/versions/old_migrations/42709384216_.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Removed foreign key constraint - -Revision ID: 42709384216 -Revises: 57a00d0b7bc -Create Date: 2015-06-04 22:34:05.237943 - -""" - -# revision identifiers, used by Alembic. -revision = '42709384216' -down_revision = '57a00d0b7bc' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('order_ibfk_1', 'order', type_='foreignkey') - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.create_foreign_key('order_ibfk_1', 'order', 'user', ['courrier_id'], ['id']) - ### end Alembic commands ### diff --git a/app/migrations/versions/old_migrations/4e94c0b08ed_.py b/app/migrations/versions/old_migrations/4e94c0b08ed_.py deleted file mode 100644 index 550e057..0000000 --- a/app/migrations/versions/old_migrations/4e94c0b08ed_.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Add extra message - -Revision ID: 4e94c0b08ed -Revises: 42709384216 -Create Date: 2015-06-24 21:42:41.466973 - -""" - -# revision identifiers, used by Alembic. -revision = '4e94c0b08ed' -down_revision = '42709384216' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.add_column('order_item', sa.Column('extra', sa.String(length=254), nullable=True)) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_column('order_item', 'extra') - ### end Alembic commands ### diff --git a/app/migrations/versions/old_migrations/57a00d0b7bc_.py b/app/migrations/versions/old_migrations/57a00d0b7bc_.py deleted file mode 100644 index 464d9c9..0000000 --- a/app/migrations/versions/old_migrations/57a00d0b7bc_.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Added order paid column - -Revision ID: 57a00d0b7bc -Revises: 3243c3538fc -Create Date: 2015-06-04 19:16:47.888372 - -""" - -# revision identifiers, used by Alembic. -revision = '57a00d0b7bc' -down_revision = '3243c3538fc' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.add_column('order_item', sa.Column('paid', sa.Boolean(), nullable=True)) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_column('order_item', 'paid') - ### end Alembic commands ### diff --git a/first-setup.sh b/first-setup.sh index 466cab4..633a4b1 100755 --- a/first-setup.sh +++ b/first-setup.sh @@ -29,4 +29,4 @@ cd .. echo -e "${B} Seeding database ${E}" ./populate-db.sh -echo -e "${B} Activate your venv using 'source venv/bin/activate'.\nThen run the server with 'python app/haldis.py runserver' ${E}" +echo -e "${B} Activate your venv using 'source venv/bin/activate'.\nThen run the server with 'python app/app.py runserver' ${E}" \ No newline at end of file