# Copyright (c) 2017, JINGROW
# License: MIT. See LICENSE

import jingrow
from jingrow.model.page import Page


class PrintStyle(Page):
	# begin: auto-generated types
	# This code is auto-generated. Do not modify anything in this block.

	from typing import TYPE_CHECKING

	if TYPE_CHECKING:
		from jingrow.types import DF

		css: DF.Code
		disabled: DF.Check
		preview: DF.AttachImage | None
		print_style_name: DF.Data
		standard: DF.Check

	# end: auto-generated types
	def validate(self):
		if (
			self.standard == 1
			and not jingrow.local.conf.get("developer_mode")
			and not (jingrow.flags.in_import or jingrow.flags.in_test)
		):
			jingrow.throw(jingrow._("Standard Print Style cannot be changed. Please duplicate to edit."))

	def on_update(self):
		self.export_pg()

	def export_pg(self):
		# export
		from jingrow.modules.utils import export_module_json

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