# Copyright (c) 2017, XhiveFramework Technologies and contributors
# License: MIT. See LICENSE

import xhiveframework
from xhiveframework.model.document import Document


class PrintStyle(Document):
	def validate(self):
		if (
			self.standard == 1
			and not xhiveframework.local.conf.get("developer_mode")
			and not (xhiveframework.flags.in_import or xhiveframework.flags.in_test)
		):

			xhiveframework.throw(xhiveframework._("Standard Print Style cannot be changed. Please duplicate to edit."))

	def on_update(self):
		self.export_doc()

	def export_doc(self):
		# export
		from xhiveframework.modules.utils import export_module_json

		export_module_json(self, self.standard == 1, "Printing")
