Define default settings explicitly (openstack_dashboard 4/5)

This commit mainly covers settings
in openstack_dashboard/dashboards/identity/.

Part of blueprint ini-based-configuration
Change-Id: Ibb174f62d0047a10b2832dd2ff350f5f32955b08
This commit is contained in:
Akihiro Motoki 2019-04-11 09:04:36 +09:00
parent a7a04da657
commit 8653f718f2
10 changed files with 35 additions and 40 deletions

View File

@ -204,9 +204,7 @@ class EnableDomainsAction(tables.BatchAction):
class DomainFilterAction(tables.FilterAction):
def allowed(self, request, datum):
multidomain_support = getattr(settings,
'OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT',
False)
multidomain_support = settings.OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT
return multidomain_support
def filter(self, table, domains, filter_string):
@ -229,9 +227,7 @@ class SetDomainContext(tables.Action):
policy_rules = (('identity', 'identity:update_domain'),)
def allowed(self, request, datum):
multidomain_support = getattr(settings,
'OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT',
False)
multidomain_support = settings.OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT
if not multidomain_support:
return False

View File

@ -69,8 +69,7 @@ class UpdateDomainUsersAction(workflows.MembershipAction):
default_role = api.keystone.get_default_role(self.request)
# Default role is necessary to add members to a domain
if default_role is None:
default = getattr(settings,
"OPENSTACK_KEYSTONE_DEFAULT_ROLE", None)
default = settings.OPENSTACK_KEYSTONE_DEFAULT_ROLE
msg = (_('Could not find default role "%s" in Keystone') %
default)
raise exceptions.NotFound(msg)
@ -168,8 +167,7 @@ class UpdateDomainGroupsAction(workflows.MembershipAction):
default_role = api.keystone.get_default_role(self.request)
# Default role is necessary to add members to a domain
if default_role is None:
default = getattr(settings,
"OPENSTACK_KEYSTONE_DEFAULT_ROLE", None)
default = settings.OPENSTACK_KEYSTONE_DEFAULT_ROLE
msg = (_('Could not find default role "%s" in Keystone') %
default)
raise exceptions.NotFound(msg)

View File

@ -58,7 +58,7 @@ class OverviewTab(tabs.Tab):
def _get_extras(self, project):
if api.keystone.VERSIONS.active >= 3:
extra_info = getattr(settings, 'PROJECT_TABLE_EXTRA_INFO', {})
extra_info = settings.PROJECT_TABLE_EXTRA_INFO
return dict((display_key, getattr(project, key, ''))
for key, display_key in extra_info.items())
else:

View File

@ -183,7 +183,7 @@ class UpdateProjectView(workflows.WorkflowView):
if keystone.VERSIONS.active >= 3:
# get extra columns info
ex_info = getattr(settings, 'PROJECT_TABLE_EXTRA_INFO', {})
ex_info = settings.PROJECT_TABLE_EXTRA_INFO
for ex_field in ex_info:
initial[ex_field] = getattr(project_info, ex_field, None)

View File

@ -241,7 +241,7 @@ class CreateProjectInfoAction(workflows.Action):
def add_extra_fields(self):
# add extra column defined by setting
EXTRA_INFO = getattr(settings, 'PROJECT_TABLE_EXTRA_INFO', {})
EXTRA_INFO = settings.PROJECT_TABLE_EXTRA_INFO
for key, value in EXTRA_INFO.items():
form = forms.CharField(label=value, required=False,)
self.fields[key] = form
@ -264,7 +264,7 @@ class CreateProjectInfo(workflows.Step):
def __init__(self, workflow):
super(CreateProjectInfo, self).__init__(workflow)
if keystone.VERSIONS.active >= 3:
EXTRA_INFO = getattr(settings, 'PROJECT_TABLE_EXTRA_INFO', {})
EXTRA_INFO = settings.PROJECT_TABLE_EXTRA_INFO
self.contributes += tuple(EXTRA_INFO.keys())
@ -286,8 +286,7 @@ class UpdateProjectMembersAction(workflows.MembershipAction):
default_role = keystone.get_default_role(self.request)
# Default role is necessary to add members to a project
if default_role is None:
default = getattr(settings,
"OPENSTACK_KEYSTONE_DEFAULT_ROLE", None)
default = settings.OPENSTACK_KEYSTONE_DEFAULT_ROLE
msg = (_('Could not find default role "%s" in Keystone') %
default)
raise exceptions.NotFound(msg)
@ -384,8 +383,7 @@ class UpdateProjectGroupsAction(workflows.MembershipAction):
default_role = api.keystone.get_default_role(self.request)
# Default role is necessary to add members to a project
if default_role is None:
default = getattr(settings,
"OPENSTACK_KEYSTONE_DEFAULT_ROLE", None)
default = settings.OPENSTACK_KEYSTONE_DEFAULT_ROLE
msg = (_('Could not find default role "%s" in Keystone') %
default)
raise exceptions.NotFound(msg)
@ -502,7 +500,7 @@ class CreateProject(workflows.Workflow):
try:
# add extra information
if keystone.VERSIONS.active >= 3:
EXTRA_INFO = getattr(settings, 'PROJECT_TABLE_EXTRA_INFO', {})
EXTRA_INFO = settings.PROJECT_TABLE_EXTRA_INFO
kwargs = dict((key, data.get(key)) for key in EXTRA_INFO)
else:
kwargs = {}
@ -643,7 +641,7 @@ class UpdateProjectInfo(workflows.Step):
def __init__(self, workflow):
super(UpdateProjectInfo, self).__init__(workflow)
if keystone.VERSIONS.active >= 3:
EXTRA_INFO = getattr(settings, 'PROJECT_TABLE_EXTRA_INFO', {})
EXTRA_INFO = settings.PROJECT_TABLE_EXTRA_INFO
self.contributes += tuple(EXTRA_INFO.keys())
@ -688,7 +686,7 @@ class UpdateProject(workflows.Workflow):
# add extra information
if keystone.VERSIONS.active >= 3:
EXTRA_INFO = getattr(settings, 'PROJECT_TABLE_EXTRA_INFO', {})
EXTRA_INFO = settings.PROJECT_TABLE_EXTRA_INFO
kwargs = dict((key, data.get(key)) for key in EXTRA_INFO)
else:
kwargs = {}

View File

@ -97,7 +97,7 @@ class AddExtraColumnMixIn(object):
def add_extra_fields(self, ordering=None):
if api.keystone.VERSIONS.active >= 3:
# add extra column defined by setting
EXTRA_INFO = getattr(settings, 'USER_TABLE_EXTRA_INFO', {})
EXTRA_INFO = settings.USER_TABLE_EXTRA_INFO
for key, value in EXTRA_INFO.items():
self.fields[key] = forms.CharField(label=value,
required=False)
@ -172,7 +172,7 @@ class CreateUserForm(PasswordMixin, BaseUserForm, AddExtraColumnMixIn):
# add extra information
if api.keystone.VERSIONS.active >= 3:
EXTRA_INFO = getattr(settings, 'USER_TABLE_EXTRA_INFO', {})
EXTRA_INFO = settings.USER_TABLE_EXTRA_INFO
kwargs = dict((key, data.get(key)) for key in EXTRA_INFO)
else:
kwargs = {}
@ -291,7 +291,7 @@ class ChangePasswordForm(PasswordMixin, forms.SelfHandlingForm):
def __init__(self, request, *args, **kwargs):
super(ChangePasswordForm, self).__init__(request, *args, **kwargs)
if getattr(settings, 'ENFORCE_PASSWORD_CHECK', False):
if settings.ENFORCE_PASSWORD_CHECK:
self.fields["admin_password"] = forms.CharField(
label=_("Admin Password"),
widget=forms.PasswordInput(render_value=False))
@ -309,7 +309,7 @@ class ChangePasswordForm(PasswordMixin, forms.SelfHandlingForm):
data.pop('confirm_password', None)
# Verify admin password before changing user password
if getattr(settings, 'ENFORCE_PASSWORD_CHECK', False):
if settings.ENFORCE_PASSWORD_CHECK:
admin_password = data.pop('admin_password')
if not api.keystone.user_verify_admin_password(request,
admin_password):

View File

@ -68,7 +68,7 @@ class OverviewTab(tabs.Tab):
def _get_extras(self, user):
if api.keystone.VERSIONS.active >= 3:
extra_info = getattr(settings, 'USER_TABLE_EXTRA_INFO', {})
extra_info = settings.USER_TABLE_EXTRA_INFO
return dict((display_key, getattr(user, key, ''))
for key, display_key in extra_info.items())
else:

View File

@ -155,7 +155,7 @@ class UpdateView(forms.ModalFormView):
'email': getattr(user, 'email', None),
'description': getattr(user, 'description', None)}
if api.keystone.VERSIONS.active >= 3:
for key in getattr(settings, 'USER_TABLE_EXTRA_INFO', {}):
for key in settings.USER_TABLE_EXTRA_INFO:
data[key] = getattr(user, key, None)
return data

View File

@ -140,6 +140,22 @@ OPENRC_CUSTOM_TEMPLATE = 'project/api_access/openrc.sh.template'
OPENSTACK_CLOUDS_YAML_CUSTOM_TEMPLATE = ('project/api_access/'
'clouds.yaml.template')
# Projects and users can have extra attributes as defined by keystone v3.
# Horizon has the ability to display these extra attributes via this setting.
# If you'd like to display extra data in the project or user tables, set the
# corresponding dict key to the attribute name, followed by the display name.
# For more information, see horizon's customization
# (https://docs.openstack.org/horizon/latest/configuration/
# customizing.html#horizon-customization-module-overrides)
# PROJECT_TABLE_EXTRA_INFO = {
# 'phone_num': _('Phone Number'),
# }
PROJECT_TABLE_EXTRA_INFO = {}
# USER_TABLE_EXTRA_INFO = {
# 'phone_num': _('Phone Number'),
# }
USER_TABLE_EXTRA_INFO = {}
SECURITY_GROUP_RULES = {
'all_tcp': {
'name': _('All TCP'),

View File

@ -597,19 +597,6 @@ SECURITY_GROUP_RULES = {
# of data fetched by default when rendering the Overview panel.
#OVERVIEW_DAYS_RANGE = 1
# Projects and users can have extra attributes as defined by keystone v3.
# Horizon has the ability to display these extra attributes via this setting.
# If you'd like to display extra data in the project or user tables, set the
# corresponding dict key to the attribute name, followed by the display name.
# For more information, see horizon's customization
# (https://docs.openstack.org/horizon/latest/configuration/customizing.html#horizon-customization-module-overrides)
#PROJECT_TABLE_EXTRA_INFO = {
# 'phone_num': _('Phone Number'),
#}
#USER_TABLE_EXTRA_INFO = {
# 'phone_num': _('Phone Number'),
#}
# Password will have an expiration date when using keystone v3 and enabling the
# feature.
# This setting allows you to set the number of days that the user will be alerted