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


import jingrow


def execute():
	jingrow.reload_pagetype("Site")
	domains = jingrow.get_all(
		"Site Domain",
		fields=["site", "domain"],
		filters={"status": "Active"},
		group_by="site",
	)
	for domain in domains:
		site = jingrow.get_pg("Site", domain.site)
		if site.status == "Active":
			site.set_host_name(domain.domain)
