mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-31 12:56:11 +01:00
Add fill/no fill for schema props
This commit is contained in:
parent
dcd81102fa
commit
ed9accc1e4
@ -9,27 +9,111 @@ from app.classes.web.base_api_handler import BaseApiHandler
|
|||||||
config_json_schema = {
|
config_json_schema = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"https_port": {"type": "integer", "error": "typeInteger"},
|
"https_port": {
|
||||||
"language": {"type": "string", "error": "typeString"},
|
"type": "integer",
|
||||||
"cookie_expire": {"type": "integer", "error": "typeInteger"},
|
"error": "typeInteger",
|
||||||
"show_errors": {"type": "boolean", "error": "typeBool"},
|
"fill": True,
|
||||||
"history_max_age": {"type": "integer", "error": "typeInteger"},
|
},
|
||||||
"stats_update_frequency_seconds": {"type": "integer", "error": "typeInteger"},
|
"language": {
|
||||||
"delete_default_json": {"type": "boolean", "error": "typeBool"},
|
"type": "string",
|
||||||
"show_contribute_link": {"type": "boolean", "error": "typeBool"},
|
"error": "typeString",
|
||||||
"virtual_terminal_lines": {"type": "integer", "error": "typeInteger"},
|
"fill": True,
|
||||||
"max_log_lines": {"type": "integer", "error": "typeInteger"},
|
},
|
||||||
"max_audit_entries": {"type": "integer", "error": "typeInteger"},
|
"cookie_expire": {
|
||||||
"disabled_language_files": {"type": "array", "error": "typeList"},
|
"type": "integer",
|
||||||
"stream_size_GB": {"type": "integer", "error": "typeInteger"},
|
"error": "typeInteger",
|
||||||
"keywords": {"type": "array", "error": "typeList"},
|
"fill": True,
|
||||||
"allow_nsfw_profile_pictures": {"type": "boolean", "error": "typeBool"},
|
},
|
||||||
"enable_user_self_delete": {"type": "boolean", "error": "typeBool"},
|
"show_errors": {
|
||||||
"reset_secrets_on_next_boot": {"type": "boolean", "error": "typeBool"},
|
"type": "boolean",
|
||||||
"monitored_mounts": {"type": "array", "error": "typeList"},
|
"error": "typeBool",
|
||||||
"dir_size_poll_freq_minutes": {"type": "integer", "error": "typeInteger"},
|
"fill": True,
|
||||||
"crafty_logs_delete_after_days": {"type": "integer", "error": "typeInteger"},
|
},
|
||||||
"big_bucket_repo": {"type": "string", "error": "typeString"},
|
"history_max_age": {
|
||||||
|
"type": "integer",
|
||||||
|
"error": "typeInteger",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"stats_update_frequency_seconds": {
|
||||||
|
"type": "integer",
|
||||||
|
"error": "typeInteger",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"delete_default_json": {
|
||||||
|
"type": "boolean",
|
||||||
|
"error": "typeBool",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"show_contribute_link": {
|
||||||
|
"type": "boolean",
|
||||||
|
"error": "typeBool",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"virtual_terminal_lines": {
|
||||||
|
"type": "integer",
|
||||||
|
"error": "typeInteger",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"max_log_lines": {
|
||||||
|
"type": "integer",
|
||||||
|
"error": "typeInteger",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"max_audit_entries": {
|
||||||
|
"type": "integer",
|
||||||
|
"error": "typeInteger",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"disabled_language_files": {
|
||||||
|
"type": "array",
|
||||||
|
"error": "typeList",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"stream_size_GB": {
|
||||||
|
"type": "integer",
|
||||||
|
"error": "typeInteger",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"keywords": {
|
||||||
|
"type": "array",
|
||||||
|
"error": "typeList",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"allow_nsfw_profile_pictures": {
|
||||||
|
"type": "boolean",
|
||||||
|
"error": "typeBool",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"enable_user_self_delete": {
|
||||||
|
"type": "boolean",
|
||||||
|
"error": "typeBool",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"reset_secrets_on_next_boot": {
|
||||||
|
"type": "boolean",
|
||||||
|
"error": "typeBool",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"monitored_mounts": {
|
||||||
|
"type": "array",
|
||||||
|
"error": "typeList",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"dir_size_poll_freq_minutes": {
|
||||||
|
"type": "integer",
|
||||||
|
"error": "typeInteger",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"crafty_logs_delete_after_days": {
|
||||||
|
"type": "integer",
|
||||||
|
"error": "typeInteger",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"big_bucket_repo": {
|
||||||
|
"type": "string",
|
||||||
|
"error": "typeString",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
"minProperties": 1,
|
"minProperties": 1,
|
||||||
@ -37,8 +121,16 @@ config_json_schema = {
|
|||||||
customize_json_schema = {
|
customize_json_schema = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"photo": {"type": "string", "error": "typeString"},
|
"photo": {
|
||||||
"opacity": {"type": "string", "error": "typeString"},
|
"type": "string",
|
||||||
|
"error": "typeString",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"opacity": {
|
||||||
|
"type": "string",
|
||||||
|
"error": "typeString",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
"minProperties": 1,
|
"minProperties": 1,
|
||||||
@ -47,7 +139,11 @@ customize_json_schema = {
|
|||||||
photo_delete_schema = {
|
photo_delete_schema = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"photo": {"type": "string", "error": "typeString"},
|
"photo": {
|
||||||
|
"type": "string",
|
||||||
|
"error": "typeString",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
"minProperties": 1,
|
"minProperties": 1,
|
||||||
@ -109,7 +205,9 @@ class ApiCraftyConfigIndexHandler(BaseApiHandler):
|
|||||||
try:
|
try:
|
||||||
validate(data, config_json_schema)
|
validate(data, config_json_schema)
|
||||||
except ValidationError as why:
|
except ValidationError as why:
|
||||||
offending_key = why.path[0] if why.path else None
|
offending_key = None
|
||||||
|
if why.get("fill", None):
|
||||||
|
offending_key = why.path[0] if why.path else None
|
||||||
err = f"""{self.translator.translate(
|
err = f"""{self.translator.translate(
|
||||||
"validators",
|
"validators",
|
||||||
why.schema.get("error"),
|
why.schema.get("error"),
|
||||||
|
@ -17,10 +17,21 @@ files_get_schema = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
"error": "filesPageLen",
|
"error": "filesPageLen",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"folder": {"type": "string", "error": "typeString", "fill": True},
|
||||||
|
"upload": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": "False",
|
||||||
|
"error": "typeBool",
|
||||||
|
"fill": True,
|
||||||
|
},
|
||||||
|
"unzip": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": "True",
|
||||||
|
"error": "typeBool",
|
||||||
|
"fill": True,
|
||||||
},
|
},
|
||||||
"folder": {"type": "string", "error": "typeString"},
|
|
||||||
"upload": {"type": "boolean", "default": "False", "error": "typeBool"},
|
|
||||||
"unzip": {"type": "boolean", "default": "True", "error": "typeBool"},
|
|
||||||
},
|
},
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
"minProperties": 1,
|
"minProperties": 1,
|
||||||
@ -52,7 +63,9 @@ class ApiImportFilesIndexHandler(BaseApiHandler):
|
|||||||
try:
|
try:
|
||||||
validate(data, files_get_schema)
|
validate(data, files_get_schema)
|
||||||
except ValidationError as why:
|
except ValidationError as why:
|
||||||
offending_key = why.path[0] if why.path else None
|
offending_key = None
|
||||||
|
if why.get("fill", None):
|
||||||
|
offending_key = why.path[0] if why.path else None
|
||||||
err = f"""{self.translator.translate(
|
err = f"""{self.translator.translate(
|
||||||
"validators",
|
"validators",
|
||||||
why.schema.get("error"),
|
why.schema.get("error"),
|
||||||
|
@ -17,6 +17,7 @@ create_role_schema = {
|
|||||||
"servers": {
|
"servers": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"error": "typeList",
|
"error": "typeList",
|
||||||
|
"fill": True,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -51,6 +52,7 @@ basic_create_role_schema = {
|
|||||||
"servers": {
|
"servers": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"error": "typeList",
|
"error": "typeList",
|
||||||
|
"fill": True,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -142,13 +144,21 @@ class ApiRolesIndexHandler(BaseApiHandler):
|
|||||||
validate(data, create_role_schema)
|
validate(data, create_role_schema)
|
||||||
else:
|
else:
|
||||||
validate(data, basic_create_role_schema)
|
validate(data, basic_create_role_schema)
|
||||||
except ValidationError as e:
|
except ValidationError as why:
|
||||||
|
offending_key = None
|
||||||
|
if why.get("fill", None):
|
||||||
|
offending_key = why.path[0] if why.path else None
|
||||||
|
err = f"""{self.translator.translate(
|
||||||
|
"validators",
|
||||||
|
why.schema.get("error"),
|
||||||
|
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
|
||||||
|
)} {offending_key}"""
|
||||||
return self.finish_json(
|
return self.finish_json(
|
||||||
400,
|
400,
|
||||||
{
|
{
|
||||||
"status": "error",
|
"status": "error",
|
||||||
"error": "INVALID_JSON_SCHEMA",
|
"error": "INVALID_JSON_SCHEMA",
|
||||||
"error_data": str(e),
|
"error_data": f"{str(err)}",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ modify_role_schema = {
|
|||||||
"servers": {
|
"servers": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"error": "typeList",
|
"error": "typeList",
|
||||||
|
"fill": True,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -50,6 +51,7 @@ basic_modify_role_schema = {
|
|||||||
"servers": {
|
"servers": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"error": "typeList",
|
"error": "typeList",
|
||||||
|
"fill": True,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -173,13 +175,21 @@ class ApiRolesRoleIndexHandler(BaseApiHandler):
|
|||||||
validate(data, modify_role_schema)
|
validate(data, modify_role_schema)
|
||||||
else:
|
else:
|
||||||
validate(data, basic_modify_role_schema)
|
validate(data, basic_modify_role_schema)
|
||||||
except ValidationError as e:
|
except ValidationError as why:
|
||||||
|
offending_key = None
|
||||||
|
if why.get("fill", None):
|
||||||
|
offending_key = why.path[0] if why.path else None
|
||||||
|
err = f"""{self.translator.translate(
|
||||||
|
"validators",
|
||||||
|
why.schema.get("error"),
|
||||||
|
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
|
||||||
|
)} {offending_key}"""
|
||||||
return self.finish_json(
|
return self.finish_json(
|
||||||
400,
|
400,
|
||||||
{
|
{
|
||||||
"status": "error",
|
"status": "error",
|
||||||
"error": "INVALID_JSON_SCHEMA",
|
"error": "INVALID_JSON_SCHEMA",
|
||||||
"error_data": str(e),
|
"error_data": f"{str(err)}",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -668,12 +668,13 @@
|
|||||||
"uses": "Number of uses allowed (-1==No Limit)"
|
"uses": "Number of uses allowed (-1==No Limit)"
|
||||||
},
|
},
|
||||||
"validators": {
|
"validators": {
|
||||||
"filesPageLen": "Length must be greater than 1 for property ",
|
"filesPageLen": "Length must be greater than 1 for property for prop",
|
||||||
"passLength": "Password Too Short. Minimum Length: 8",
|
"passLength": "Password Too Short. Minimum Length: 8",
|
||||||
"roleManager": "Role manager must be of type integer (manager ID) or None",
|
"roleManager": "Role manager must be of type integer (manager ID) or None",
|
||||||
"roleName": "Role name must be a string that is greater than 1 character. It must not include any of the following symbols: [ ] , ",
|
"roleName": "Role name must be a string that is greater than 1 character. It must not include any of the following symbols: [ ] , ",
|
||||||
"roleServerId": "Server ID property must be a string with a minimum length of 1",
|
"roleServerId": "Server ID property must be a string with a minimum length of 1",
|
||||||
"roleServerPerms": "Server permissions must be an 8-bit string",
|
"roleServerPerms": "Server permissions must be an 8-bit string",
|
||||||
|
"serverCreateName": "Server name must be a string with a minimum length of 2 and must not include: \\ / or # ",
|
||||||
"typeBool": "Type error: True or False required for ",
|
"typeBool": "Type error: True or False required for ",
|
||||||
"typeInteger": "Type error: Integer required for ",
|
"typeInteger": "Type error: Integer required for ",
|
||||||
"typeList": "Type error: List required for ",
|
"typeList": "Type error: List required for ",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user