formatting
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from flask import Flask, Blueprint
|
||||
|
||||
from . import commands, login, target_exchange, target
|
||||
from .settings import ProdConfig, Config
|
||||
from .extensions import db, migrate, jwt, apispec
|
||||
from .exceptions import ApiException
|
||||
from .extensions import db, migrate, jwt, apispec
|
||||
from .settings import ProdConfig, Config
|
||||
|
||||
|
||||
def create_app(config: Config = ProdConfig) -> Flask:
|
||||
@@ -78,6 +79,7 @@ def register_errorhandlers(app: Flask):
|
||||
|
||||
def register_shellcontext(app: Flask):
|
||||
"""Register shell context objects."""
|
||||
|
||||
def shell_context():
|
||||
"""Shell context objects."""
|
||||
return {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import os
|
||||
import click
|
||||
|
||||
import click
|
||||
from flask import current_app
|
||||
from flask.cli import with_appcontext
|
||||
from werkzeug.exceptions import MethodNotAllowed, NotFound
|
||||
|
||||
from .target_exchange.models import TargetExchange
|
||||
|
||||
|
||||
@click.command()
|
||||
def clean():
|
||||
"""Remove *.pyc and *.pyo files recursively starting at current directory.
|
||||
@@ -82,6 +83,7 @@ def urls(url, order):
|
||||
for row in rows:
|
||||
click.echo(str_template.format(*row[:column_length]))
|
||||
|
||||
|
||||
@click.command()
|
||||
@with_appcontext
|
||||
def seed():
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
API_PASS='API_PASS'
|
||||
API_USER='super'
|
||||
API_PASS = 'API_PASS'
|
||||
API_USER = 'super'
|
||||
|
||||
@@ -9,6 +9,7 @@ Column = db.Column
|
||||
relationship = relationship
|
||||
Model = db.Model
|
||||
|
||||
|
||||
# From Mike Bayer's "Building the app" talk
|
||||
# https://speakerdeck.com/zzzeek/building-the-app
|
||||
class SurrogatePK(object):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from flask import jsonify
|
||||
|
||||
|
||||
class ApiException(Exception):
|
||||
status_code = 500
|
||||
|
||||
@@ -13,10 +14,12 @@ class ApiException(Exception):
|
||||
rv.status_code = self.status_code
|
||||
return rv
|
||||
|
||||
|
||||
class NotFoundException(ApiException):
|
||||
def __init__(self, entity_name) -> None:
|
||||
super().__init__(404, f'{entity_name} could not be found')
|
||||
|
||||
|
||||
class BadRequestException(ApiException):
|
||||
def __init__(self, message) -> None:
|
||||
super().__init__(400, message)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from flask_apispec import FlaskApiSpec
|
||||
from flask_jwt_extended import JWTManager
|
||||
from flask_migrate import Migrate
|
||||
from flask_sqlalchemy import SQLAlchemy, Model
|
||||
from flask_apispec import FlaskApiSpec
|
||||
|
||||
|
||||
class CRUDMixin(Model):
|
||||
"""Mixin that adds convenience methods for CRUD (create, read, update, delete) operations."""
|
||||
@@ -30,6 +31,7 @@ class CRUDMixin(Model):
|
||||
db.session.delete(self)
|
||||
return commit and db.session.commit()
|
||||
|
||||
|
||||
db = SQLAlchemy(model_class=CRUDMixin)
|
||||
migrate = Migrate()
|
||||
jwt = JWTManager()
|
||||
|
||||
Reference in New Issue
Block a user