# Copyright (c) 2015, JINGROW and Contributors
# License: MIT. See LICENSE
import jingrow


def add_custom_field(pagetype, fieldname, fieldtype="Data", options=None):
	jingrow.get_pg(
		{
			"pagetype": "Custom Field",
			"dt": pagetype,
			"fieldname": fieldname,
			"fieldtype": fieldtype,
			"options": options,
		}
	).insert()


def clear_custom_fields(pagetype):
	jingrow.db.delete("Custom Field", {"dt": pagetype})
	jingrow.clear_cache(pagetype=pagetype)
