From 1ba718106771c696511289d20f4daf6e17964fc3 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Thu, 7 Jul 2016 11:44:11 -0700 Subject: [PATCH] =?UTF-8?q?Fixed=20an=20issue=20were=20default=20notificat?= =?UTF-8?q?ions=20were=20added=20even=20when=20updati=E2=80=A6=20(#395)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed an issue were default notifications were added even when updating a certificate, resulting in duplicate notifications. * Ensuring imported certificates get the same treatment. --- lemur/certificates/schemas.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lemur/certificates/schemas.py b/lemur/certificates/schemas.py index dc16e25c..c4ce7f28 100644 --- a/lemur/certificates/schemas.py +++ b/lemur/certificates/schemas.py @@ -28,8 +28,10 @@ class CertificateSchema(LemurInputSchema): owner = fields.Email(required=True) description = fields.String() + +class CertificateCreationSchema(CertificateSchema): @post_load - def default_notifications(self, data): + def default_notification(self, data): if not data['notifications']: notification_name = "DEFAULT_{0}".format(data['owner'].split('@')[0].upper()) data['notifications'] += notification_service.create_default_expiration_notifications(notification_name, [data['owner']]) @@ -39,7 +41,7 @@ class CertificateSchema(LemurInputSchema): return data -class CertificateInputSchema(CertificateSchema): +class CertificateInputSchema(CertificateCreationSchema): name = fields.String() common_name = fields.String(required=True, validate=validators.sensitive_domain) authority = fields.Nested(AssociatedAuthoritySchema, required=True) @@ -127,7 +129,7 @@ class CertificateOutputSchema(LemurOutputSchema): endpoints = fields.Nested(EndpointNestedOutputSchema, many=True, missing=[]) -class CertificateUploadInputSchema(CertificateSchema): +class CertificateUploadInputSchema(CertificateCreationSchema): name = fields.String() active = fields.Boolean(missing=True)