From ea5204d47152a5954ad657b97549da48f2c28a49 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 24 Jul 2018 13:43:03 +0200 Subject: [PATCH] Fixes for review feedbacks --- server_environment/__init__.py | 4 +++- server_environment/models/server_env_mixin.py | 11 ++++++----- server_environment/tests/testfiles/default/base.conf | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/server_environment/__init__.py b/server_environment/__init__.py index 0ff0f53..aab9a42 100644 --- a/server_environment/__init__.py +++ b/server_environment/__init__.py @@ -18,8 +18,10 @@ # ############################################################################## from . import models +# TODO when migrating to 12, fix the import of serv_config by renaming the +# file? # Add an alias to access to the 'serv_config' module as it is shadowed -# the next line by an import of a variable with the same name. +# in the following line by an import of a variable with the same name. # We can't change the import of serv_config for backward compatibility. from . import serv_config as server_env from .serv_config import serv_config, setboolean diff --git a/server_environment/models/server_env_mixin.py b/server_environment/models/server_env_mixin.py index 98a80d3..5805e88 100644 --- a/server_environment/models/server_env_mixin.py +++ b/server_environment/models/server_env_mixin.py @@ -43,10 +43,11 @@ class ServerEnvMixin(models.AbstractModel): :meth:`~_server_env_global_section_name`. For each field transformed to an env-computed field, a companion field - ``_env_default`` is automatically created. When it's value is set - and the configuration files do not contain a key, the env-computed field - uses the default value stored in database. If a key is empty, the - env-computed field has an empty value. + ``_env_default`` is automatically created. When its value is set + and the configuration files do not contain a key for that field, the + env-computed field uses the default value stored in database. If there is a + key for this field but it is empty, the env-computed field has an empty + value. Env-computed fields are conditionally editable, based on the absence of their key in environment configuration files. When edited, their @@ -295,7 +296,7 @@ class ServerEnvMixin(models.AbstractModel): is_editable_field = self._server_env_is_editable_fieldname(field) for elem in view_arch.findall(field_xpath % field): # set env-computed fields to readonly if the configuration - # files have a key + # files have a key set for this field elem.set('attrs', str({'readonly': [(is_editable_field, '=', False)]})) if not view_arch.findall(field_xpath % is_editable_field): diff --git a/server_environment/tests/testfiles/default/base.conf b/server_environment/tests/testfiles/default/base.conf index 566de2b..434afc2 100644 --- a/server_environment/tests/testfiles/default/base.conf +++ b/server_environment/tests/testfiles/default/base.conf @@ -1,4 +1,4 @@ [external_service.ftp] host = sftp.example.com user = foo -password = bar \ No newline at end of file +password = bar