sharing/bday/summary: check for not to be empty
This commit is contained in:
@@ -597,7 +597,7 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([
|
|||||||
("conversion_bday_summary_template", {
|
("conversion_bday_summary_template", {
|
||||||
"value": sharing.SHARING_BDAY_SUMMARY_TEMPLATE_DEFAULT,
|
"value": sharing.SHARING_BDAY_SUMMARY_TEMPLATE_DEFAULT,
|
||||||
"help": "conversion bday summary template",
|
"help": "conversion bday summary template",
|
||||||
"type": sharing.check_template}),
|
"type": sharing.check_template_not_empty}),
|
||||||
("conversion_bday_description_template", {
|
("conversion_bday_description_template", {
|
||||||
"value": sharing.SHARING_BDAY_DESCRIPTION_TEMPLATE_DEFAULT,
|
"value": sharing.SHARING_BDAY_DESCRIPTION_TEMPLATE_DEFAULT,
|
||||||
"help": "conversion bday description template",
|
"help": "conversion bday description template",
|
||||||
|
|||||||
@@ -152,6 +152,13 @@ def check_template(data: Any) -> str:
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def check_template_not_empty(data: Any) -> str:
|
||||||
|
result = check_template(data)
|
||||||
|
if result == "":
|
||||||
|
raise ValueError("template not allowed to be empty")
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
def check_template_alarm_trigger(data: Any) -> str:
|
def check_template_alarm_trigger(data: Any) -> str:
|
||||||
if data is not None and data != '':
|
if data is not None and data != '':
|
||||||
for entry in data.split('|'):
|
for entry in data.split('|'):
|
||||||
@@ -169,7 +176,7 @@ def check_template_alarm_trigger(data: Any) -> str:
|
|||||||
|
|
||||||
if alarm_description is not None and alarm_description != '':
|
if alarm_description is not None and alarm_description != '':
|
||||||
try:
|
try:
|
||||||
check_template(alarm_description)
|
check_template_not_empty(alarm_description)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
@@ -179,7 +186,7 @@ def check_template_alarm_trigger(data: Any) -> str:
|
|||||||
|
|
||||||
ACTIONS_WHITELIST: dict = {
|
ACTIONS_WHITELIST: dict = {
|
||||||
'config': {
|
'config': {
|
||||||
'conversion_bday_summary_template': check_template,
|
'conversion_bday_summary_template': check_template_not_empty,
|
||||||
'conversion_bday_description_template': check_template,
|
'conversion_bday_description_template': check_template,
|
||||||
'conversion_bday_alarm_trigger_template': check_template_alarm_trigger,
|
'conversion_bday_alarm_trigger_template': check_template_alarm_trigger,
|
||||||
'conversion_bday_categories': str,
|
'conversion_bday_categories': str,
|
||||||
|
|||||||
@@ -5097,6 +5097,26 @@ permissions: RrWw""")
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
logging.info("\n*** configuration test: conversion_bday_summary_template empty")
|
||||||
|
try:
|
||||||
|
self.configure({"sharing": {
|
||||||
|
"conversion_bday_summary_template": "",
|
||||||
|
}})
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
logging.info("\n*** configuration test: conversion_bday_description_template empty")
|
||||||
|
try:
|
||||||
|
self.configure({"sharing": {
|
||||||
|
"conversion_bday_description_template": "",
|
||||||
|
}})
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
logging.info("\n*** configuration test: conversion_bday_alarm_trigger_template not supported")
|
logging.info("\n*** configuration test: conversion_bday_alarm_trigger_template not supported")
|
||||||
try:
|
try:
|
||||||
self.configure({"sharing": {
|
self.configure({"sharing": {
|
||||||
|
|||||||
Reference in New Issue
Block a user