hobo: add setting to disable/enable a type of service (#72335)
HOBO_SERVICES_DISABLED is used in hobo/settings.py to list deprecated or services still not in production. HOBO_SERVICES_ENABLED is used through config.json to enable a new service. ServiceBase.is_enabled() is modified to use those settings
This commit is contained in:
parent
89096f8def
commit
12b1b5096b
|
@ -117,7 +117,8 @@ class ServiceBase(models.Model):
|
|||
|
||||
@classmethod
|
||||
def is_enabled(cls):
|
||||
return True
|
||||
name = cls.__name__.lower()
|
||||
return name not in settings.HOBO_SERVICES_DISABLED or name in settings.HOBO_SERVICES_ENABLED
|
||||
|
||||
def is_operational(self):
|
||||
return (
|
||||
|
|
|
@ -228,6 +228,16 @@ MELLON_USERNAME_TEMPLATE = '{attributes[name_id_content]}'
|
|||
|
||||
MATOMO_SERVER = {}
|
||||
|
||||
# List of service class names to hide from the create service menu.
|
||||
HOBO_SERVICES_DISABLED = [
|
||||
'bijoe',
|
||||
'fargo',
|
||||
'lingo',
|
||||
'welco',
|
||||
]
|
||||
# List of service to show in the create service menu, it overrides HOBO_SERVICES_DISABLED.
|
||||
HOBO_SERVICES_ENABLED = []
|
||||
|
||||
local_settings_file = os.environ.get(
|
||||
'HOBO_SETTINGS_FILE', os.path.join(os.path.dirname(__file__), 'local_settings.py')
|
||||
)
|
||||
|
|
|
@ -155,7 +155,7 @@ def test_service_creation_url_validation(app, admin_user, monkeypatch):
|
|||
assert Combo.objects.exists()
|
||||
|
||||
|
||||
def test_home_view(app, admin_user):
|
||||
def test_home_view(app, admin_user, settings):
|
||||
app = login(app)
|
||||
combo = Combo.objects.create(
|
||||
base_url='https://combo.agglo.love', template_name='...portal-user...', slug='portal'
|
||||
|
@ -165,8 +165,31 @@ def test_home_view(app, admin_user):
|
|||
for service in AVAILABLE_SERVICES:
|
||||
if service.is_enabled():
|
||||
assert str(service._meta.verbose_name) in response.text
|
||||
enabled_services = {elt.attr['data-service'] for elt in response.pyquery('#new-service a').items()}
|
||||
assert enabled_services == {
|
||||
'authentic',
|
||||
'chrono',
|
||||
'combo',
|
||||
'hobo',
|
||||
'passerelle',
|
||||
'wcs',
|
||||
}
|
||||
assert response.html.find('span', {'class': 'slug'}).a.text == 'https://combo.agglo.love/'
|
||||
|
||||
# check HOBO_SERVICES_ENABLED works
|
||||
settings.HOBO_SERVICES_ENABLED = ['lingo']
|
||||
response = response.goto('')
|
||||
enabled_services = {elt.attr['data-service'] for elt in response.pyquery('#new-service a').items()}
|
||||
assert enabled_services == {
|
||||
'authentic',
|
||||
'chrono',
|
||||
'combo',
|
||||
'hobo',
|
||||
'passerelle',
|
||||
'wcs',
|
||||
'lingo',
|
||||
}
|
||||
|
||||
# add legacy urls
|
||||
combo.change_base_url('https://combo1.agglo.love')
|
||||
combo.save()
|
||||
|
|
Loading…
Reference in New Issue