Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
0521d9e6 by Mark Sapiro at 2021-06-18T21:22:25-07:00
Implement list:admin:notice:pending template.

- - - - -
0a5c5ec4 by Mark Sapiro at 2021-06-19T05:24:54+00:00
Merge branch 'notify' into 'master'

Implement list:admin:notice:pending template.

Closes #890

See merge request mailman/mailman!876
- - - - -


9 changed files:

- src/mailman/commands/cli_notify.py
- src/mailman/commands/tests/test_cli_notify.py
- src/mailman/docs/NEWS.rst
- src/mailman/interfaces/template.py
- src/mailman/rest/docs/templates.rst
- src/mailman/rest/tests/test_domains.py
- src/mailman/rest/tests/test_lists.py
- src/mailman/rest/tests/test_root.py
- + src/mailman/templates/en/list:admin:notice:pending.txt


Changes:

=====================================
src/mailman/commands/cli_notify.py
=====================================
@@ -27,7 +27,9 @@ from mailman.interfaces.command import ICLISubCommand
 from mailman.interfaces.listmanager import IListManager
 from mailman.interfaces.pending import IPendings
 from mailman.interfaces.requests import IListRequests, RequestType
+from mailman.interfaces.template import ITemplateLoader
 from mailman.utilities.options import I18nCommand
+from mailman.utilities.string import expand, wrap
 from public import public
 from zope.component import getUtility
 from zope.interface import implementer
@@ -138,12 +140,12 @@ def _send_notice(mlist, count, detail):
     """Creates and sends the notice to the list administrators."""
     subject = _('The {} list has {} moderation requests waiting.').format(
                 mlist.fqdn_listname, count)
-    # XXX This should be a template.
-    text = _("""The {} list has {} moderation requests waiting.
-
-{}
-Please attend to this at your earliest convenience.
-""").format(mlist.fqdn_listname, count, detail)
+    template = getUtility(ITemplateLoader).get(
+        'list:admin:notice:pending', mlist)
+    text = wrap(expand(template, mlist, dict(
+        count=count,
+        data=detail,
+        )))
     msg = OwnerNotification(mlist, subject, text, mlist.administrators)
     msg.send(mlist)
 


=====================================
src/mailman/commands/tests/test_cli_notify.py
=====================================
@@ -120,8 +120,7 @@ Held Messages:
     Reason: Some other reason
 
 
-Please attend to this at your earliest convenience.
-""")
+Please attend to this at your earliest convenience.""")
 
     def test_notify_bogus_list(self):
         result = self._command.invoke(notify,
@@ -159,8 +158,7 @@ Held Messages:
     Reason: Some other reason
 
 
-Please attend to this at your earliest convenience.
-""")
+Please attend to this at your earliest convenience.""")
 
 
 class TestBogusRFC2047(unittest.TestCase):
@@ -196,5 +194,4 @@ Held Messages:
     Reason: Non-member post
 
 
-Please attend to this at your earliest convenience.
-""")
+Please attend to this at your earliest convenience.""")


=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -105,6 +105,8 @@ New Features
   at intervals defined by the new ``run_tasks_every`` setting in the
   ``[mailman]`` section of mailman.cfg. Default is 1 hour.  (Closes #467 and
   #853)
+* There is a new ``list:admin:notice:pending`` template for the notice from
+  the ``mailman notify`` command.  (Closes #890)
 
 .. _news-3.3.4:
 


=====================================
src/mailman/interfaces/template.py
=====================================
@@ -175,6 +175,7 @@ ALL_TEMPLATES = {
         'list:admin:notice:unsubscribe',
         'list:admin:notice:disable',
         'list:admin:notice:increment',
+        'list:admin:notice:pending',
         'list:admin:notice:removal',
         'list:member:digest:footer',
         'list:member:digest:header',


=====================================
src/mailman/rest/docs/templates.rst
=====================================
@@ -482,6 +482,13 @@ below.  Here are all the supported template names:
 
     * ``member`` - display name and email address of the subscriber
 
+* ``list:admin:notice:pending``
+    The notice of pending moderator requests sent to the list administrators
+    by the ``mailman notify`` command.
+
+    * ``count`` - the number of pending requests.
+    * ``data`` - the list of pending requests.
+
 * ``list:admin:notice:removal``
    Sent to the list administrators to notify them when a member is unsubscribed
    from am mailing list due to excessive bounces.


=====================================
src/mailman/rest/tests/test_domains.py
=====================================
@@ -374,6 +374,7 @@ class TestDomainTemplates(unittest.TestCase):
                 'list:admin:action:unsubscribe': '',
                 'list:admin:notice:subscribe': '',
                 'list:admin:notice:unrecognized': '',
+                'list:admin:notice:pending': '',
                 'list:admin:notice:increment': '',
                 'list:admin:notice:disable': '',
                 'list:admin:notice:unsubscribe': '',


=====================================
src/mailman/rest/tests/test_lists.py
=====================================
@@ -859,6 +859,7 @@ class TestListTemplates(unittest.TestCase):
                 'list:admin:notice:subscribe': '',
                 'list:admin:notice:unrecognized': '',
                 'list:admin:notice:unsubscribe': '',
+                'list:admin:notice:pending': '',
                 'list:admin:notice:increment': '',
                 'list:admin:notice:disable': '',
                 'list:admin:notice:removal': '',


=====================================
src/mailman/rest/tests/test_root.py
=====================================
@@ -270,6 +270,7 @@ class TestSiteTemplates(unittest.TestCase):
                 'list:admin:notice:subscribe': '',
                 'list:admin:notice:unrecognized': '',
                 'list:admin:notice:unsubscribe': '',
+                'list:admin:notice:pending': '',
                 'list:admin:notice:increment': '',
                 'list:admin:notice:disable': '',
                 'list:admin:notice:removal': '',


=====================================
src/mailman/templates/en/list:admin:notice:pending.txt
=====================================
@@ -0,0 +1,4 @@
+The $listname list has $count moderation requests waiting.
+
+$data
+Please attend to this at your earliest convenience.



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/79e7d618aeb9d7866795ad9c1cc0a25a0fdc0d22...0a5c5ec414e0aabb91d912b1f2636d38765affed

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/79e7d618aeb9d7866795ad9c1cc0a25a0fdc0d22...0a5c5ec414e0aabb91d912b1f2636d38765affed
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list -- mailman-checkins@python.org
To unsubscribe send an email to mailman-checkins-le...@python.org
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: arch...@jab.org

Reply via email to