Address a variety of small review issues

This commit is contained in:
Jeff Bradberry
2019-09-27 15:07:23 -04:00
parent 6aa6471b7c
commit b6b70e55fb
6 changed files with 22 additions and 18 deletions

View File

@@ -496,8 +496,8 @@ class WebhookTemplateMixin(models.Model):
abstract = True
SERVICES = [
('github', "Github"),
('gitlab', "Gitlab"),
('github', "GitHub"),
('gitlab', "GitLab"),
]
webhook_service = models.CharField(
@@ -583,7 +583,7 @@ class WebhookMixin(models.Model):
'pending': 'pending',
'successful': 'success',
'failed': 'failure',
'canceled': 'failure', # Github doesn't have a 'canceled' status :(
'canceled': 'failure', # GitHub doesn't have a 'canceled' status :(
'error': 'error',
},
'gitlab': {
@@ -591,7 +591,7 @@ class WebhookMixin(models.Model):
'running': 'running',
'successful': 'success',
'failed': 'failed',
'error': 'failed', # Gitlab doesn't have an 'error' status distinct from 'failed' :(
'error': 'failed', # GitLab doesn't have an 'error' status distinct from 'failed' :(
'canceled': 'canceled',
},
}
@@ -611,7 +611,7 @@ class WebhookMixin(models.Model):
k: v.format(self.webhook_credential.get_input('token')),
'Content-Type': 'application/json'
}
response = requests.post(status_api, data=json.dumps(data), headers=headers)
response = requests.post(status_api, data=json.dumps(data), headers=headers, timeout=30)
except Exception:
logger.exception("Posting webhook status caused an error.")
return