Commit 370ee905 authored by lukas.burgey's avatar lukas.burgey

Rework when we're publishing to the clients and users

parent 9c96a3cb
......@@ -180,6 +180,7 @@ class VODeployment(Deployment):
if created:
LOGGER.debug(deployment.msg('Created'))
LOGGER.debug('VO has services: %s', vo.services.all())
for service in vo.services.all():
DeploymentState.get_or_create(user, service, deployment)
......@@ -215,6 +216,7 @@ class ServiceDeployment(Deployment):
if created:
LOGGER.debug(deployment.msg('Created'))
LOGGER.debug('Service exists: %s', service)
DeploymentState.get_or_create(user, service, deployment)
return deployment
......@@ -429,12 +431,11 @@ class DeploymentState(models.Model):
self.audit_log_response()
LOGGER.debug(self.msg('Patched by client: {} - {}'.format(self.state, self.message)))
self.publish_to_user()
if self.state == NOT_DEPLOYED and self.is_orphaned:
# publish one last time so the webpage displays "not_deployed"
self.publish_to_user()
LOGGER.debug(self.msg('Deleting'))
# don't delete 'self' but the DepState via its id
DeploymentState.objects.get(id=self.id).delete()
return
......@@ -452,8 +453,6 @@ class DeploymentState(models.Model):
self.failed_attempts = 0
self.save()
self.publish_to_user()
# called when one of our deployments changes its state_target or when we are first created
def dep_target_changed(self):
LOGGER.debug(self.msg('Deployment changed'))
......@@ -466,7 +465,7 @@ class DeploymentState(models.Model):
# target -> state -> transition
state_transitions = {
DEPLOYED: {
NOT_DEPLOYED: DEPLOYMENT_PENDING, # needs to get deployed
NOT_DEPLOYED: [DEPLOYMENT_PENDING, self.publish_to_client], # needs to get deployed
REMOVAL_PENDING: DEPLOYED, # aborting a removal
DEPLOYED: None, # already reached correct state
DEPLOYMENT_PENDING: None, # already on the way to the correct state
......@@ -496,8 +495,8 @@ class DeploymentState(models.Model):
# state_target -> state -> transition
state_transitions = {
DEPLOYED: {
DEPLOYED: self.publish_to_client, # the user updated the answers
FAILED: self.publish_to_client, # maybe changed answers solve the problem
DEPLOYED: [DEPLOYMENT_PENDING, self.publish_to_client], # the user updated the answers
FAILED: [DEPLOYMENT_PENDING, self.publish_to_client], # maybe changed answers solve the problem
QUESTIONNAIRE: [DEPLOYMENT_PENDING, self.publish_to_client], # answers were needed for deploying
},
NOT_DEPLOYED: {
......@@ -561,6 +560,8 @@ class DeploymentState(models.Model):
self.save()
self.publish_to_user() # always publish to the use when the state changes
else:
LOGGER.debug(self.msg('State unchanged: {}'.format(self.state)))
def publish_to_user(self):
if self.user is None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment