From 832da874c9f5f7921ebd43d284f9912b273c1d6b Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Wed, 13 Jan 2016 00:02:38 +0100 Subject: [PATCH] Rename blueprints and api. --- accountant/__init__.py | 4 ++-- accountant/api/__init__.py | 4 ++-- accountant/api/views/accounts.py | 10 +++++----- accountant/api/views/operations.py | 6 +++--- accountant/api/views/scheduled_operations.py | 6 +++--- accountant/api/views/users.py | 4 ++-- accountant/frontend/__init__.py | 6 +++--- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/accountant/__init__.py b/accountant/__init__.py index d22df55..81db5cd 100644 --- a/accountant/__init__.py +++ b/accountant/__init__.py @@ -30,8 +30,8 @@ app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True db = SQLAlchemy(app) # Must be after db declaration because the blueprints may need it. -from .api import api -from .frontend import frontend, frontend_js, frontend_css +from .api import blueprint as api +from .frontend import blueprint as frontend, frontend_js, frontend_css app.register_blueprint(frontend, url_prefix='/app') app.register_blueprint(api, url_prefix='/api') diff --git a/accountant/api/__init__.py b/accountant/api/__init__.py index aa7819a..cafdede 100644 --- a/accountant/api/__init__.py +++ b/accountant/api/__init__.py @@ -17,8 +17,8 @@ from flask import Blueprint from flask.ext.restful import Api -api = Blueprint('api', __name__) -api_api = Api(api) +blueprint = Blueprint('api', __name__) +api = Api(blueprint) # Load all views. from .views import * diff --git a/accountant/api/views/accounts.py b/accountant/api/views/accounts.py index 104338c..6d75a83 100644 --- a/accountant/api/views/accounts.py +++ b/accountant/api/views/accounts.py @@ -22,7 +22,7 @@ from sqlalchemy.orm.exc import NoResultFound from accountant import db -from .. import api_api +from .. import api from ..models.accounts import Account from ..models.operations import Operation @@ -143,8 +143,8 @@ class AccountResource(Resource): return None, 204 -api_api.add_resource(AccountListResource, '/accounts') -api_api.add_resource(AccountResource, '/accounts/') +api.add_resource(AccountListResource, '/accounts') +api.add_resource(AccountResource, '/accounts/') range_parser = reqparse.RequestParser() @@ -187,5 +187,5 @@ class SoldsResource(Resource): return Operation.get_ohlc_per_day_for_range(**data).all(), 200 -api_api.add_resource(CategoriesResource, "/categories") -api_api.add_resource(SoldsResource, "/solds") +api.add_resource(CategoriesResource, "/categories") +api.add_resource(SoldsResource, "/solds") diff --git a/accountant/api/views/operations.py b/accountant/api/views/operations.py index f126007..a6759ab 100644 --- a/accountant/api/views/operations.py +++ b/accountant/api/views/operations.py @@ -20,7 +20,7 @@ from flask.ext.restful import Resource, fields, reqparse, marshal_with_field from accountant import db -from .. import api_api +from .. import api from ..models.operations import Operation @@ -136,5 +136,5 @@ class OperationResource(Resource): return None, 204 -api_api.add_resource(OperationListResource, "/operations") -api_api.add_resource(OperationResource, "/operations/") +api.add_resource(OperationListResource, "/operations") +api.add_resource(OperationResource, "/operations/") diff --git a/accountant/api/views/scheduled_operations.py b/accountant/api/views/scheduled_operations.py index 5f0f923..d6bace9 100644 --- a/accountant/api/views/scheduled_operations.py +++ b/accountant/api/views/scheduled_operations.py @@ -26,7 +26,7 @@ from accountant import db from ..models.scheduled_operations import ScheduledOperation from ..models.operations import Operation -from .. import api_api +from .. import api from ..fields import Object @@ -159,6 +159,6 @@ class ScheduledOperationResource(Resource): return None, 204 -api_api.add_resource(ScheduledOperationListResource, "/scheduled_operations") -api_api.add_resource(ScheduledOperationResource, +api.add_resource(ScheduledOperationListResource, "/scheduled_operations") +api.add_resource(ScheduledOperationResource, "/scheduled_operations/") diff --git a/accountant/api/views/users.py b/accountant/api/views/users.py index 3cf969e..f044926 100644 --- a/accountant/api/views/users.py +++ b/accountant/api/views/users.py @@ -28,7 +28,7 @@ from werkzeug.exceptions import BadRequest from accountant import app -from .. import api_api +from .. import api from ..fields import Object @@ -126,4 +126,4 @@ class LoginResource(Resource): return g.user -api_api.add_resource(LoginResource, "/users/login") +api.add_resource(LoginResource, "/users/login") diff --git a/accountant/frontend/__init__.py b/accountant/frontend/__init__.py index dda5175..ae0bfb3 100644 --- a/accountant/frontend/__init__.py +++ b/accountant/frontend/__init__.py @@ -1,7 +1,7 @@ from flask import Blueprint, render_template from flask.ext.assets import Environment, Bundle -frontend = Blueprint( +blueprint = Blueprint( 'frontend', __name__, template_folder='templates', @@ -15,7 +15,7 @@ frontend_js = Bundle('frontend/js/app.js', 'frontend/js/accounts.js', frontend_css = Bundle('frontend/css/main.css') -@frontend.route('/', defaults={'path': 'accounts'}) -@frontend.route('/') +@blueprint.route('/', defaults={'path': 'accounts'}) +@blueprint.route('/') def index(path): return render_template('layout.html')