add per-service default set of variables (#5841)
This commit is contained in:
parent
a689108198
commit
a9d8481489
|
@ -120,6 +120,15 @@ SERVICE_URL_TEMPLATE = 'https://${app}.example.net'
|
|||
# }
|
||||
SERVICE_TEMPLATES = None
|
||||
|
||||
# SERVICE_EXTRA_VARIABLES: variables to create automatically for the
|
||||
# given service types.
|
||||
#
|
||||
# Example:
|
||||
# SERVICE_EXTRA_VARIABLES = {
|
||||
# 'wcs': ['legal_url', 'commune_url', 'domain_key'],
|
||||
# }
|
||||
SERVICE_EXTRA_VARIABLES = None
|
||||
|
||||
AGENT_HOST_PATTERNS = None
|
||||
AGENT_WCS_APP_DIR = '/var/lib/wcs'
|
||||
AGENT_WCS_COMMAND = '/usr/sbin/wcsctl check-hobos'
|
||||
|
|
|
@ -88,6 +88,16 @@ class ServiceBase(models.Model):
|
|||
def name(self):
|
||||
return self.title
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
is_new = (self.id is None)
|
||||
super(ServiceBase, self).save(*args, **kwargs)
|
||||
if is_new and settings.SERVICE_EXTRA_VARIABLES:
|
||||
for variable in settings.SERVICE_EXTRA_VARIABLES.get(self.Extra.service_id, []):
|
||||
v = Variable()
|
||||
v.name = variable
|
||||
v.service = self
|
||||
v.save()
|
||||
|
||||
|
||||
class Authentic(ServiceBase):
|
||||
class Meta:
|
||||
|
|
Loading…
Reference in New Issue