main #2

Merged
jingrow merged 250 commits from main into v1 2026-01-13 22:45:50 +08:00
26 changed files with 77 additions and 77 deletions
Showing only changes of commit b72a4b2031 - Show all commits

View File

@ -431,7 +431,7 @@ export default {
this.$confirm({
title: 'Remove App',
message: `Are you sure you want to uninstall app ${app.title} from <b>site</b>?<br><br>
<b>All doctypes and modules pertaining to this app will be removed.</b>`,
<b>All pagetypes and modules pertaining to this app will be removed.</b>`,
actionLabel: 'Remove App',
actionColor: 'red',
action: closeDialog => {

View File

@ -5,7 +5,7 @@ import { isMobile } from '../../utils/device';
import { duration } from '../../utils/format';
import { ColumnField, Tab } from './types';
type JobDocTypes = 'Site' | 'Bench' | 'Server' | 'Release Group';
type JobPageTypes = 'Site' | 'Bench' | 'Server' | 'Release Group';
// 英文 job_type 到中文的映射
const jobTypeI18nMap: Record<string, string> = {
@ -35,7 +35,7 @@ function statusI18n(status: string) {
return statusI18nMap[status] || status;
}
export function getJobsTab(pagetype: JobDocTypes) {
export function getJobsTab(pagetype: JobPageTypes) {
const jobRoute = getJobRoute(pagetype);
return {
@ -95,7 +95,7 @@ export function getJobsTab(pagetype: JobDocTypes) {
} satisfies Tab as Tab;
}
function getJobRoute(pagetype: JobDocTypes) {
function getJobRoute(pagetype: JobPageTypes) {
if (pagetype === 'Site') return 'Site Job';
else if (pagetype === 'Bench') return 'Bench Job';
else if (pagetype === 'Server') return 'Server Job';
@ -103,7 +103,7 @@ function getJobRoute(pagetype: JobDocTypes) {
throw unreachable;
}
function getJobTabColumns(pagetype: JobDocTypes) {
function getJobTabColumns(pagetype: JobPageTypes) {
const columns: ColumnField[] = [
{
label: '任务类型',

View File

@ -100,7 +100,7 @@ test files (for organization reasons). These functions will be doing the bare
minimum to make a valid document of that pagetype.
Eg: `create_test_bench` in `test_bench.py` can be imported and used whenever
you need a valid bench (which itself has dependencies on many other doctypes)
you need a valid bench (which itself has dependencies on many other pagetypes)
You can also add default args to these utility functions as you come across the
need. Just append to end so you won't have to rewrite pre-existing tests.

View File

@ -1205,10 +1205,10 @@ def get_permission_options(name, ptype):
available_actions,
)
doctypes = jingrow.get_all("Jcloud Method Permission", pluck="document_type", distinct=True)
pagetypes = jingrow.get_all("Jcloud Method Permission", pluck="document_type", distinct=True)
options = []
for pagetype in doctypes:
for pagetype in pagetypes:
pg = jingrow.qb.PageType(pagetype)
perm_pg = jingrow.qb.PageType("Jcloud User Permission")
subtable = (

View File

@ -105,7 +105,7 @@ def get_list(
if filters is None:
filters = {}
# these doctypes doesn't have a team field to filter by but are used in get or run_pg_method
# these pagetypes doesn't have a team field to filter by but are used in get or run_pg_method
if pagetype in ["Team", "User SSH Key"]:
return []

View File

@ -22,11 +22,11 @@ if TYPE_CHECKING:
from jcloud.jcloud.pagetype.cluster.cluster import Cluster
def poly_get_pg(doctypes, name):
for pagetype in doctypes:
def poly_get_pg(pagetypes, name):
for pagetype in pagetypes:
if jingrow.db.exists(pagetype, name):
return jingrow.get_pg(pagetype, name)
return jingrow.get_pg(doctypes[-1], name)
return jingrow.get_pg(pagetypes[-1], name)
MOUNTPOINT_REGEX = "(/|/opt/volumes/mariadb|/opt/volumes/benches)"

View File

@ -58,21 +58,21 @@ if TYPE_CHECKING:
NAMESERVERS = ["1.1.1.1", "1.0.0.1", "8.8.8.8", "8.8.4.4"]
def protected(doctypes):
def protected(pagetypes):
"""
This decorator is stupid. It works in magical ways. It checks whether the
owner of the Pagetype (one of `doctypes`) is the same as the current team.
owner of the Pagetype (one of `pagetypes`) is the same as the current team.
The stupid magical part of this decorator is how it gets the name of the
Pagetype (see: `get_protected_pagetype_name`); in order of precedence:
1. kwargs value with key `name`
2. first value in kwargs value with key `filters` i.e. `kwargs['filters'].values()[0]`
3. first value in the args tuple
4. kwargs value with key `snake_case(doctypes[0])`
4. kwargs value with key `snake_case(pagetypes[0])`
"""
if not isinstance(doctypes, list):
doctypes = [doctypes]
if not isinstance(pagetypes, list):
pagetypes = [pagetypes]
@wrapt.decorator
def wrapper(wrapped, instance, args, kwargs):
@ -82,12 +82,12 @@ def protected(doctypes):
if user_type == "System User":
return wrapped(*args, **kwargs)
name = get_protected_pagetype_name(args, kwargs, doctypes)
name = get_protected_pagetype_name(args, kwargs, pagetypes)
if not name:
jingrow.throw("找不到名称不允许API访问", jingrow.PermissionError)
team = get_current_team()
for pagetype in doctypes:
for pagetype in pagetypes:
owner = jingrow.db.get_value(pagetype, name, "team")
if owner == team or has_role("Jcloud Support Agent"):
@ -98,7 +98,7 @@ def protected(doctypes):
return wrapper
def get_protected_pagetype_name(args: list, kwargs: dict, doctypes: list[str]):
def get_protected_pagetype_name(args: list, kwargs: dict, pagetypes: list[str]):
# 1. Name from kwargs["name"]
if name := kwargs.get("name"):
return name
@ -112,11 +112,11 @@ def get_protected_pagetype_name(args: list, kwargs: dict, doctypes: list[str]):
if len(args) >= 1 and args[0]:
return args[0]
if len(doctypes) == 0:
if len(pagetypes) == 0:
return None
# 4. Name from snakecased first `doctypes` name
pagetype = doctypes[0]
# 4. Name from snakecased first `pagetypes` name
pagetype = pagetypes[0]
key = pagetype.lower().replace(" ", "_")
return kwargs.get(key)

View File

@ -394,10 +394,10 @@ persistent_cache_keys = [
"defaults",
"pagetype_form_meta",
"pagetype_meta",
"doctypes_with_web_view",
"pagetypes_with_web_view",
"document_cache::*",
"document_naming_rule_map",
"domain_restricted_doctypes",
"domain_restricted_pagetypes",
"domain_restricted_pages",
"energy_point_rule_map",
"jingrow.utils.scheduler.schedule_jobs_based_on_activity*", # dormant checks

View File

@ -202,7 +202,7 @@ def update_with_row_size_too_large_err(details: Details, job: AgentJob):
details[
"message"
] = f"""<p>The server encountered a row size too large error while migrating the site <b>{job.site}</b>.</p>
<p>This tends to happen on doctypes with many custom fields</p>
<p>This tends to happen on pagetypes with many custom fields</p>
<p>To rectify this issue, please follow the steps mentioned in <i>Help</i>.</p>
"""

View File

@ -228,7 +228,7 @@ class AlertmanagerWebhookLog(Document):
return jingrow.render_template(TELEGRAM_NOTIFICATION_TEMPLATE, context)
def guess_pagetype(self, name):
doctypes = [
pagetypes = [
"Site",
"Bench",
"Server",
@ -241,7 +241,7 @@ class AlertmanagerWebhookLog(Document):
"Site Domain",
"Trace Server",
]
for pagetype in doctypes:
for pagetype in pagetypes:
if jingrow.db.exists(pagetype, name):
return pagetype
return None

View File

@ -235,7 +235,7 @@ class Cluster(Document):
@property
def images_available(self) -> float:
return len(self.get_same_region_vmis()) / len(self.server_doctypes)
return len(self.get_same_region_vmis()) / len(self.server_pagetypes)
def validate_cidr_block(self):
if not self.cidr_block:
@ -672,18 +672,18 @@ class Cluster(Document):
return VirtualMachineImage.get_available_for_series(series, self.region, platform=platform)
@property
def server_doctypes(self):
server_doctypes = {**self.base_servers}
def server_pagetypes(self):
server_pagetypes = {**self.base_servers}
if not self.public:
server_doctypes = {**server_doctypes, **self.private_servers}
return server_doctypes
server_pagetypes = {**server_pagetypes, **self.private_servers}
return server_pagetypes
def get_same_region_vmis(self, get_series=False):
return jingrow.get_all(
"Virtual Machine Image",
filters={
"region": self.region,
"series": ("in", list(self.server_doctypes.values())),
"series": ("in", list(self.server_pagetypes.values())),
"status": "Available",
},
pluck="name" if not get_series else "series",
@ -691,7 +691,7 @@ class Cluster(Document):
def get_other_region_vmis(self, get_series=False):
vmis = []
for series in list(self.server_doctypes.values()):
for series in list(self.server_pagetypes.values()):
vmis.extend(
jingrow.get_all(
"Virtual Machine Image",

View File

@ -24,11 +24,11 @@ class JcloudMethodPermission(Document):
def available_actions():
result = {}
doctypes = jingrow.get_all(
pagetypes = jingrow.get_all(
"Jcloud Method Permission", pluck="document_type", distinct=True
)
for pagetype in doctypes:
for pagetype in pagetypes:
result[pagetype] = {
perm["checkbox_label"]: perm["method"]
for perm in jingrow.get_all(

View File

@ -7,7 +7,7 @@ from jingrow.model.document import Document
from jcloud.api.client import dashboard_whitelist
DEFAULT_PERMISSIONS = {
"*": {"*": {"*": True}} # all doctypes # all documents # all methods
"*": {"*": {"*": True}} # all pagetypes # all documents # all methods
}
@ -59,7 +59,7 @@ class JcloudPermissionGroup(Document):
return
for pagetype, pagetype_perms in permissions.items():
if pagetype not in get_all_restrictable_doctypes() and pagetype != "*":
if pagetype not in get_all_restrictable_pagetypes() and pagetype != "*":
jingrow.throw(f"{pagetype} is not a valid pagetype.")
if not isinstance(pagetype_perms, dict):
@ -160,7 +160,7 @@ class JcloudPermissionGroup(Document):
if not (jingrow.local.system_user() or user_belongs_to_group or user_is_team_owner):
jingrow.throw(f"{user} does not belong to {self.name}")
if pagetype not in get_all_restrictable_doctypes():
if pagetype not in get_all_restrictable_pagetypes():
jingrow.throw(f"{pagetype} is not a valid restrictable pagetype.")
restrictable_methods = get_all_restrictable_methods(pagetype)
@ -222,7 +222,7 @@ def has_method_permission(
user = jingrow.session.user
if pagetype not in get_all_restrictable_doctypes():
if pagetype not in get_all_restrictable_pagetypes():
return True
if method not in get_all_restrictable_methods(pagetype):
@ -244,7 +244,7 @@ def has_method_permission(
def get_permitted_methods(pagetype: str, name: str, group_names: list = None) -> list:
user = jingrow.session.user
if pagetype not in get_all_restrictable_doctypes():
if pagetype not in get_all_restrictable_pagetypes():
jingrow.throw(f"{pagetype} is not a valid restrictable pagetype.")
permissions_by_group = {}
@ -320,7 +320,7 @@ def resolve_pg_permissions(pagetype, permissions_by_group: dict) -> dict:
return method_perms
def get_all_restrictable_doctypes() -> list:
def get_all_restrictable_pagetypes() -> list:
return ["Site", "Release Group"]

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

@ -293,14 +293,14 @@ def paid_plans():
"price_cny": (">", 0),
"enabled": 1,
}
doctypes = [
pagetypes = [
"Site Plan",
"Marketplace App Plan",
"Server Plan",
"Server Storage Plan",
"Cluster Plan",
]
for pagetype in doctypes:
for pagetype in pagetypes:
paid_plans += jingrow.get_all(pagetype, filter, pluck="name", ignore_ifnull=True)
return list(set(paid_plans))

View File

@ -141,7 +141,7 @@ class TLSCertificate(Document):
@jingrow.whitelist()
def trigger_server_tls_setup_callback(self):
server_doctypes = [
server_pagetypes = [
"Proxy Server",
"Server",
"Database Server",
@ -151,7 +151,7 @@ class TLSCertificate(Document):
"Analytics Server",
"Trace Server",
]
for server_pagetype in server_doctypes:
for server_pagetype in server_pagetypes:
servers = jingrow.get_all(
server_pagetype,
{"status": "Active", "name": ("like", f"%.{self.domain}")}
@ -279,7 +279,7 @@ def retrigger_failed_wildcard_tls_callbacks():
"""
可用于手动重新为失败的通配符证书部署
"""
server_doctypes = [
server_pagetypes = [
"Proxy Server",
"Server",
"Database Server",
@ -289,7 +289,7 @@ def retrigger_failed_wildcard_tls_callbacks():
"Analytics Server",
"Trace Server",
]
for server_pagetype in server_doctypes:
for server_pagetype in server_pagetypes:
servers = jingrow.get_all(server_pagetype, {"status": "Active"}, pluck="name")
for srv in servers:
plays = jingrow.get_all(

View File

@ -38,7 +38,7 @@ from jcloud.overrides import get_permission_query_conditions_for_pagetype
from jcloud.utils import log_error
from jcloud.utils.jobs import has_job_timeout_exceeded
server_doctypes = [
server_pagetypes = [
"Server",
"Database Server",
"Proxy Server",
@ -392,7 +392,7 @@ class VirtualMachine(Document):
return jingrow.render_template(cloud_init_template, context, is_path=True)
def get_server(self):
for pagetype in server_doctypes:
for pagetype in server_pagetypes:
server = jingrow.db.get_value(pagetype, {"virtual_machine": self.name}, "name")
if server:
return jingrow.get_pg(pagetype, server)
@ -740,7 +740,7 @@ class VirtualMachine(Document):
"Terminated": "Archived",
"Stopped": "Pending",
}
for pagetype in server_doctypes:
for pagetype in server_pagetypes:
server = jingrow.get_all(pagetype, {"virtual_machine": self.name}, pluck="name")
if server:
server = server[0]

View File

@ -24,7 +24,7 @@ jcloud.patches.v0_0_1.add_domains_to_site_config
execute:jingrow.reload_pg('jcloud', 'pagetype', 'Remote File')
# jcloud.patches.v0_0_1.add_site_to_remote_file # 2020-11-12 run via run-patch command in active site state
jcloud.patches.v0_0_1.new_onboarding
jcloud.patches.v0_0_1.remove_obsolete_doctypes
jcloud.patches.v0_0_1.remove_obsolete_pagetypes
jcloud.patches.v0_0_1.make_default_site_domain
jcloud.patches.v0_0_1.update_site_config_pg
jcloud.patches.v0_0_1.create_certificate_authorities
@ -75,7 +75,7 @@ jcloud.patches.v0_0_1.add_domains_in_site_config_preview
jcloud.patches.v0_0_1.use_private_ip_for_upstreams
jcloud.jcloud.pagetype.site.patches.set_plan_in_site
jcloud.jcloud.pagetype.app_release.patches.set_status_to_draft
jcloud.patches.v0_0_4.remove_legacy_billing_doctypes
jcloud.patches.v0_0_4.remove_legacy_billing_pagetypes
# jcloud.jcloud.pagetype.invoice.patches.set_free_credits # 2021-08-11 run via run-patch command
jcloud.jcloud.pagetype.team.patches.set_payment_mode
jcloud.patches.v0_0_1.add_team_name_as_default_notify_email
@ -109,7 +109,7 @@ jcloud.jcloud.pagetype.virtual_disk_snapshot.patches.rename_aws_fields
jcloud.jcloud.pagetype.virtual_machine_volume.patches.rename_aws_fields
jcloud.patches.v0_7_0.convert_marketplace_description_to_html
jcloud.jcloud.pagetype.team.patches.remove_invalid_email_addresses
jcloud.saas.pagetype.product_trial.patches.rename_saas_product_doctypes_to_product_trial
jcloud.saas.pagetype.product_trial.patches.rename_saas_product_pagetypes_to_product_trial
[post_model_sync]
jcloud.patches.v0_7_0.rename_plan_to_site_plan
@ -119,7 +119,7 @@ jcloud.jcloud.pagetype.agent_job.patches.update_status_for_undelivered_jobs #202
jcloud.jcloud.pagetype.jcloud_role.patches.migrate_permissions
jcloud.jcloud.pagetype.jcloud_role.patches.change_fields_from_enable_to_allow
jcloud.jcloud.pagetype.stripe_webhook_log.patches.add_payment_method_for_failed_events
jcloud.patches.v0_7_0.add_team_field_for_site_related_doctypes
jcloud.patches.v0_7_0.add_team_field_for_site_related_pagetypes
jcloud.patches.v0_7_0.add_team_field_for_site_backups_archived
jcloud.jcloud.pagetype.server_storage_plan.patches.add_subscription_for_servers_with_additional_disk
jcloud.jcloud.pagetype.jcloud_notification.patches.link_reference_pagetype_to_notifications

View File

@ -9,7 +9,7 @@ def execute():
jingrow.reload_pg("jcloud", "pagetype", "cluster")
cluster = jingrow.get_pg({"pagetype": "Cluster", "name": "Default", "default": True})
cluster.insert()
doctypes = ["Server", "Proxy Server", "Database Server", "Bench", "Site"]
for pagetype in doctypes:
pagetypes = ["Server", "Proxy Server", "Database Server", "Bench", "Site"]
for pagetype in pagetypes:
jingrow.reload_pg("jcloud", "pagetype", jingrow.scrub(pagetype))
jingrow.db.set_value(pagetype, {"name": ("like", "%")}, "cluster", "Default")

View File

@ -7,7 +7,7 @@ import jingrow
def execute():
obsolete_doctypes = [
obsolete_pagetypes = [
"Credit Ledger Entry",
"Custom Domain",
"Site Analytics",
@ -16,6 +16,6 @@ def execute():
"Usage Report",
"User Account",
]
for pagetype in obsolete_doctypes:
for pagetype in obsolete_pagetypes:
if jingrow.db.exists("PageType", pagetype):
jingrow.delete_pg("PageType", pagetype)

View File

@ -6,8 +6,8 @@ import jingrow
def execute():
doctypes = ["Server", "Proxy Server", "Database Server"]
for pagetype in doctypes:
pagetypes = ["Server", "Proxy Server", "Database Server"]
for pagetype in pagetypes:
jingrow.reload_pg("jcloud", "pagetype", jingrow.scrub(pagetype))
servers = jingrow.get_all(pagetype, {"hostname": ("is", "not set")})
domain = jingrow.db.get_single_value("Jcloud Settings", "domain")

View File

@ -6,6 +6,6 @@ import jingrow
def execute():
# these doctypes are only deleted from PageType table, their tables will exist
doctypes = ["Payment", "Payment Ledger Entry"]
jingrow.db.sql("DELETE from tabPageType where name in %s", [doctypes])
# these pagetypes are only deleted from PageType table, their tables will exist
pagetypes = ["Payment", "Payment Ledger Entry"]
jingrow.db.sql("DELETE from tabPageType where name in %s", [pagetypes])

View File

@ -1,6 +1,6 @@
### New SaaS Flow (Product Trial)
It has 2 doctypes.
It has 2 pagetypes.
1. **Product Trial** - Hold the configuration for a specific product.
2. **Product Trial Request** - This holds the records of request for a specific product from a user.

View File

@ -7,11 +7,11 @@ from jingrow.model.utils.rename_field import rename_field
def execute():
rename_doctypes()
rename_pagetypes()
rename_fields()
def rename_doctypes():
def rename_pagetypes():
renames = {
"SaaS Product": "Product Trial",
"SaaS Product App": "Product Trial App",

View File

@ -587,12 +587,12 @@ class ttl_cache:
return wrapper_func
def poly_get_pagetype(doctypes, name):
"""Get the pagetype value from the given name of a pg from a list of doctypes"""
for pagetype in doctypes:
def poly_get_pagetype(pagetypes, name):
"""Get the pagetype value from the given name of a pg from a list of pagetypes"""
for pagetype in pagetypes:
if jingrow.db.exists(pagetype, name):
return pagetype
return doctypes[-1]
return pagetypes[-1]
def reconnect_on_failure():

View File

@ -4,13 +4,13 @@ title: Build a Bench
# Build a Bench
This is information about doctypes required to manage benches and apps on FC
This is information about pagetypes required to manage benches and apps on FC
from [desk](https://jingrow.com/app). Roughly, the build process goes
through these doctypes (that you're concerned with) in order.
through these pagetypes (that you're concerned with) in order.
App => App Source => Release Group => Deploy Candidate => Bench
To build a bench, we need documents of the following doctypes.
To build a bench, we need documents of the following pagetypes.
## App