settings: mark options set by hobo as readonly (#44756) #844
|
@ -82,7 +82,9 @@ def test_settings_disabled_screens(pub):
|
|||
|
||||
if not pub.site_options.has_section('options'):
|
||||
pub.site_options.add_section('options')
|
||||
pub.site_options.set('options', 'settings-disabled-screens', 'identification, import-export, geolocation')
|
||||
pub.site_options.set(
|
||||
'options', 'settings-disabled-screens', 'identification, import-export, geolocation, smtp'
|
||||
)
|
||||
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
pub.site_options.write(fd)
|
||||
resp = app.get('/backoffice/settings/')
|
||||
|
@ -93,6 +95,9 @@ def test_settings_disabled_screens(pub):
|
|||
app.get('/backoffice/settings/export', status=404)
|
||||
app.get('/backoffice/settings/geolocation', status=404)
|
||||
|
||||
resp = app.get('/backoffice/settings/emails/options')
|
||||
assert not resp.pyquery('#form_smtp_server')
|
||||
|
||||
pub.site_options.set('options', 'settings-disabled-screens', '')
|
||||
pub.site_options.set('options', 'settings-hidden-screens', 'import-export')
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
|
@ -1036,3 +1041,18 @@ def test_submission_channels(pub):
|
|||
|
||||
resp = app.get('/backoffice/settings/submission-channels')
|
||||
assert resp.form['include-in-global-listing'].checked
|
||||
|
||||
|
||||
def test_hobo_locked_settings(pub):
|
||||
create_superuser(pub)
|
||||
app = login(get_app(pub))
|
||||
app.get('/backoffice/settings/')
|
||||
resp = app.get('/backoffice/settings/sitename')
|
||||
assert not resp.pyquery('#form_sitename').attr.readonly
|
||||
hobo_json_path = os.path.join(pub.app_dir, 'hobo.json')
|
||||
try:
|
||||
with open(hobo_json_path, 'w'):
|
||||
resp = app.get('/backoffice/settings/sitename')
|
||||
assert resp.pyquery('#form_sitename').attr.readonly
|
||||
fpeters
commented
Et un deuxième commit qui en présence d'un déploiement via hobo (via la présence du fichier hobo.json), marque en lecture seule les paramètres qui en viennent. (ici sitename, mais aussi les paramètres de footer d'email, de connecteur sms, etc.). Et un deuxième commit qui en présence d'un déploiement via hobo (via la présence du fichier hobo.json), marque en lecture seule les paramètres qui en viennent. (ici sitename, mais aussi les paramètres de footer d'email, de connecteur sms, etc.).
|
||||
finally:
|
||||
os.unlink(hobo_json_path)
|
||||
|
|
|
@ -39,7 +39,7 @@ from wcs.data_sources import NamedDataSource
|
|||
from wcs.fields.map import MapOptionsMixin
|
||||
from wcs.formdef import FormDef, FormdefImportError, get_formdefs_of_all_kinds
|
||||
from wcs.qommon import _, errors, get_cfg, ident, misc, template
|
||||
from wcs.qommon.admin.cfg import cfg_submit
|
||||
from wcs.qommon.admin.cfg import cfg_submit, hobo_kwargs
|
||||
from wcs.qommon.admin.emails import EmailsDirectory
|
||||
from wcs.qommon.admin.texts import TextsDirectory
|
||||
from wcs.qommon.afterjobs import AfterJob
|
||||
|
@ -92,6 +92,7 @@ class IdentificationDirectory(Directory):
|
|||
options=methods,
|
||||
inline=False,
|
||||
required=True,
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
|
||||
form.add_submit('submit', _('Submit'))
|
||||
|
@ -1012,13 +1013,20 @@ class SettingsDirectory(AccessControlled, Directory):
|
|||
def sitename(self):
|
||||
form = Form(enctype='multipart/form-data')
|
||||
misc_cfg = get_cfg('misc', {})
|
||||
form.add(StringWidget, 'sitename', title=_('Site Name'), value=misc_cfg.get('sitename', ''))
|
||||
form.add(
|
||||
StringWidget,
|
||||
'sitename',
|
||||
title=_('Site Name'),
|
||||
value=misc_cfg.get('sitename', ''),
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
'frontoffice-url',
|
||||
size=32,
|
||||
title=_('Site base URL'),
|
||||
value=misc_cfg.get('frontoffice-url', ''),
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
|
@ -1051,8 +1059,20 @@ class SettingsDirectory(AccessControlled, Directory):
|
|||
r += htmltext('<h2>%s</h2>') % _('SMS Options')
|
||||
sms_cfg = get_cfg('sms', {})
|
||||
form = Form(enctype='multipart/form-data')
|
||||
form.add(StringWidget, 'sender', title=_('Sender (number or name)'), value=sms_cfg.get('sender'))
|
||||
form.add(StringWidget, 'passerelle_url', title=_('URL'), value=sms_cfg.get('passerelle_url'))
|
||||
form.add(
|
||||
StringWidget,
|
||||
'sender',
|
||||
title=_('Sender (number or name)'),
|
||||
value=sms_cfg.get('sender'),
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
'passerelle_url',
|
||||
title=_('URL'),
|
||||
value=sms_cfg.get('passerelle_url'),
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
form.add_submit('submit', _('Submit'))
|
||||
form.add_submit('cancel', _('Cancel'))
|
||||
|
||||
|
@ -1077,6 +1097,7 @@ class SettingsDirectory(AccessControlled, Directory):
|
|||
title=_('Database Name'),
|
||||
required=True,
|
||||
value=postgresql_cfg.get('database'),
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
|
@ -1084,7 +1105,7 @@ class SettingsDirectory(AccessControlled, Directory):
|
|||
title=_('User'),
|
||||
required=False,
|
||||
value=postgresql_cfg.get('user'),
|
||||
hint=_('User name used to authenticate'),
|
||||
**hobo_kwargs(hint=_('User name used to authenticate')),
|
||||
)
|
||||
form.add(
|
||||
PasswordWidget,
|
||||
|
@ -1092,7 +1113,7 @@ class SettingsDirectory(AccessControlled, Directory):
|
|||
title=_('Password'),
|
||||
required=False,
|
||||
value=postgresql_cfg.get('password'),
|
||||
hint=_('Password used to authenticate'),
|
||||
**hobo_kwargs(hint=_('Password used to authenticate')),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
|
@ -1100,14 +1121,19 @@ class SettingsDirectory(AccessControlled, Directory):
|
|||
title=_('Host'),
|
||||
required=False,
|
||||
value=postgresql_cfg.get('host'),
|
||||
hint=_('Database host address'),
|
||||
**hobo_kwargs(hint=_('Database host address')),
|
||||
)
|
||||
try:
|
||||
port = int(postgresql_cfg.get('port'))
|
||||
except (ValueError, TypeError):
|
||||
port = None
|
||||
form.add(
|
||||
IntWidget, 'port', title=_('Port'), required=False, value=port, hint=_('Connection port number')
|
||||
IntWidget,
|
||||
'port',
|
||||
title=_('Port'),
|
||||
required=False,
|
||||
value=port,
|
||||
**hobo_kwargs(hint=_('Connection port number')),
|
||||
)
|
||||
form.add_submit('submit', _('Submit'))
|
||||
form.add_submit('cancel', _('Cancel'))
|
||||
|
|
|
@ -14,9 +14,17 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
|
||||
from quixote import get_publisher
|
||||
|
||||
from .. import get_cfg
|
||||
from .. import _, get_cfg
|
||||
|
||||
|
||||
def hobo_kwargs(**kwargs):
|
||||
if os.path.exists(os.path.join(get_publisher().tenant.directory, 'hobo.json')):
|
||||
kwargs.update({'readonly': True, 'hint': _('This setting is locked-down by deployment.')})
|
||||
tnoel
commented
Plutôt ajouter un "hint" que remplacer le "title" ? Plutôt ajouter un "hint" que remplacer le "title" ?
fpeters
commented
Oui ok, en écrasant la remarque si jamais elle existait (comme le champ ne peut pas être modifié, pas bien grave de la perdre, je pense). Oui ok, en écrasant la remarque si jamais elle existait (comme le champ ne peut pas être modifié, pas bien grave de la perdre, je pense).
|
||||
return kwargs
|
||||
|
||||
|
||||
def cfg_submit(form, cfg_key, fields):
|
||||
|
|
|
@ -19,7 +19,7 @@ from quixote.directory import Directory
|
|||
from quixote.html import TemplateIO, htmltext
|
||||
|
||||
from .. import _, get_cfg
|
||||
from ..admin.cfg import cfg_submit
|
||||
from ..admin.cfg import cfg_submit, hobo_kwargs
|
||||
from ..form import CheckboxWidget, Form, StringWidget, TextWidget, WidgetList
|
||||
|
||||
|
||||
|
@ -75,29 +75,42 @@ class EmailsDirectory(Directory):
|
|||
|
||||
def options(self):
|
||||
form = Form(enctype='multipart/form-data')
|
||||
disabled_screens = '%s,%s' % (
|
||||
get_publisher().get_site_option('settings-disabled-screens') or '',
|
||||
get_publisher().get_site_option('settings-hidden-screens') or '',
|
||||
)
|
||||
disabled_smtp_options = 'smtp' in [x.strip() for x in disabled_screens.split(',')]
|
||||
emails = get_cfg('emails', {})
|
||||
if not disabled_smtp_options:
|
||||
form.add(
|
||||
StringWidget,
|
||||
'smtp_server',
|
||||
title=_('SMTP Server'),
|
||||
required=False,
|
||||
value=emails.get('smtp_server', ''),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
'smtp_login',
|
||||
title=_('SMTP Login'),
|
||||
required=False,
|
||||
value=emails.get('smtp_login', ''),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
'smtp_password',
|
||||
title=_('SMTP Password'),
|
||||
required=False,
|
||||
value=emails.get('smtp_password', ''),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
'smtp_server',
|
||||
title=_('SMTP Server'),
|
||||
required=False,
|
||||
value=emails.get('smtp_server', ''),
|
||||
'from',
|
||||
title=_('Email Sender'),
|
||||
required=True,
|
||||
value=emails.get('from'),
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
'smtp_login',
|
||||
title=_('SMTP Login'),
|
||||
required=False,
|
||||
value=emails.get('smtp_login', ''),
|
||||
)
|
||||
form.add(
|
||||
StringWidget,
|
||||
'smtp_password',
|
||||
title=_('SMTP Password'),
|
||||
required=False,
|
||||
value=emails.get('smtp_password', ''),
|
||||
)
|
||||
form.add(StringWidget, 'from', title=_('Email Sender'), required=True, value=emails.get('from'))
|
||||
form.add(
|
||||
StringWidget,
|
||||
'reply_to',
|
||||
|
@ -113,6 +126,7 @@ class EmailsDirectory(Directory):
|
|||
rows=5,
|
||||
required=False,
|
||||
value=emails.get('footer'),
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
form.add(
|
||||
CheckboxWidget,
|
||||
|
|
|
@ -31,6 +31,7 @@ from quixote.directory import Directory
|
|||
from quixote.html import TemplateIO, htmltext
|
||||
|
||||
from .. import _, errors, get_cfg, misc, saml2utils, template, x509utils
|
||||
from ..admin.cfg import cfg_submit, hobo_kwargs
|
||||
from ..admin.menu import command_icon
|
||||
from ..form import (
|
||||
CheckboxWidget,
|
||||
|
@ -732,6 +733,7 @@ class MethodAdminDirectory(Directory):
|
|||
'idp-manage-user-attributes',
|
||||
title=_('IdP manage user attributes'),
|
||||
value=get_cfg('sp', {}).get('idp-manage-user-attributes', False),
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
|
||||
form.add(
|
||||
|
@ -739,6 +741,7 @@ class MethodAdminDirectory(Directory):
|
|||
'idp-manage-roles',
|
||||
title=_('IdP manage roles'),
|
||||
value=get_cfg('sp', {}).get('idp-manage-roles', False),
|
||||
**hobo_kwargs(),
|
||||
)
|
||||
|
||||
form.add_submit('submit', _('Submit'))
|
||||
|
@ -893,8 +896,6 @@ class MethodAdminDirectory(Directory):
|
|||
return r.getvalue()
|
||||
|
||||
def identities_submit(self, form):
|
||||
from wcs.qommon.admin.cfg import cfg_submit
|
||||
|
||||
cfg_submit(form, 'saml_identities', ('registration-url',))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Un premier commit qui ajoute une valeur "smtp" pour settings-disabled-screens, pour ne pas afficher les options smtp_server, smtp_login, smtp_password.