sharing/bday/add support for custom categories
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
* Add: [sharing] conversion_bday_summary_template (customize summary)
|
* Add: [sharing] conversion_bday_summary_template (customize summary)
|
||||||
* Add: [sharing] conversion_bday_description_template (customize description)
|
* Add: [sharing] conversion_bday_description_template (customize description)
|
||||||
* Add: [sharing] conversion_bday_alarm_trigger_template (customize alarms)
|
* Add: [sharing] conversion_bday_alarm_trigger_template (customize alarms)
|
||||||
|
* Add: [sharing] conversion_bday_categories (customize)
|
||||||
* Add: [sharing] conversion_bday_age_max (limit in case of "age" placeholder is used which blocks using RRULE)
|
* Add: [sharing] conversion_bday_age_max (limit in case of "age" placeholder is used which blocks using RRULE)
|
||||||
|
|
||||||
## 3.7.4
|
## 3.7.4
|
||||||
|
|||||||
@@ -2352,6 +2352,14 @@ Supported format for `TIMEDELTA`: `[+-]?[0-9]+[WDHM]`
|
|||||||
|
|
||||||
Supported placeholders for `DESCRIPTION` see `conversion_bday_summary_template`
|
Supported placeholders for `DESCRIPTION` see `conversion_bday_summary_template`
|
||||||
|
|
||||||
|
##### conversion_bday_categories
|
||||||
|
|
||||||
|
_(>= 3.7.5)_
|
||||||
|
|
||||||
|
Global categories of conversion "bday", separated by `,`
|
||||||
|
|
||||||
|
Default: `Birthday`
|
||||||
|
|
||||||
##### conversion_bday_age_max
|
##### conversion_bday_age_max
|
||||||
|
|
||||||
_(>= 3.7.5)_
|
_(>= 3.7.5)_
|
||||||
|
|||||||
3
config
3
config
@@ -366,6 +366,9 @@
|
|||||||
# Example: "-15H;BDAY tomorrow|9H;BDAY today"
|
# Example: "-15H;BDAY tomorrow|9H;BDAY today"
|
||||||
#conversion_bday_alarm_trigger_template = ""
|
#conversion_bday_alarm_trigger_template = ""
|
||||||
|
|
||||||
|
# Global categories of conversion "bday"
|
||||||
|
#conversion_bday_categories = "Birthday"
|
||||||
|
|
||||||
# Global max limit of "bday" age
|
# Global max limit of "bday" age
|
||||||
# Only active in case of {age} is used as placeholder
|
# Only active in case of {age} is used as placeholder
|
||||||
#conversion_bday_age_max = 99
|
#conversion_bday_age_max = 99
|
||||||
|
|||||||
@@ -606,6 +606,10 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([
|
|||||||
"value": "",
|
"value": "",
|
||||||
"help": "conversion bday alarm trigger template",
|
"help": "conversion bday alarm trigger template",
|
||||||
"type": sharing.check_template_alarm_trigger}),
|
"type": sharing.check_template_alarm_trigger}),
|
||||||
|
("conversion_bday_categories", {
|
||||||
|
"value": "Birthday",
|
||||||
|
"help": "conversion bday categories",
|
||||||
|
"type": str}),
|
||||||
("conversion_bday_age_max", {
|
("conversion_bday_age_max", {
|
||||||
"value": "99",
|
"value": "99",
|
||||||
"help": "conversion bday age max",
|
"help": "conversion bday age max",
|
||||||
|
|||||||
@@ -663,6 +663,12 @@ class Item:
|
|||||||
description = ShareActions['config']['conversion_bday_description_template']
|
description = ShareActions['config']['conversion_bday_description_template']
|
||||||
description = replace_placeholders(description, placeholder_mapping)
|
description = replace_placeholders(description, placeholder_mapping)
|
||||||
|
|
||||||
|
# create CATEGORIES
|
||||||
|
categories: list = ["Birthday"] # default
|
||||||
|
if ShareActions is not None and 'config' in ShareActions:
|
||||||
|
if 'conversion_bday_categories' in ShareActions['config']:
|
||||||
|
categories = ShareActions['config']['conversion_bday_categories'].split(',')
|
||||||
|
|
||||||
# check ALARM
|
# check ALARM
|
||||||
alarm_trigger = "" # default
|
alarm_trigger = "" # default
|
||||||
if ShareActions is not None and 'config' in ShareActions:
|
if ShareActions is not None and 'config' in ShareActions:
|
||||||
@@ -718,6 +724,10 @@ class Item:
|
|||||||
summary_value = summary
|
summary_value = summary
|
||||||
vevent.add('summary').value = summary_value
|
vevent.add('summary').value = summary_value
|
||||||
|
|
||||||
|
# set CATEGORIES
|
||||||
|
if categories is not None and categories != []:
|
||||||
|
vevent.add('categories').value = categories
|
||||||
|
|
||||||
# set VALARM
|
# set VALARM
|
||||||
if alarm_trigger is not None and alarm_trigger != "":
|
if alarm_trigger is not None and alarm_trigger != "":
|
||||||
for entry in alarm_trigger.split('|'):
|
for entry in alarm_trigger.split('|'):
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ ACTIONS_WHITELIST: dict = {
|
|||||||
'conversion_bday_summary_template': check_template,
|
'conversion_bday_summary_template': check_template,
|
||||||
'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_age_max': check_bday_max_age,
|
'conversion_bday_age_max': check_bday_max_age,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -228,6 +229,7 @@ class BaseSharing:
|
|||||||
self.conversion_bday_summary_template = configuration.get("sharing", "conversion_bday_summary_template")
|
self.conversion_bday_summary_template = configuration.get("sharing", "conversion_bday_summary_template")
|
||||||
self.conversion_bday_description_template = configuration.get("sharing", "conversion_bday_description_template")
|
self.conversion_bday_description_template = configuration.get("sharing", "conversion_bday_description_template")
|
||||||
self.conversion_bday_alarm_trigger_template = configuration.get("sharing", "conversion_bday_alarm_trigger_template")
|
self.conversion_bday_alarm_trigger_template = configuration.get("sharing", "conversion_bday_alarm_trigger_template")
|
||||||
|
self.conversion_bday_categories = configuration.get("sharing", "conversion_bday_categories")
|
||||||
self.conversion_bday_age_max = configuration.get("sharing", "conversion_bday_age_max")
|
self.conversion_bday_age_max = configuration.get("sharing", "conversion_bday_age_max")
|
||||||
|
|
||||||
logger.info("sharing.collection_by_map : %s", self.sharing_collection_by_map)
|
logger.info("sharing.collection_by_map : %s", self.sharing_collection_by_map)
|
||||||
@@ -241,6 +243,7 @@ class BaseSharing:
|
|||||||
logger.info("sharing.conversion_bday_summary_template: %s", self.conversion_bday_summary_template)
|
logger.info("sharing.conversion_bday_summary_template: %s", self.conversion_bday_summary_template)
|
||||||
logger.info("sharing.conversion_bday_description_template: %s", self.conversion_bday_description_template)
|
logger.info("sharing.conversion_bday_description_template: %s", self.conversion_bday_description_template)
|
||||||
logger.info("sharing.conversion_bday_alarm_trigger_template: %s", self.conversion_bday_alarm_trigger_template)
|
logger.info("sharing.conversion_bday_alarm_trigger_template: %s", self.conversion_bday_alarm_trigger_template)
|
||||||
|
logger.info("sharing.conversion_bday_categories: %s", self.conversion_bday_categories)
|
||||||
logger.info("sharing.conversion_bday_age_max: %s", self.conversion_bday_age_max)
|
logger.info("sharing.conversion_bday_age_max: %s", self.conversion_bday_age_max)
|
||||||
|
|
||||||
# database tasks
|
# database tasks
|
||||||
@@ -479,6 +482,7 @@ class BaseSharing:
|
|||||||
'conversion_bday_summary_template': self.conversion_bday_summary_template,
|
'conversion_bday_summary_template': self.conversion_bday_summary_template,
|
||||||
'conversion_bday_description_template': self.conversion_bday_description_template,
|
'conversion_bday_description_template': self.conversion_bday_description_template,
|
||||||
'conversion_bday_alarm_trigger_template': self.conversion_bday_alarm_trigger_template,
|
'conversion_bday_alarm_trigger_template': self.conversion_bday_alarm_trigger_template,
|
||||||
|
'conversion_bday_categories': self.conversion_bday_categories,
|
||||||
'conversion_bday_age_max': self.conversion_bday_age_max,
|
'conversion_bday_age_max': self.conversion_bday_age_max,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -508,6 +512,14 @@ class BaseSharing:
|
|||||||
{'conversion_bday_alarm_trigger_template': self.conversion_bday_alarm_trigger_template}
|
{'conversion_bday_alarm_trigger_template': self.conversion_bday_alarm_trigger_template}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if 'conversion_bday_categories' in share['Actions']['config']:
|
||||||
|
# nothing to do
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
share['Actions']['config'].update(
|
||||||
|
{'conversion_bday_categories': self.conversion_bday_categories}
|
||||||
|
)
|
||||||
|
|
||||||
if 'conversion_bday_age_max' in share['Actions']['config']:
|
if 'conversion_bday_age_max' in share['Actions']['config']:
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -4830,6 +4830,7 @@ permissions: RrWw""")
|
|||||||
assert "DTEND;VALUE=DATE:19700102" in answer
|
assert "DTEND;VALUE=DATE:19700102" in answer
|
||||||
assert "TRANSP:TRANSPARENT" in answer
|
assert "TRANSP:TRANSPARENT" in answer
|
||||||
assert "DESCRIPTION:BDAY=1970-01-01" in answer
|
assert "DESCRIPTION:BDAY=1970-01-01" in answer
|
||||||
|
assert "CATEGORIES:Birthday" in answer
|
||||||
# content type must be adjusted
|
# content type must be adjusted
|
||||||
assert 'Content-Type' in headers
|
assert 'Content-Type' in headers
|
||||||
assert 'text/calendar' in headers['Content-Type']
|
assert 'text/calendar' in headers['Content-Type']
|
||||||
@@ -4879,6 +4880,7 @@ permissions: RrWw""")
|
|||||||
assert "DTEND;VALUE=DATE:19700102" in answer
|
assert "DTEND;VALUE=DATE:19700102" in answer
|
||||||
assert "TRANSP:TRANSPARENT" in answer
|
assert "TRANSP:TRANSPARENT" in answer
|
||||||
assert "DESCRIPTION:BDAY=1970-01-01" in answer
|
assert "DESCRIPTION:BDAY=1970-01-01" in answer
|
||||||
|
assert "CATEGORIES:Birthday" in answer
|
||||||
# content type must be adjusted
|
# content type must be adjusted
|
||||||
assert 'Content-Type' in headers
|
assert 'Content-Type' in headers
|
||||||
assert 'text/calendar' in headers['Content-Type']
|
assert 'text/calendar' in headers['Content-Type']
|
||||||
@@ -5068,6 +5070,13 @@ permissions: RrWw""")
|
|||||||
assert "TRIGGER:-PT12H" in answer
|
assert "TRIGGER:-PT12H" in answer
|
||||||
assert "TRIGGER:PT12H" in answer
|
assert "TRIGGER:PT12H" in answer
|
||||||
|
|
||||||
|
self.configure({"sharing": {"conversion_bday_categories": "Birthday,Geburtstag"}})
|
||||||
|
logging.info("\n*** GET collection user format: description -> ok")
|
||||||
|
_, headers, answer = self.request("GET", path_shared_3, login="user:userpw")
|
||||||
|
assert "DESCRIPTION:Birthday tomorrow of Test-FN-C3" in answer
|
||||||
|
assert "DESCRIPTION:Birthday today of Given3Test Family3Test" in answer
|
||||||
|
assert "CATEGORIES:Birthday,Geburtstag" in answer
|
||||||
|
|
||||||
logging.info("\n*** configuration test: conversion_bday_summary_template not supported")
|
logging.info("\n*** configuration test: conversion_bday_summary_template not supported")
|
||||||
try:
|
try:
|
||||||
self.configure({"sharing": {
|
self.configure({"sharing": {
|
||||||
|
|||||||
Reference in New Issue
Block a user