Commit 0b196054 authored by Daniele Venzano's avatar Daniele Venzano

Simplify if statements (pylint)

parent 5b1acf18
......@@ -58,7 +58,7 @@ class UsersEndpointWeb(ZoeWebRequestHandler):
user_id = int(self.get_argument('id'))
user_data = {
'email': None if self.get_argument('email') == '' or self.get_argument('email') == 'None' else self.get_argument('email'),
'enabled': True if self.get_argument('enabled', 'off') == 'on' else False,
'enabled': self.get_argument('enabled', 'off') == 'on',
'fs_uid': int(self.get_argument('fs_uid')),
'auth_source': self.get_argument('auth_source'),
'role_id': self.api_endpoint.role_by_name(self.get_argument('role')).id,
......@@ -114,13 +114,13 @@ class RolesEndpointWeb(ZoeWebRequestHandler):
if self.get_argument('action') == 'update':
role_id = int(self.get_argument('id'))
role_data = {
'can_see_status': True if self.get_argument('can_see_status', 'off') == 'on' else False,
'can_change_config': True if self.get_argument('can_change_config', 'off') == 'on' else False,
'can_operate_others': True if self.get_argument('can_operate_others', 'off') == 'on' else False,
'can_delete_executions': True if self.get_argument('can_delete_executions', 'off') == 'on' else False,
'can_access_api': True if self.get_argument('can_access_api', 'off') == 'on' else False,
'can_customize_resources': True if self.get_argument('can_customize_resources', 'off') == 'on' else False,
'can_access_full_zapp_shop': True if self.get_argument('can_access_full_zapp_shop', 'off') == 'on' else False
'can_see_status': self.get_argument('can_see_status', 'off') == 'on',
'can_change_config': self.get_argument('can_change_config', 'off') == 'on',
'can_operate_others': self.get_argument('can_operate_others', 'off') == 'on',
'can_delete_executions': self.get_argument('can_delete_executions', 'off') == 'on',
'can_access_api': self.get_argument('can_access_api', 'off') == 'on',
'can_customize_resources': self.get_argument('can_customize_resources', 'off') == 'on',
'can_access_full_zapp_shop': self.get_argument('can_access_full_zapp_shop', 'off') == 'on'
}
self.api_endpoint.role_update(self.current_user, role_id, role_data)
......@@ -130,13 +130,13 @@ class RolesEndpointWeb(ZoeWebRequestHandler):
elif self.get_argument('action') == 'create':
role_data = {
'name': self.get_argument('name'),
'can_see_status': True if self.get_argument('can_see_status', 'off') == 'on' else False,
'can_change_config': True if self.get_argument('can_change_config', 'off') == 'on' else False,
'can_operate_others': True if self.get_argument('can_operate_others', 'off') == 'on' else False,
'can_delete_executions': True if self.get_argument('can_delete_executions', 'off') == 'on' else False,
'can_access_api': True if self.get_argument('can_access_api', 'off') == 'on' else False,
'can_customize_resources': True if self.get_argument('can_customize_resources', 'off') == 'on' else False,
'can_access_full_zapp_shop': True if self.get_argument('can_access_full_zapp_shop', 'off') == 'on' else False
'can_see_status': self.get_argument('can_see_status', 'off') == 'on',
'can_change_config': self.get_argument('can_change_config', 'off') == 'on',
'can_operate_others': self.get_argument('can_operate_others', 'off') == 'on',
'can_delete_executions': self.get_argument('can_delete_executions', 'off') == 'on',
'can_access_api': self.get_argument('can_access_api', 'off') == 'on',
'can_customize_resources': self.get_argument('can_customize_resources', 'off') == 'on',
'can_access_full_zapp_shop': self.get_argument('can_access_full_zapp_shop', 'off') == 'on'
}
self.api_endpoint.role_new(self.current_user, role_data)
self.redirect(self.reverse_url('admin_roles'))
......
......@@ -56,7 +56,7 @@ class JinjaApp:
'auto_reload': app_settings.get('autoreload', False),
'loader': _loader,
'cache_size': 50 if app_settings.get('compiled_template_cache', True) else 0,
'autoescape': True if app_settings.get('autoescape', 'xhtml_escape') == "xhtml_escape" else False,
'autoescape': app_settings.get('autoescape', 'xhtml_escape') == "xhtml_escape"
}
_jinja_config.update(**(jinja_options or {}))
......
......@@ -228,13 +228,13 @@ def role_create_cmd(api: ZoeAPI, args):
"""Create a new role."""
role = {
'name': args.name,
'can_see_status': True if args.can_see_status else False,
'can_change_config': True if args.can_change_config else False,
'can_operate_others': True if args.can_operate_others else False,
'can_delete_executions': True if args.can_delete_executions else False,
'can_access_api': True if args.can_access_api else False,
'can_customize_resources': True if args.can_customize_resources else False,
'can_access_full_zapp_shop': True if args.can_access_full_zapp_shop else False
'can_see_status': bool(args.can_see_status),
'can_change_config': bool(args.can_change_config),
'can_operate_others': bool(args.can_operate_others),
'can_delete_executions': bool(args.can_delete_executions),
'can_access_api': bool(args.can_access_api),
'can_customize_resources': bool(args.can_customize_resources),
'can_access_full_zapp_shop': bool(args.can_access_full_zapp_shop)
}
new_id = api.role.create(role)
print('New role created with ID: {}'.format(new_id))
......@@ -251,19 +251,19 @@ def role_update_cmd(api: ZoeAPI, args):
if args.name is not None:
role_update['name'] = args.name
if args.can_see_status is not None:
role_update['can_see_status'] = True if args.can_see_status else False
role_update['can_see_status'] = bool(args.can_see_status)
if args.can_change_config is not None:
role_update['can_change_config'] = True if args.can_change_config else False
role_update['can_change_config'] = bool(args.can_change_config)
if args.can_operate_others is not None:
role_update['can_operate_others'] = True if args.can_operate_others else False
role_update['can_operate_others'] = bool(args.can_operate_others)
if args.can_delete_executions is not None:
role_update['can_delete_executions'] = True if args.can_delete_executions else False
role_update['can_delete_executions'] = bool(args.can_delete_executions)
if args.can_access_api is not None:
role_update['can_access_api'] = True if args.can_access_api else False
role_update['can_access_api'] = bool(args.can_access_api)
if args.can_customize_resources is not None:
role_update['can_customize_resources'] = True if args.can_customize_resources else False
role_update['can_customize_resources'] = bool(args.can_customize_resources)
if args.can_access_full_zapp_shop is not None:
role_update['can_access_full_zapp_shop'] = True if args.can_access_full_zapp_shop else False
role_update['can_access_full_zapp_shop'] = bool(args.can_access_full_zapp_shop)
api.role.update(args.id, role_update)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment