summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/database/autorespond.py12
-rw-r--r--src/mailman/database/mailinglist.py3
-rw-r--r--src/mailman/docs/autorespond.txt37
-rw-r--r--src/mailman/interfaces/autorespond.py15
-rw-r--r--src/mailman/styles/default.py3
-rw-r--r--src/mailman/utilities/datetime.py7
6 files changed, 67 insertions, 10 deletions
diff --git a/src/mailman/database/autorespond.py b/src/mailman/database/autorespond.py
index 0a22dfa14..d65e8ed07 100644
--- a/src/mailman/database/autorespond.py
+++ b/src/mailman/database/autorespond.py
@@ -27,7 +27,7 @@ __all__ = [
]
-from storm.locals import And, Date, Int, Reference
+from storm.locals import And, Date, Desc, Int, Reference
from zope.interface import implements
from mailman.config import config
@@ -83,6 +83,16 @@ class AutoResponseSet:
self._mailing_list, address, response_type)
config.db.store.add(response)
+ def last_response(self, address, response_type):
+ """See `IAutoResponseSet`."""
+ results = config.db.store.find(
+ AutoResponseRecord,
+ And(AutoResponseRecord.address == address,
+ AutoResponseRecord.mailing_list == self._mailing_list,
+ AutoResponseRecord.response_type == response_type)
+ ).order_by(Desc(AutoResponseRecord.date_sent))
+ return (None if results.count() == 0 else results.first())
+
def adapt_mailing_list_to_response_set(iface, obj):
diff --git a/src/mailman/database/mailinglist.py b/src/mailman/database/mailinglist.py
index 02100eeb8..2c5869978 100644
--- a/src/mailman/database/mailinglist.py
+++ b/src/mailman/database/mailinglist.py
@@ -62,9 +62,6 @@ class MailingList(Model):
# will change as the schema and implementation is developed.
next_request_id = Int()
next_digest_number = Int()
- admin_responses = Pickle()
- postings_responses = Pickle()
- request_responses = Pickle()
digest_last_sent_at = DateTime()
one_last_digest = Pickle()
volume = Int()
diff --git a/src/mailman/docs/autorespond.txt b/src/mailman/docs/autorespond.txt
index d2e4797f7..7aac90b1c 100644
--- a/src/mailman/docs/autorespond.txt
+++ b/src/mailman/docs/autorespond.txt
@@ -70,3 +70,40 @@ Now the day flips over and all the counts reset.
0
>>> response_set.todays_count(address, Response.command)
0
+
+
+Response dates
+--------------
+
+You can also use the response set to get the date of the last response sent.
+
+ >>> response = response_set.last_response(address, Response.hold)
+ >>> response.mailing_list
+ <mailing list "test@example.com" at ...>
+ >>> response.address
+ <Address: aperson@example.com [not verified] at ...>
+ >>> response.response_type
+ <EnumValue: Response.hold [int=1]>
+ >>> response.date_sent
+ datetime.date(2005, 8, 1)
+
+When another response is sent today, that becomes the last one sent.
+
+ >>> response_set.response_sent(address, Response.command)
+ >>> response_set.last_response(address, Response.command).date_sent
+ datetime.date(2005, 8, 2)
+
+ >>> factory.fast_forward(days=3)
+ >>> response_set.response_sent(address, Response.command)
+ >>> response_set.last_response(address, Response.command).date_sent
+ datetime.date(2005, 8, 5)
+
+If there's been no response sent to a particular address, None is returned.
+
+ >>> address = config.db.user_manager.create_address(
+ ... u'bperson@example.com')
+
+ >>> response_set.todays_count(address, Response.command)
+ 0
+ >>> print response_set.last_response(address, Response.command)
+ None
diff --git a/src/mailman/interfaces/autorespond.py b/src/mailman/interfaces/autorespond.py
index fa4d19de6..f0b2f88bd 100644
--- a/src/mailman/interfaces/autorespond.py
+++ b/src/mailman/interfaces/autorespond.py
@@ -37,6 +37,10 @@ class Response(Enum):
hold = 1
# Email commands, i.e. -request messages.
command = 2
+ # Messages to the list owner/administrator.
+ owner = 3
+ # Messages to the list's posting address.
+ postings = 4
@@ -85,3 +89,14 @@ class IAutoResponseSet(Interface):
:param response_type: The response type being sent.
:type response_type: `Response`
"""
+
+ def last_response(address, response_type):
+ """Record the fact that another response is being sent to the address.
+
+ :param address: The address who is the recipient of the auto-response.
+ :type address: `IAddress`
+ :param response_type: The response type being sent.
+ :type response_type: `Response`
+ :return: the last response recorded.
+ :rtype: `IAutoResponseRecord`
+ """
diff --git a/src/mailman/styles/default.py b/src/mailman/styles/default.py
index 3ae7b35f3..b5bbe877d 100644
--- a/src/mailman/styles/default.py
+++ b/src/mailman/styles/default.py
@@ -177,9 +177,6 @@ ${listinfo_page}
mlist.autoresponse_admin_text = ''
mlist.autoresponse_request_text = ''
mlist.autoresponse_graceperiod = datetime.timedelta(days=90)
- mlist.postings_responses = {}
- mlist.admin_responses = {}
- mlist.request_responses = {}
# Bounces
mlist.bounce_processing = True
mlist.bounce_score_threshold = 5.0
diff --git a/src/mailman/utilities/datetime.py b/src/mailman/utilities/datetime.py
index 764b2eecd..05445335e 100644
--- a/src/mailman/utilities/datetime.py
+++ b/src/mailman/utilities/datetime.py
@@ -44,7 +44,7 @@ class DateFactory:
predictable_today = None
def now(self, tz=None):
- return (self.predictable_now
+ return (yself.predictable_now
if self.testing_mode
else datetime.datetime.now(tz))
@@ -56,11 +56,12 @@ class DateFactory:
@classmethod
def reset(cls):
cls.predictable_now = datetime.datetime(2005, 8, 1, 7, 49, 23)
- cls.predictable_today = cls.predictable_now.today()
+ cls.predictable_today = cls.predictable_now.date()
@classmethod
def fast_forward(cls, days=1):
- cls.predictable_today += datetime.timedelta(days=days)
+ cls.predictable_now += datetime.timedelta(days=days)
+ cls.predictable_today = cls.predictable_now.date()
factory = DateFactory()