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


Commits:
46e7315c by Mark Sapiro at 2021-04-11T13:40:24-07:00
Deletion of a pending request deletes associated workflow.

- - - - -
2e7e53e3 by Mark Sapiro at 2021-04-11T21:07:52+00:00
Merge branch 'wf' into 'master'

Deletion of a pending request deletes associated workflow.

See merge request mailman/mailman!825
- - - - -


3 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/model/pending.py
- src/mailman/model/tests/test_pending.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -27,6 +27,8 @@ Bugs
   triggering DSN.  (Closes #737)
 * Handling a held message now also removes the poster's pending
   ``held message`` from the pending db.  (Closes #257)
+* Deleting a pending request now also deletes any associated workflow.
+  (See #853)
 
 Command line
 ------------


=====================================
src/mailman/model/pending.py
=====================================
@@ -26,11 +26,13 @@ from mailman.database.transaction import dbconnection
 from mailman.database.types import SAUnicode, SAUnicodeXL
 from mailman.interfaces.pending import (
     IPendable, IPended, IPendedKeyValue, IPendings)
+from mailman.interfaces.workflow import IWorkflowStateManager
 from mailman.utilities.datetime import now
 from mailman.utilities.uid import TokenFactory
 from public import public
 from sqlalchemy import Column, DateTime, ForeignKey, Index, Integer, and_
 from sqlalchemy.orm import aliased, relationship
+from zope.component import getUtility
 from zope.interface import implementer
 from zope.interface.verify import verifyObject
 
@@ -146,6 +148,8 @@ class Pendings:
             pendable[keyvalue.key] = value
         if expunge:
             store.delete(pending)
+            # Discard associated workflow if any.
+            getUtility(IWorkflowStateManager).discard(token)
         return pendable
 
     @dbconnection


=====================================
src/mailman/model/tests/test_pending.py
=====================================
@@ -23,6 +23,7 @@ from mailman.app.lifecycle import create_list
 from mailman.config import config
 from mailman.interfaces.pending import IPendable, IPendings
 from mailman.interfaces.subscriptions import TokenOwner
+from mailman.interfaces.workflow import IWorkflowStateManager
 from mailman.model.pending import PendedKeyValue
 from mailman.testing.layers import ConfigLayer
 from zope.component import getUtility
@@ -54,6 +55,22 @@ class TestPendings(unittest.TestCase):
         self.assertEqual(pendingdb.count(), 0)
         self.assertEqual(config.db.store.query(PendedKeyValue).count(), 0)
 
+    def test_delete_workflow(self):
+        # Deleting a pending should delete any associated workflow state.
+        pendingdb = getUtility(IPendings)
+        wsmanager = getUtility(IWorkflowStateManager)
+        subscription = SimplePendable(
+            type='subscription',
+            address='aper...@example.com',
+            display_name='Anne Person',
+            language='en',
+            password='xyz')
+        token = pendingdb.add(subscription)
+        wsmanager.save(token, step='step1', data='data')
+        self.assertEqual(wsmanager.count, 1)
+        pendingdb.confirm(token)
+        self.assertEqual(wsmanager.count, 0)
+
     def test_find(self):
         # Test getting pendables for a mailing-list.
         mlist = create_list('li...@example.com')



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/2b05e8441265ae5edb14a5896c45f4c20213df69...2e7e53e381a49f78b289d8a359e28f4e0e16089d

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/2b05e8441265ae5edb14a5896c45f4c20213df69...2e7e53e381a49f78b289d8a359e28f4e0e16089d
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