# Copyright (c) 2024, JINGROW
# For license information, please see license.txt

import jingrow

from jcloud.jcloud.pagetype.site_plan.plan import Plan


class ServerStoragePlan(Plan):
	# 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

		enabled: DF.Check
		price_cny: DF.Currency
		price_usd: DF.Currency
		title: DF.Data | None
	# end: auto-generated types

	def validate(self):
		if self.enabled and jingrow.db.exists(
			"Server Storage Plan", {"enabled": 1, "name": ("!=", self.name)}
		):
			jingrow.throw("Only one storage add-on plan can be enabled at a time")
