Compare commits

...

5 Commits

Author SHA1 Message Date
Alexis Lahouze
2db7925cad Fix route to avoid remove trailing slash in collection endpoints. 2017-07-15 08:13:31 +02:00
Alexis Lahouze
02f14863b1 Add commit to have updated model objects in return. 2017-07-07 17:39:48 +02:00
Alexis Lahouze
16979bfc0b Fix data.get with default. 2017-07-07 17:39:21 +02:00
Alexis Lahouze
892470bdad Add argument for account creation on command line. 2017-07-07 17:38:53 +02:00
Alexis Lahouze
26e7d578c7 Fix subquery. 2017-07-07 17:38:35 +02:00
5 changed files with 13 additions and 7 deletions

View File

@ -195,7 +195,7 @@ class Account(db.Model):
) )
if end: if end:
query = query.filter(query.c.operation_date <= str(end)) query = query.filter(base_query.c.operation_date <= str(end))
elif end: elif end:
query = query.filter(Operation.operation_date <= str(end)) query = query.filter(Operation.operation_date <= str(end))

View File

@ -24,6 +24,8 @@ def users():
@users.command() @users.command()
@click.argument('email')
@click.argument('password')
def add(email, password): def add(email, password):
""" Add a new user. """ """ Add a new user. """
user = User() user = User()

View File

@ -122,7 +122,7 @@ range_parser.add_argument(
# pylint: disable=no-self-use # pylint: disable=no-self-use
@ns.route('/') @ns.route('')
@ns.doc( @ns.doc(
security='apikey', security='apikey',
responses={ responses={
@ -205,7 +205,7 @@ class AccountResource(Resource):
data = self.api.payload data = self.api.payload
# Check ID consistency. # Check ID consistency.
if data.get('id', default=account_id) != account_id: if data.get('id', account_id) != account_id:
ns.abort(406, 'Id must not be provided or changed on update.') ns.abort(406, 'Id must not be provided or changed on update.')
# Need to get the object to update it. # Need to get the object to update it.

View File

@ -90,7 +90,7 @@ account_range_parser.add_argument(
# pylint: disable=no-self-use # pylint: disable=no-self-use
@ns.route('/') @ns.route('')
@ns.doc( @ns.doc(
security='apikey', security='apikey',
responses={ responses={
@ -143,6 +143,8 @@ class OperationListResource(Resource):
db.session.add(operation) # pylint: disable=no-member db.session.add(operation) # pylint: disable=no-member
db.session.commit()
return operation, 201 return operation, 201
@ -185,7 +187,7 @@ class OperationResource(Resource):
data = self.api.payload data = self.api.payload
# Check ID consistency. # Check ID consistency.
if data.get('id', default=operation_id) != operation_id: if data.get('id', operation_id) != operation_id:
ns.abort(406, 'Id must not be provided or changed on update.') ns.abort(406, 'Id must not be provided or changed on update.')
# pylint: disable=no-member # pylint: disable=no-member
@ -203,6 +205,8 @@ class OperationResource(Resource):
db.session.merge(operation) # pylint: disable=no-member db.session.merge(operation) # pylint: disable=no-member
db.session.commit()
return operation, 200 return operation, 200
@ns.response(204, 'Operation deleted', operation_model) @ns.response(204, 'Operation deleted', operation_model)

View File

@ -68,7 +68,7 @@ account_id_parser.add_argument(
# pylint: disable=no-self-use # pylint: disable=no-self-use
@ns.route('/') @ns.route('')
@ns.doc( @ns.doc(
security='apikey', security='apikey',
responses={ responses={
@ -160,7 +160,7 @@ class ScheduledOperationResource(Resource):
so_id = scheduled_operation_id so_id = scheduled_operation_id
# Check ID consistency. # Check ID consistency.
if data.get('id', default=so_id) != so_id: if data.get('id', so_id) != so_id:
ns.abort(406, 'Id must not be provided or changed on update.') ns.abort(406, 'Id must not be provided or changed on update.')
scheduled_operation = ScheduledOperation.query().get(so_id) scheduled_operation = ScheduledOperation.query().get(so_id)