This commit is contained in:
Alexis Lahouze 2017-05-19 13:47:55 +02:00
parent 1cf053bc39
commit de5e0482cd
5 changed files with 27 additions and 13 deletions

View File

@ -30,6 +30,6 @@ def add(email, password):
user.email = email user.email = email
user.password = User.hash_password(password) user.password = User.hash_password(password)
db.session.add(user) db.session.add(user) # pylint: disable=no-member
click.echo("User '%s' successfully added." % email) click.echo("User '%s' successfully added." % email)

View File

@ -116,8 +116,10 @@ range_parser.add_argument(
location='args', location='args',
help='End date of the time period' help='End date of the time period'
) )
# pylint: enable=invalid-name
# pylint: disable=no-self-use
@ns.route('/') @ns.route('/')
@ns.doc( @ns.doc(
security='apikey', security='apikey',
@ -156,10 +158,10 @@ class AccountListResource(Resource):
account = Account(**data) account = Account(**data)
# Add new account in session. # Add new account in session.
db.session.add(account) db.session.add(account) # pylint: disable=no-member
# Flush session to have id in account. # Flush session to have id in account.
db.session.flush() db.session.flush() # pylint: disable=no-member
# Return account. # Return account.
return account, 201 return account, 201
@ -226,7 +228,7 @@ class AccountResource(Resource):
for k, v in data.items(): for k, v in data.items():
setattr(account, k, v) setattr(account, k, v)
db.session.merge(account) db.session.merge(account) # pylint: disable=no-member
# Return account. # Return account.
return account, 200 return account, 200
@ -246,7 +248,7 @@ class AccountResource(Resource):
error_message='Account with id %d not found.' % account_id error_message='Account with id %d not found.' % account_id
) )
db.session.delete(account) db.session.delete(account) # pylint: disable=no-member
return None, 204 return None, 204

View File

@ -86,8 +86,10 @@ account_range_parser.add_argument(
location='args', location='args',
help='Id of the account' help='Id of the account'
) )
# pylint: enable=invalid-name
# pylint: disable=no-self-use
@ns.route('/') @ns.route('/')
@ns.doc( @ns.doc(
security='apikey', security='apikey',
@ -141,7 +143,7 @@ class OperationListResource(Resource):
operation = Operation(**data) operation = Operation(**data)
db.session.add(operation) db.session.add(operation) # pylint: disable=no-member
return operation, 201 return operation, 201
@ -165,7 +167,9 @@ class OperationResource(Resource):
def get(self, operation_id): def get(self, operation_id):
"""Get operation.""" """Get operation."""
# pylint: disable=no-member
operation = db.session.query(Operation).get(operation_id) operation = db.session.query(Operation).get(operation_id)
# pylint: enable=no-member
if not operation: if not operation:
ns.abort( ns.abort(
@ -192,7 +196,9 @@ class OperationResource(Resource):
error_message='Id must not be provided or changed on update.' error_message='Id must not be provided or changed on update.'
) )
# pylint: disable=no-member
operation = db.session.query(Operation).get(operation_id) operation = db.session.query(Operation).get(operation_id)
# pylint: enable=no-member
if not operation: if not operation:
ns.abort( ns.abort(
@ -206,7 +212,7 @@ class OperationResource(Resource):
for k, v in data.items(): for k, v in data.items():
setattr(operation, k, v) setattr(operation, k, v)
db.session.merge(operation) db.session.merge(operation) # pylint: disable=no-member
return operation, 200 return operation, 200
@ -216,7 +222,9 @@ class OperationResource(Resource):
def delete(self, operation_id): def delete(self, operation_id):
"""Delete an operation.""" """Delete an operation."""
# pylint: disable=no-member
operation = db.session.query(Operation).get(operation_id) operation = db.session.query(Operation).get(operation_id)
# pylint: enable=no-member
if not operation: if not operation:
ns.abort( ns.abort(
@ -224,6 +232,6 @@ class OperationResource(Resource):
error_message='Operation with id %d not found.' % operation_id error_message='Operation with id %d not found.' % operation_id
) )
db.session.delete(operation) db.session.delete(operation) # pylint: disable=no-member
return None, 204 return None, 204

View File

@ -64,8 +64,10 @@ account_id_parser.add_argument(
location='args', location='args',
help='Id of the account' help='Id of the account'
) )
# pylint: enable=invalid-name
# pylint: disable=no-self-use
@ns.route('/') @ns.route('/')
@ns.doc( @ns.doc(
security='apikey', security='apikey',
@ -115,11 +117,11 @@ class ScheduledOperationListResource(Resource):
scheduled_operation = ScheduledOperation(**data) scheduled_operation = ScheduledOperation(**data)
db.session.add(scheduled_operation) db.session.add(scheduled_operation) # pylint: disable=no-member
scheduled_operation.reschedule() scheduled_operation.reschedule()
db.session.flush() db.session.flush() # pylint: disable=no-member
return scheduled_operation, 201 return scheduled_operation, 201
@ -187,11 +189,11 @@ class ScheduledOperationResource(Resource):
for k, v in data.items(): for k, v in data.items():
setattr(scheduled_operation, k, v) setattr(scheduled_operation, k, v)
db.session.merge(scheduled_operation) db.session.merge(scheduled_operation) # pylint: disable=no-member
scheduled_operation.reschedule() scheduled_operation.reschedule()
db.session.flush() db.session.flush() # pylint: disable=no-member
return scheduled_operation, 200 return scheduled_operation, 200
@ -225,6 +227,6 @@ class ScheduledOperationResource(Resource):
# Delete unconfirmed operations # Delete unconfirmed operations
scheduled_operation.operations.delete() scheduled_operation.operations.delete()
db.session.delete(scheduled_operation) db.session.delete(scheduled_operation) # pylint: disable=no-member
return None, 204 return None, 204

View File

@ -46,8 +46,10 @@ user_model = ns.model('User', {
readonly=True, readonly=True,
description='Active state of the user') description='Active state of the user')
}) })
# pylint: enable=invalid-name
# pylint: disable=no-self-use
@ns.route('/login') @ns.route('/login')
class LoginResource(Resource): class LoginResource(Resource):
"""Resource to handle login operations.""" """Resource to handle login operations."""