routing and model __init__ updates
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
from api.database import (Model, SurrogatePK, db,
|
||||
Column, reference_col, relationship)
|
||||
Column)
|
||||
|
||||
|
||||
class TargetExchange(SurrogatePK, Model):
|
||||
__tablename__ = "target-exchange"
|
||||
name = Column(db.String(255), unique=True, nullable=False)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(TargetExchange, self).__init__(**kwargs)
|
||||
|
||||
@staticmethod
|
||||
def ensure_created(name):
|
||||
if TargetExchange.query.filter_by(name=name).first() is None:
|
||||
|
||||
@@ -30,11 +30,11 @@ def create(name):
|
||||
|
||||
|
||||
@doc(tags=['TargetExchange'])
|
||||
@blueprint.route('/<id>', methods=['GET'])
|
||||
@blueprint.route('/<exchange_id>', methods=['GET'])
|
||||
@jwt_required()
|
||||
@marshal_with(target_exchange_schema)
|
||||
def get_by_id(id):
|
||||
target_exchange = TargetExchange.get_by_id(id)
|
||||
def get_by_id(exchange_id):
|
||||
target_exchange = TargetExchange.get_by_id(exchange_id)
|
||||
if target_exchange is not None:
|
||||
return target_exchange
|
||||
else:
|
||||
@@ -42,12 +42,12 @@ def get_by_id(id):
|
||||
|
||||
|
||||
@doc(tags=['TargetExchange'])
|
||||
@blueprint.route('/<id>', methods=['PUT'])
|
||||
@blueprint.route('/<exchange_id>', methods=['PUT'])
|
||||
@jwt_required()
|
||||
@use_kwargs(target_exchange_schema)
|
||||
@marshal_with(target_exchange_schema)
|
||||
def update(id, **kwargs):
|
||||
target_exchange = TargetExchange.get_by_id(id)
|
||||
def update(exchange_id, **kwargs):
|
||||
target_exchange = TargetExchange.get_by_id(exchange_id)
|
||||
if target_exchange is not None:
|
||||
return target_exchange.update(**kwargs)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user