Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: 4152dbfb by Nick Wynja at 2019-01-16T01:44:34Z Adds user_name_or_address substitution variable Closes #533 - - - - - 8d9f8055 by Mark Sapiro at 2019-01-16T16:00:52Z Merge branch '533-user_name_or_address' into 'master' Adds user_name_or_address substitution variable Closes #533 See merge request mailman/mailman!434 - - - - - 4 changed files: - src/mailman/docs/NEWS.rst - src/mailman/handlers/decorate.py - src/mailman/handlers/tests/test_decorate.py - src/mailman/rest/docs/templates.rst Changes: ===================================== src/mailman/docs/NEWS.rst ===================================== @@ -44,6 +44,9 @@ Other * An ``explicit_header_only`` option has been added to Reply-To: munging to avoid putting the list address in Cc:. (Closes #531) * The default list welcome message has been cleaned up a bit. (Closes #530) +* A substitution variable ``user_name_or_email`` has been added to + ``list:member:regular:header`` and ``list:member:regular:footer`` templates + when personalized deliveries are enabled. (Closes #533) 3.2.0 -- "La Villa Strangiato" ===================================== src/mailman/handlers/decorate.py ===================================== @@ -65,6 +65,7 @@ def process(mlist, msg, msgdata): d['user_delivered_to'] = _address.original_email d['user_language'] = member.preferred_language.description d['user_name'] = member.display_name + d['user_name_or_address'] = member.display_name or recipient # For backward compatibility. d['user_address'] = recipient # Calculate the archiver permalink substitution variables. This provides ===================================== src/mailman/handlers/tests/test_decorate.py ===================================== @@ -169,6 +169,44 @@ This is a test message. self.assertIn('Anne Person <aper...@example.com>', self._msg.as_string()) + def test_decorate_user_name_or_address_as_user_name(self): + site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en') + os.makedirs(site_dir) + footer_path = os.path.join(site_dir, 'myfooter.txt') + with open(footer_path, 'w', encoding='utf-8') as fp: + print('$user_name_or_address', file=fp) + getUtility(ITemplateManager).set( + 'list:member:regular:footer', None, 'mailman:///myfooter.txt') + self._mlist.preferred_language = 'en' + user = getUtility(IUserManager).make_user( + 'aper...@example.com', 'Anne Person') + member = Member(MemberRole.member, self._mlist.list_id, user) + member.preferences = Preferences() + member.preferences.preferred_language = 'en' + msgdata = dict(member=member) + decorate.process(self._mlist, self._msg, msgdata) + self.assertIn('Anne Person', + self._msg.as_string()) + + def test_decorate_user_name_or_address_as_address(self): + site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en') + os.makedirs(site_dir) + footer_path = os.path.join(site_dir, 'myfooter.txt') + with open(footer_path, 'w', encoding='utf-8') as fp: + print('$user_name_or_address', file=fp) + getUtility(ITemplateManager).set( + 'list:member:regular:footer', None, 'mailman:///myfooter.txt') + self._mlist.preferred_language = 'en' + user = getUtility(IUserManager).make_user( + 'aper...@example.com') + member = Member(MemberRole.member, self._mlist.list_id, user) + member.preferences = Preferences() + member.preferences.preferred_language = 'en' + msgdata = dict(member=member) + decorate.process(self._mlist, self._msg, msgdata) + self.assertIn('aper...@example.com', + self._msg.as_string()) + def test_decorate_header_footer_with_bad_character_mpa(self): site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en') os.makedirs(site_dir) ===================================== src/mailman/rest/docs/templates.rst ===================================== @@ -466,6 +466,9 @@ below. Here are all the supported template names: * ``user_language`` - the description of the user's preferred language (e.g. "French", "English", "Italian") * ``user_name`` - the recipient's display name if available + * ``user_name_or_email`` - the recipient's display name if available, + or their email address if no display name + (e.g. "Anne Person", "Bart", or "fper...@example.com") * ``list:member:regular:header`` The header for a regular (non-digest) message. @@ -479,6 +482,9 @@ below. Here are all the supported template names: * ``user_language`` - the description of the user's preferred language (e.g. "French", "English", "Italian") * ``user_name`` - the recipient's display name if available + * ``user_name_or_email`` - the recipient's display name if available, + or their email address if no display name + (e.g. "Anne Person", "Bart", or "fper...@example.com") * ``list:user:action:subscribe`` The message sent to subscribers when a subscription confirmation is View it on GitLab: https://gitlab.com/mailman/mailman/compare/dcc4e34a1f24e1b12da74e3ea64144b47ae217f7...8d9f8055933887570fa93fab44a5cc41a03a700c -- View it on GitLab: https://gitlab.com/mailman/mailman/compare/dcc4e34a1f24e1b12da74e3ea64144b47ae217f7...8d9f8055933887570fa93fab44a5cc41a03a700c You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org