do not expose legacy features (#28512)
This commit is contained in:
parent
76dcfc2ff2
commit
80784d047b
|
@ -85,21 +85,26 @@ class PanelDirectory(Directory):
|
||||||
form.add(SingleSelectWidget, 'forms', title = _('Admin role for forms'),
|
form.add(SingleSelectWidget, 'forms', title = _('Admin role for forms'),
|
||||||
value = permissions_cfg.get('forms', None),
|
value = permissions_cfg.get('forms', None),
|
||||||
options = [(None, _('Nobody'), None)] + get_user_roles())
|
options = [(None, _('Nobody'), None)] + get_user_roles())
|
||||||
form.add(SingleSelectWidget, 'events', title = _('Admin role for events'),
|
if get_publisher().has_site_option('auquotidien-events'):
|
||||||
value = permissions_cfg.get('events', None),
|
form.add(SingleSelectWidget, 'events', title = _('Admin role for events'),
|
||||||
options = [(None, _('Nobody'), None)] + get_user_roles())
|
value = permissions_cfg.get('events', None),
|
||||||
form.add(SingleSelectWidget, 'links', title = _('Admin role for links'),
|
options = [(None, _('Nobody'), None)] + get_user_roles())
|
||||||
value = permissions_cfg.get('links', None),
|
if get_publisher().has_site_option('auquotidien-links'):
|
||||||
options = [(None, _('Nobody'), None)] + get_user_roles())
|
form.add(SingleSelectWidget, 'links', title = _('Admin role for links'),
|
||||||
form.add(SingleSelectWidget, 'announces', title = _('Admin role for announces'),
|
value = permissions_cfg.get('links', None),
|
||||||
value = permissions_cfg.get('announces', None),
|
options = [(None, _('Nobody'), None)] + get_user_roles())
|
||||||
options = [(None, _('Nobody'), None)] + get_user_roles())
|
if get_publisher().has_site_option('auquotidien-announces'):
|
||||||
form.add(SingleSelectWidget, 'payments', title = _('Admin role for payments'),
|
form.add(SingleSelectWidget, 'announces', title = _('Admin role for announces'),
|
||||||
value = permissions_cfg.get('payments', None),
|
value = permissions_cfg.get('announces', None),
|
||||||
options = [(None, _('Nobody'), None)] + get_user_roles())
|
options = [(None, _('Nobody'), None)] + get_user_roles())
|
||||||
form.add(SingleSelectWidget, 'strongbox', title = _('Admin role for strongbox'),
|
if get_publisher().has_site_option('auquotidien-payments'):
|
||||||
value = permissions_cfg.get('strongbox', None),
|
form.add(SingleSelectWidget, 'payments', title = _('Admin role for payments'),
|
||||||
options = [(None, _('Nobody'), None)] + get_user_roles())
|
value = permissions_cfg.get('payments', None),
|
||||||
|
options = [(None, _('Nobody'), None)] + get_user_roles())
|
||||||
|
if get_publisher().has_site_option('auquotidien-strongbox'):
|
||||||
|
form.add(SingleSelectWidget, 'strongbox', title = _('Admin role for strongbox'),
|
||||||
|
value = permissions_cfg.get('strongbox', None),
|
||||||
|
options = [(None, _('Nobody'), None)] + get_user_roles())
|
||||||
form.add_submit('submit', _('Submit'))
|
form.add_submit('submit', _('Submit'))
|
||||||
form.add_submit('cancel', _('Cancel'))
|
form.add_submit('cancel', _('Cancel'))
|
||||||
|
|
||||||
|
@ -256,16 +261,25 @@ class PanelDirectory(Directory):
|
||||||
|
|
||||||
class SettingsDirectory(wcs.admin.settings.SettingsDirectory):
|
class SettingsDirectory(wcs.admin.settings.SettingsDirectory):
|
||||||
def _q_index(self):
|
def _q_index(self):
|
||||||
|
if not (get_publisher().has_site_option('auquotidien-announces') or
|
||||||
|
get_publisher().has_site_option('auquotidien-links') or
|
||||||
|
get_publisher().has_site_option('auquotidien-events') or
|
||||||
|
get_publisher().has_site_option('auquotidien-payments') or
|
||||||
|
get_publisher().has_site_option('auquotidien-strongvox')):
|
||||||
|
return super(SettingsDirectory, self)._q_index()
|
||||||
r = TemplateIO(html=True)
|
r = TemplateIO(html=True)
|
||||||
r += htmltext(super(SettingsDirectory, self)._q_index())
|
r += htmltext(super(SettingsDirectory, self)._q_index())
|
||||||
r += htmltext('<div class="splitcontent-right">')
|
r += htmltext('<div class="splitcontent-right">')
|
||||||
r += htmltext('<div class="bo-block">')
|
r += htmltext('<div class="bo-block">')
|
||||||
r += htmltext('<h2>%s</h2>') % _('Extra Options')
|
r += htmltext('<h2>%s</h2>') % _('Extra Options')
|
||||||
r += htmltext('<ul>')
|
r += htmltext('<ul>')
|
||||||
r += htmltext('<li><a href="aq/announces">%s</a></li>') % _('Announces Options')
|
if get_publisher().has_site_option('auquotidien-announces'):
|
||||||
|
r += htmltext('<li><a href="aq/announces">%s</a></li>') % _('Announces Options')
|
||||||
r += htmltext('<li><a href="aq/permissions">%s</a></li>') % _('Permissions')
|
r += htmltext('<li><a href="aq/permissions">%s</a></li>') % _('Permissions')
|
||||||
r += htmltext('<li><a href="aq/event_keywords">%s</a></li>') % _('Event Keywords')
|
if get_publisher().has_site_option('auquotidien-events'):
|
||||||
r += htmltext('<li><a href="aq/announce_themes">%s</a></li>') % _('Announce Themes')
|
r += htmltext('<li><a href="aq/event_keywords">%s</a></li>') % _('Event Keywords')
|
||||||
|
if get_publisher().has_site_option('auquotidien-announces'):
|
||||||
|
r += htmltext('<li><a href="aq/announce_themes">%s</a></li>') % _('Announce Themes')
|
||||||
if get_publisher().has_site_option('strongbox'):
|
if get_publisher().has_site_option('strongbox'):
|
||||||
r += htmltext('<li><a href="aq/strongbox">%s</a></li>') % _('Strongbox Support')
|
r += htmltext('<li><a href="aq/strongbox">%s</a></li>') % _('Strongbox Support')
|
||||||
if get_publisher().has_site_option('clicrdv'):
|
if get_publisher().has_site_option('clicrdv'):
|
||||||
|
|
|
@ -18,6 +18,9 @@ from qommon.form import *
|
||||||
CURRENT_USER = object()
|
CURRENT_USER = object()
|
||||||
|
|
||||||
def check_visibility(target, user=CURRENT_USER):
|
def check_visibility(target, user=CURRENT_USER):
|
||||||
|
if not get_publisher().has_site_option('auquotidien-%s' % target):
|
||||||
|
# option not explicitely enabled, -> off.
|
||||||
|
return False
|
||||||
if user is CURRENT_USER:
|
if user is CURRENT_USER:
|
||||||
user = get_request().user
|
user = get_request().user
|
||||||
if not user:
|
if not user:
|
||||||
|
|
|
@ -65,6 +65,10 @@ def create_role():
|
||||||
def teardown_module(module):
|
def teardown_module(module):
|
||||||
shutil.rmtree(pub.APP_DIR)
|
shutil.rmtree(pub.APP_DIR)
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def empty_siteoptions():
|
||||||
|
open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w').close()
|
||||||
|
|
||||||
def test_with_superuser():
|
def test_with_superuser():
|
||||||
create_superuser()
|
create_superuser()
|
||||||
app = login(get_app(pub))
|
app = login(get_app(pub))
|
||||||
|
@ -85,18 +89,40 @@ def test_general_admin_permissions():
|
||||||
del pub.cfg['admin-permissions']
|
del pub.cfg['admin-permissions']
|
||||||
pub.write_cfg()
|
pub.write_cfg()
|
||||||
|
|
||||||
def test_aq_permissions_panel():
|
def test_aq_permissions_panel(empty_siteoptions):
|
||||||
create_superuser()
|
create_superuser()
|
||||||
app = login(get_app(pub))
|
app = login(get_app(pub))
|
||||||
|
resp = app.get('/backoffice/settings/')
|
||||||
|
assert not 'aq/permissions' in resp.body
|
||||||
|
|
||||||
|
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||||
|
if not pub.site_options.has_section('options'):
|
||||||
|
pub.site_options.add_section('options')
|
||||||
|
pub.site_options.set('options', 'auquotidien-links', 'true')
|
||||||
|
pub.site_options.write(fd)
|
||||||
|
|
||||||
resp = app.get('/backoffice/settings/')
|
resp = app.get('/backoffice/settings/')
|
||||||
assert 'aq/permissions' in resp.body
|
assert 'aq/permissions' in resp.body
|
||||||
resp = app.get('/backoffice/settings/aq/permissions')
|
resp = app.get('/backoffice/settings/aq/permissions')
|
||||||
|
|
||||||
def test_menu_items():
|
def test_menu_items(empty_siteoptions):
|
||||||
create_superuser()
|
create_superuser()
|
||||||
role = create_role()
|
role = create_role()
|
||||||
|
|
||||||
|
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||||
|
if not pub.site_options.has_section('options'):
|
||||||
|
pub.site_options.add_section('options')
|
||||||
|
pub.site_options.set('options', 'auquotidien-links', 'true')
|
||||||
|
pub.site_options.write(fd)
|
||||||
|
|
||||||
for area in ('links', 'announces', 'events', 'links', 'payments'):
|
for area in ('links', 'announces', 'events', 'links', 'payments'):
|
||||||
|
|
||||||
|
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||||
|
if not pub.site_options.has_section('options'):
|
||||||
|
pub.site_options.add_section('options')
|
||||||
|
pub.site_options.set('options', 'auquotidien-%s' % area, 'true')
|
||||||
|
pub.site_options.write(fd)
|
||||||
|
|
||||||
pub.cfg['aq-permissions'] = {area: None}
|
pub.cfg['aq-permissions'] = {area: None}
|
||||||
pub.write_cfg()
|
pub.write_cfg()
|
||||||
|
|
||||||
|
|
Reference in New Issue