sharing/bday/Actions: align config section
This commit is contained in:
@@ -647,29 +647,29 @@ class Item:
|
|||||||
|
|
||||||
# create SUMMARY
|
# create SUMMARY
|
||||||
summary = name + " (BDAY)" # default
|
summary = name + " (BDAY)" # default
|
||||||
if ShareActions is not None and 'template' in ShareActions:
|
if ShareActions is not None and 'config' in ShareActions:
|
||||||
if 'conversion_bday_summary_template' in ShareActions['template']:
|
if 'conversion_bday_summary_template' in ShareActions['config']:
|
||||||
summary = ShareActions['template']['conversion_bday_summary_template']
|
summary = ShareActions['config']['conversion_bday_summary_template']
|
||||||
summary = self.replace_placeholders(summary, placeholder_mapping)
|
summary = self.replace_placeholders(summary, placeholder_mapping)
|
||||||
|
|
||||||
# create DESCRIPTION
|
# create DESCRIPTION
|
||||||
description = "BDAY=" + bdaySdesc # default
|
description = "BDAY=" + bdaySdesc # default
|
||||||
if ShareActions is not None and 'template' in ShareActions:
|
if ShareActions is not None and 'config' in ShareActions:
|
||||||
if 'conversion_bday_description_template' in ShareActions['template']:
|
if 'conversion_bday_description_template' in ShareActions['config']:
|
||||||
description = ShareActions['template']['conversion_bday_description_template']
|
description = ShareActions['config']['conversion_bday_description_template']
|
||||||
description = self.replace_placeholders(description, placeholder_mapping)
|
description = self.replace_placeholders(description, placeholder_mapping)
|
||||||
|
|
||||||
# check ALARM
|
# check ALARM
|
||||||
alarm_trigger = "" # default
|
alarm_trigger = "" # default
|
||||||
if ShareActions is not None and 'template' in ShareActions:
|
if ShareActions is not None and 'config' in ShareActions:
|
||||||
alarm_trigger = ShareActions['template']['conversion_bday_alarm_trigger_template']
|
alarm_trigger = ShareActions['config']['conversion_bday_alarm_trigger_template']
|
||||||
|
|
||||||
vevent_enable_age = False
|
vevent_enable_age = False
|
||||||
age_max = 0
|
age_max = 0
|
||||||
if "{age}" in summary or "{age}" in description or "age" in alarm_trigger:
|
if "{age}" in summary or "{age}" in description or "age" in alarm_trigger:
|
||||||
if ShareActions is not None and 'limit' in ShareActions:
|
if ShareActions is not None and 'config' in ShareActions:
|
||||||
if 'conversion_bday_age_max' in ShareActions['limit']:
|
if 'conversion_bday_age_max' in ShareActions['config']:
|
||||||
age_max = ShareActions['limit']['conversion_bday_age_max']
|
age_max = ShareActions['config']['conversion_bday_age_max']
|
||||||
vevent_enable_age = True
|
vevent_enable_age = True
|
||||||
|
|
||||||
# create UID
|
# create UID
|
||||||
|
|||||||
@@ -425,67 +425,48 @@ class BaseSharing:
|
|||||||
if share is not None:
|
if share is not None:
|
||||||
if share['Conversion'] == "bday":
|
if share['Conversion'] == "bday":
|
||||||
# autogenerate Actions if not existing
|
# autogenerate Actions if not existing
|
||||||
if share['Actions'] is None:
|
if share['Actions'] is None or 'config' not in share['Actions']:
|
||||||
share['Actions'] = {
|
share['Actions'] = {
|
||||||
'template': {
|
'config': {
|
||||||
'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,
|
||||||
},
|
|
||||||
'limit': {
|
|
||||||
'conversion_bday_age_max': self.conversion_bday_age_max,
|
'conversion_bday_age_max': self.conversion_bday_age_max,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
if 'template' in share['Actions']:
|
if 'config' in share['Actions']:
|
||||||
if 'conversion_bday_summary_template' in share['Actions']['template']:
|
if 'conversion_bday_summary_template' in share['Actions']['config']:
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
share['Actions']['template'].update(
|
share['Actions']['config'].update(
|
||||||
{'conversion_bday_summary_template': self.conversion_bday_summary_template}
|
{'conversion_bday_summary_template': self.conversion_bday_summary_template}
|
||||||
)
|
)
|
||||||
|
|
||||||
if 'conversion_bday_description_template' in share['Actions']['template']:
|
if 'conversion_bday_description_template' in share['Actions']['config']:
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
share['Actions']['template'].update(
|
share['Actions']['config'].update(
|
||||||
{'conversion_bday_description_template': self.conversion_bday_description_template}
|
{'conversion_bday_description_template': self.conversion_bday_description_template}
|
||||||
)
|
)
|
||||||
|
|
||||||
if 'conversion_bday_alarm_trigger_template' in share['Actions']['template']:
|
if 'conversion_bday_alarm_trigger_template' in share['Actions']['config']:
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
share['Actions']['template'].update(
|
share['Actions']['config'].update(
|
||||||
{'conversion_bday_alarm_trigger_template': self.conversion_bday_alarm_trigger_template}
|
{'conversion_bday_alarm_trigger_template': self.conversion_bday_alarm_trigger_template}
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
share['Actions'].update(
|
|
||||||
{'template': {
|
|
||||||
'conversion_bday_summary_template': self.conversion_bday_summary_template,
|
|
||||||
'conversion_bday_description_template': self.conversion_bday_description_template,
|
|
||||||
'conversion_bday_alarm_trigger_template': self.conversion_bday_alarm_trigger_template,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if 'limit' in share['Actions']:
|
if 'conversion_bday_age_max' in share['Actions']['config']:
|
||||||
if 'conversion_bday_age_max' in share['Actions']['limit']:
|
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
share['Actions']['limit'].update(
|
share['Actions']['config'].update(
|
||||||
{'conversion_bday_age_max': self.conversion_bday_age_max}
|
{'conversion_bday_age_max': self.conversion_bday_age_max}
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
share['Actions'].update(
|
|
||||||
{'limit': {
|
|
||||||
'conversion_bday_age_max': self.conversion_bday_age_max,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
logger.info("sharing/%s: resolved path %r->%r, user %r->%r, Permissions=%r Conversion=%r Actions=%r", share['ShareType'], share['PathOrToken'], share['PathMapped'], user, share['Owner'], share['Permissions'], share['Conversion'], share['Actions'])
|
logger.info("sharing/%s: resolved path %r->%r, user %r->%r, Permissions=%r Conversion=%r Actions=%r", share['ShareType'], share['PathOrToken'], share['PathMapped'], user, share['Owner'], share['Permissions'], share['Conversion'], share['Actions'])
|
||||||
|
|
||||||
|
|||||||
@@ -5178,7 +5178,7 @@ permissions: RrWw""")
|
|||||||
json_dict['User'] = "user"
|
json_dict['User'] = "user"
|
||||||
json_dict['PathMapped'] = path_mapped
|
json_dict['PathMapped'] = path_mapped
|
||||||
json_dict['PathOrToken'] = path_shared_r
|
json_dict['PathOrToken'] = path_shared_r
|
||||||
json_dict['Actions'] = {"limit": {
|
json_dict['Actions'] = {"config": {
|
||||||
"conversion_bday_age_max": 5,
|
"conversion_bday_age_max": 5,
|
||||||
}}
|
}}
|
||||||
_, headers, answer = self._sharing_api_json("map", "update", check=200, login="owner:ownerpw", json_dict=json_dict)
|
_, headers, answer = self._sharing_api_json("map", "update", check=200, login="owner:ownerpw", json_dict=json_dict)
|
||||||
@@ -5237,7 +5237,7 @@ permissions: RrWw""")
|
|||||||
json_dict['User'] = "user"
|
json_dict['User'] = "user"
|
||||||
json_dict['PathMapped'] = path_mapped
|
json_dict['PathMapped'] = path_mapped
|
||||||
json_dict['PathOrToken'] = path_shared_r
|
json_dict['PathOrToken'] = path_shared_r
|
||||||
json_dict['Actions'] = {"limit": {
|
json_dict['Actions'] = {"config": {
|
||||||
"level2": "test",
|
"level2": "test",
|
||||||
}}
|
}}
|
||||||
_, headers, answer = self._sharing_api_json("map", "update", check=400, login="owner:ownerpw", json_dict=json_dict)
|
_, headers, answer = self._sharing_api_json("map", "update", check=400, login="owner:ownerpw", json_dict=json_dict)
|
||||||
@@ -5298,7 +5298,7 @@ permissions: RrWw""")
|
|||||||
json_dict['Enabled'] = True
|
json_dict['Enabled'] = True
|
||||||
json_dict['Hidden'] = False
|
json_dict['Hidden'] = False
|
||||||
json_dict['Properties'] = {"D:displayname": "Test-BDAY2"}
|
json_dict['Properties'] = {"D:displayname": "Test-BDAY2"}
|
||||||
json_dict['Actions'] = {"template": {
|
json_dict['Actions'] = {"config": {
|
||||||
"conversion_bday_summary_template": "{fn} (BDAY2)",
|
"conversion_bday_summary_template": "{fn} (BDAY2)",
|
||||||
"conversion_bday_description_template": "BDAY2={year}-{month}-{day}",
|
"conversion_bday_description_template": "BDAY2={year}-{month}-{day}",
|
||||||
}}
|
}}
|
||||||
@@ -5317,7 +5317,7 @@ permissions: RrWw""")
|
|||||||
json_dict['Enabled'] = True
|
json_dict['Enabled'] = True
|
||||||
json_dict['Hidden'] = False
|
json_dict['Hidden'] = False
|
||||||
json_dict['Properties'] = {"D:displayname": "Test-Birthday3"}
|
json_dict['Properties'] = {"D:displayname": "Test-Birthday3"}
|
||||||
json_dict['Actions'] = {"template": {
|
json_dict['Actions'] = {"config": {
|
||||||
"conversion_bday_summary_template": "{fn} (Birthday3)",
|
"conversion_bday_summary_template": "{fn} (Birthday3)",
|
||||||
"conversion_bday_description_template": "Birthday3={year}-{month}-{day}",
|
"conversion_bday_description_template": "Birthday3={year}-{month}-{day}",
|
||||||
}}
|
}}
|
||||||
@@ -5355,7 +5355,7 @@ permissions: RrWw""")
|
|||||||
json_dict['User'] = "user"
|
json_dict['User'] = "user"
|
||||||
json_dict['PathMapped'] = path_mapped_2
|
json_dict['PathMapped'] = path_mapped_2
|
||||||
json_dict['PathOrToken'] = path_shared_2r
|
json_dict['PathOrToken'] = path_shared_2r
|
||||||
json_dict['Actions'] = {"template": {
|
json_dict['Actions'] = {"config": {
|
||||||
"conversion_bday_summary_template": "{fn} (BDAY2x)",
|
"conversion_bday_summary_template": "{fn} (BDAY2x)",
|
||||||
"conversion_bday_description_template": "BDAY2x={year}-{month}-{day}",
|
"conversion_bday_description_template": "BDAY2x={year}-{month}-{day}",
|
||||||
}}
|
}}
|
||||||
@@ -5374,7 +5374,7 @@ permissions: RrWw""")
|
|||||||
json_dict['User'] = "user"
|
json_dict['User'] = "user"
|
||||||
json_dict['PathMapped'] = path_mapped_2
|
json_dict['PathMapped'] = path_mapped_2
|
||||||
json_dict['PathOrToken'] = path_shared_2r
|
json_dict['PathOrToken'] = path_shared_2r
|
||||||
json_dict['Actions'] = {"template": {
|
json_dict['Actions'] = {"config": {
|
||||||
"conversion_bday_summary_template_UNSUPPORTED": "{fn} (BDAY2x)",
|
"conversion_bday_summary_template_UNSUPPORTED": "{fn} (BDAY2x)",
|
||||||
"conversion_bday_description_template_UNSUPPORTED": "BDAY2x={year}-{month}-{day}",
|
"conversion_bday_description_template_UNSUPPORTED": "BDAY2x={year}-{month}-{day}",
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user