sharing/bday/template: code cleanup related to placeholder replacement
This commit is contained in:
@@ -692,7 +692,6 @@ class Item:
|
|||||||
summary = ShareActions['config_default']['conversion_bday_summary_template']
|
summary = ShareActions['config_default']['conversion_bday_summary_template']
|
||||||
else:
|
else:
|
||||||
summary = sharing.SHARING_BDAY_SUMMARY_TEMPLATE_DEFAULT # fallback
|
summary = sharing.SHARING_BDAY_SUMMARY_TEMPLATE_DEFAULT # fallback
|
||||||
summary = replace_placeholders(summary, placeholder_mapping)
|
|
||||||
|
|
||||||
# prepare DESCRIPTION
|
# prepare DESCRIPTION
|
||||||
if ShareActions is not None and 'config' in ShareActions and 'conversion_bday_description_template' in ShareActions['config']:
|
if ShareActions is not None and 'config' in ShareActions and 'conversion_bday_description_template' in ShareActions['config']:
|
||||||
@@ -701,7 +700,6 @@ class Item:
|
|||||||
description = ShareActions['config_default']['conversion_bday_description_template']
|
description = ShareActions['config_default']['conversion_bday_description_template']
|
||||||
else:
|
else:
|
||||||
description = sharing.SHARING_BDAY_DESCRIPTION_TEMPLATE_DEFAULT # fallback
|
description = sharing.SHARING_BDAY_DESCRIPTION_TEMPLATE_DEFAULT # fallback
|
||||||
description = replace_placeholders(description, placeholder_mapping)
|
|
||||||
|
|
||||||
# create CATEGORIES
|
# create CATEGORIES
|
||||||
if ShareActions is not None and 'config' in ShareActions and 'conversion_bday_categories' in ShareActions['config']:
|
if ShareActions is not None and 'config' in ShareActions and 'conversion_bday_categories' in ShareActions['config']:
|
||||||
@@ -774,12 +772,16 @@ class Item:
|
|||||||
uid_value = uid
|
uid_value = uid
|
||||||
vevent.add('uid').value = uid_value
|
vevent.add('uid').value = uid_value
|
||||||
|
|
||||||
# set SUMMARY
|
# set placehoder for "age"
|
||||||
if vevent_enable_age:
|
if vevent_enable_age:
|
||||||
summary_value = summary.replace("{age}", str(age))
|
placeholder_mapping['{age}'] = str(age)
|
||||||
else:
|
elif not vcard_has_year:
|
||||||
summary_value = summary
|
placeholder_mapping['{age}'] = "??"
|
||||||
vevent.add('summary').value = summary_value
|
elif vcard_age_exceed_max:
|
||||||
|
placeholder_mapping['{age}'] = "!age!"
|
||||||
|
|
||||||
|
# set SUMMARY
|
||||||
|
vevent.add('summary').value = replace_placeholders(summary, placeholder_mapping)
|
||||||
|
|
||||||
# set CATEGORIES
|
# set CATEGORIES
|
||||||
if categories is not None and categories != []:
|
if categories is not None and categories != []:
|
||||||
@@ -793,16 +795,14 @@ class Item:
|
|||||||
|
|
||||||
# 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('$'):
|
||||||
(trigger, alarm_description) = entry.split(';')
|
(trigger, alarm_description) = entry.split(';')
|
||||||
logger.trace("item/convert_vcf_to_ics: alarm trigger entry: %r (trigger=%r description=%r)", entry, trigger, description)
|
logger.trace("item/convert_vcf_to_ics: alarm trigger entry: %r (trigger=%r description=%r)", entry, trigger, alarm_description)
|
||||||
td = trigger_to_timedelta(trigger)
|
td = trigger_to_timedelta(trigger)
|
||||||
if td is not None:
|
if td is not None:
|
||||||
alarm_description = replace_placeholders(alarm_description, placeholder_mapping)
|
|
||||||
alarm_description_value = alarm_description.replace("{age}", str(age))
|
|
||||||
valarm = vevent.add('valarm')
|
valarm = vevent.add('valarm')
|
||||||
valarm.add('action').value = "DISPLAY"
|
valarm.add('action').value = "DISPLAY"
|
||||||
valarm.add('description').value = alarm_description_value
|
valarm.add('description').value = replace_placeholders(alarm_description, placeholder_mapping)
|
||||||
valarm.add('trigger').value = td
|
valarm.add('trigger').value = td
|
||||||
|
|
||||||
# set RRULE
|
# set RRULE
|
||||||
@@ -813,12 +813,8 @@ class Item:
|
|||||||
vevent.add('transp').value = "TRANSPARENT"
|
vevent.add('transp').value = "TRANSPARENT"
|
||||||
|
|
||||||
# set DESCRIPTION
|
# set DESCRIPTION
|
||||||
if vevent_enable_age:
|
|
||||||
description_value = description.replace("{age}", str(age))
|
|
||||||
else:
|
|
||||||
description_value = description
|
|
||||||
if description != "":
|
if description != "":
|
||||||
vevent.add('description').value = description_value
|
vevent.add('description').value = replace_placeholders(description, placeholder_mapping)
|
||||||
|
|
||||||
# increase age
|
# increase age
|
||||||
age = age + 1
|
age = age + 1
|
||||||
|
|||||||
Reference in New Issue
Block a user