misc: don't expose Corbo/Mandayejs/Piwik in UI (#29092)

This commit is contained in:
Frédéric Péters 2018-12-15 19:34:35 +01:00
parent 513db18396
commit 48b16b1a9d
2 changed files with 17 additions and 1 deletions

View File

@ -74,6 +74,10 @@ class ServiceBase(models.Model):
variables = GenericRelation(Variable,
content_type_field='service_type', object_id_field='service_pk')
@classmethod
def is_enabled(cls):
return True
def is_operational(self):
return (self.last_operational_success_timestamp is not None and
self.last_operational_success_timestamp == self.last_operational_check_timestamp)
@ -362,6 +366,10 @@ class MandayeJS(ServiceBase):
service_label = _('mandayejs')
service_default_slug = 'mandayejs'
@classmethod
def is_enabled(cls):
return getattr(settings, 'MANDAYEJS_ENABLED', False)
def get_admin_zones(self):
return [
Zone(self.title, 'mandayejs', self.get_base_url_path() + '_mandaye/admin/')
@ -429,6 +437,10 @@ class Piwik(ServiceBase):
service_label = _('piwik')
service_default_slug = 'piwik'
@classmethod
def is_enabled(cls):
return getattr(settings, 'PIWIK_ENABLED', False)
def get_admin_zones(self):
return [
Zone(self.title, 'piwik', self.get_base_url_path())
@ -446,6 +458,10 @@ class Corbo(ServiceBase):
service_label = _('Corbo')
service_default_slug = 'announces'
@classmethod
def is_enabled(cls):
return getattr(settings, 'CORBO_ENABLED', False)
def get_admin_zones(self):
return [
Zone(self.title, 'corbo', self.get_base_url_path() + 'admin/')

View File

@ -26,7 +26,7 @@ class HomeView(TemplateView):
context = super(HomeView, self).get_context_data(**kwargs)
context['url_template'] = settings.SERVICE_URL_TEMPLATE
context['available_services'] = [
AvailableService(x) for x in AVAILABLE_SERVICES]
AvailableService(x) for x in AVAILABLE_SERVICES if x.is_enabled()]
context['installed_services'] = [x for x in utils.get_installed_services() if not x.secondary]
return context