# -*- coding: utf-8 -*-
# Copyright (c) 2021, JINGROW
# For license information, please see license.txt


import jingrow


def execute():
	jingrow.reload_pg("jcloud", "pagetype", "site_domain")
	jingrow.reload_pg("jcloud", "pagetype", "tls_certificate")
	certificates = jingrow.get_all(
		"TLS Certificate", ["name", "domain"], {"wildcard": False}
	)
	for certificate in certificates:
		team = jingrow.db.get_value("Site Domain", certificate.domain, "team")
		jingrow.db.set_value("TLS Certificate", certificate.name, "team", team)
