update DOCTYPES to PAGETYPES

This commit is contained in:
jingrow 2025-12-23 23:00:13 +08:00
parent e4645407fc
commit 3f6f130113
3 changed files with 6 additions and 6 deletions

View File

@ -23,7 +23,7 @@ from jcloude.utils import has_role
if typing.TYPE_CHECKING:
from jingrow.model.meta import Meta
ALLOWED_DOCTYPES = [
ALLOWED_PAGETYPES = [
"Site",
"Site App",
"Site Domain",
@ -483,7 +483,7 @@ def is_allowed_table_field(pagetype, field):
def check_permissions(pagetype):
if pagetype not in ALLOWED_DOCTYPES:
if pagetype not in ALLOWED_PAGETYPES:
raise_not_permitted()
if not hasattr(jingrow.local, "team") or not jingrow.local.team():

View File

@ -5,8 +5,8 @@ import jingrow
def execute():
DOCTYPES = ["Server", "Database Server"]
for pagetype in DOCTYPES:
PAGETYPES = ["Server", "Database Server"]
for pagetype in PAGETYPES:
server_names = jingrow.get_all(
pagetype,
{"status": ("!=", "Archived"), "virtual_machine": ("is", "set")},

View File

@ -115,7 +115,7 @@ if TYPE_CHECKING:
from jcloude.jcloude.pagetype.site_domain.site_domain import SiteDomain
from jcloude.jcloude.pagetype.tls_certificate.tls_certificate import TLSCertificate
DOCTYPE_SERVER_TYPE_MAP = {
PAGETYPE_SERVER_TYPE_MAP = {
"Server": "Application",
"Database Server": "Database",
"Proxy Server": "Proxy",
@ -934,7 +934,7 @@ class Site(Page, TagHelpers):
mountpoint = server.guess_data_disk_mountpoint()
free_space = server.free_space(mountpoint)
if (diff := free_space - space_required) <= 0:
msg = f"Insufficient estimated space on {DOCTYPE_SERVER_TYPE_MAP[server.pagetype]} server to {purpose}. Required: {human_readable(space_required)}, Available: {human_readable(free_space)} (Need {human_readable(abs(diff))} more)."
msg = f"Insufficient estimated space on {PAGETYPE_SERVER_TYPE_MAP[server.pagetype]} server to {purpose}. Required: {human_readable(space_required)}, Available: {human_readable(free_space)} (Need {human_readable(abs(diff))} more)."
if server.public and not no_increase:
self.try_increasing_disk(server, mountpoint, diff, msg)
else: