import jingrow

from jcloud.utils import log_error


def execute():
	jingrow.reload_pg("jcloud", "pagetype", "team")
	teams = jingrow.get_all("Team", pluck="name")

	for name in teams:
		try:
			team = jingrow.get_pg("Team", name)
			team.append("communication_emails", {"type": "invoices", "value": team.name})
			team.append(
				"communication_emails", {"type": "marketplace_notifications", "value": team.name}
			)
			team.save()
		except Exception as e:
			log_error(title="Weird Country Name", data=e)
