def update_owner(cert, new_cert_data):
    """
    Modify owner for certificate. Removes roles and notifications associated with prior owner.
    :param cert: Certificate object to be updated
    :param new_cert_data: Dictionary including cert fields to be updated (owner, notifications, roles).
    These values are set in CertificateEditInputSchema and are generated for the new owner.
    :return:
    """
    # remove all notifications and roles associated with old owner
    cert.roles = new_cert_data["roles"] + [r for r in cert.roles if r.name != cert.owner]
    notification_prefix = f"DEFAULT_{cert.owner.split('@')[0].upper()}"
    cert.notifications = new_cert_data["notifications"] + [n for n in cert.notifications if not n.label.startswith(notification_prefix)]

    cert.owner = new_cert_data["owner"]
    return database.update(cert)

    Modify owner for certificate. Removes roles and notifications associated with prior owner.
    :param cert: Certificate object to be updated
    :param new_cert_data: Dictionary including cert fields to be updated (owner, notifications, roles).
    These values are set in CertificateEditInputSchema and are generated for the new owner.
    :return:
    
lemur/certificates/service.py