Merge lp:~lifeless/launchpad/registry into lp:launchpad

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 11573
Proposed branch: lp:~lifeless/launchpad/registry
Merge into: lp:launchpad
Diff against target: 107 lines (+36/-13)
3 files modified
lib/lp/registry/browser/team.py (+17/-4)
lib/lp/registry/interfaces/mailinglist.py (+3/-1)
lib/lp/registry/model/mailinglist.py (+16/-8)
To merge this branch: bzr merge lp:~lifeless/launchpad/registry
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Launchpad code reviewers Pending
Review via email: mp+35774@code.launchpad.net

Commit message

Fix mailing list moderation UFD's.

Description of the change

Fix unexpected form data in mailing list moderation.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Note, this is tested by the tests for moderation; specific tests could be added but I don't think they'll add any coverage or value. (migrating the higher level tests down would add value, but only if we /move/ not /add/.

Revision history for this message
Curtis Hovey (sinzui) wrote :

This looks good to land.

review: Approve (code)
Revision history for this message
Brad Crittenden (bac) wrote :

Robert,

Per our shiny new multi-line import rule, could you fix line 9 please?

:)

--Brad

Revision history for this message
Robert Collins (lifeless) wrote :

The thing is Brad, that line 9 is actually ok in bzr, which is what I was referencing ;)

I will change it anyhow, but I think we can easily spend a lot of cycles on trivial stuff.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/registry/browser/team.py'
--- lib/lp/registry/browser/team.py 2010-09-14 00:21:04 +0000
+++ lib/lp/registry/browser/team.py 2010-09-17 18:36:33 +0000
@@ -25,7 +25,10 @@
2525
26from datetime import datetime26from datetime import datetime
27import math27import math
28from urllib import quote28from urllib import (
29 quote,
30 unquote,
31 )
2932
30import pytz33import pytz
31from zope.app.form.browser import TextAreaWidget34from zope.app.form.browser import TextAreaWidget
@@ -838,9 +841,19 @@
838 # won't be in data. Instead, get it out of the request.841 # won't be in data. Instead, get it out of the request.
839 reviewable = self.hold_count842 reviewable = self.hold_count
840 disposed_count = 0843 disposed_count = 0
841 for message in self.held_messages.currentBatch():844 actions = {}
842 action_name = self.request.form_ng.getOne(845 form = self.request.form_ng
843 'field.' + quote(message.message_id))846 for field_name in form:
847 if (field_name.startswith('field.') and
848 field_name.endswith('')):
849 # A moderated message.
850 quoted_id = field_name[len('field.'):]
851 message_id = unquote(quoted_id)
852 actions[message_id] = form.getOne(field_name)
853 messages = self.mailing_list.getReviewableMessages(
854 message_id_filter=actions)
855 for message in messages:
856 action_name = actions[message.message_id]
844 # This essentially acts like a switch statement or if/elifs. It857 # This essentially acts like a switch statement or if/elifs. It
845 # looks the action up in a map of allowed actions, watching out858 # looks the action up in a map of allowed actions, watching out
846 # for bogus input.859 # for bogus input.
847860
=== modified file 'lib/lp/registry/interfaces/mailinglist.py'
--- lib/lp/registry/interfaces/mailinglist.py 2010-08-20 20:31:18 +0000
+++ lib/lp/registry/interfaces/mailinglist.py 2010-09-17 18:36:33 +0000
@@ -431,9 +431,11 @@
431 :return: The IMessageApproval representing the held message.431 :return: The IMessageApproval representing the held message.
432 """432 """
433433
434 def getReviewableMessages():434 def getReviewableMessages(message_id_filter=None):
435 """Return the set of all held messages for this list requiring review.435 """Return the set of all held messages for this list requiring review.
436436
437 :param message_id_filter: If supplied only messages with message ids in
438 the filter are returned.
437 :return: A sequence of `IMessageApproval`s for this mailing list,439 :return: A sequence of `IMessageApproval`s for this mailing list,
438 where the status is `PostedMessageStatus.NEW`. The returned set440 where the status is `PostedMessageStatus.NEW`. The returned set
439 is ordered first by the date the message was posted, then by441 is ordered first by the date the message was posted, then by
440442
=== modified file 'lib/lp/registry/model/mailinglist.py'
--- lib/lp/registry/model/mailinglist.py 2010-09-03 03:12:39 +0000
+++ lib/lp/registry/model/mailinglist.py 2010-09-17 18:36:33 +0000
@@ -21,6 +21,7 @@
21 make_header,21 make_header,
22 )22 )
23from itertools import repeat23from itertools import repeat
24import operator
24from socket import getfqdn25from socket import getfqdn
25from string import Template26from string import Template
2627
@@ -63,8 +64,10 @@
63 sqlvalues,64 sqlvalues,
64 )65 )
65from canonical.launchpad import _66from canonical.launchpad import _
67from canonical.launchpad.components.decoratedresultset import DecoratedResultSet
66from canonical.launchpad.database.account import Account68from canonical.launchpad.database.account import Account
67from canonical.launchpad.database.emailaddress import EmailAddress69from canonical.launchpad.database.emailaddress import EmailAddress
70from canonical.launchpad.database.message import Message
68from canonical.launchpad.interfaces.account import AccountStatus71from canonical.launchpad.interfaces.account import AccountStatus
69from canonical.launchpad.interfaces.emailaddress import (72from canonical.launchpad.interfaces.emailaddress import (
70 EmailAddressStatus,73 EmailAddressStatus,
@@ -557,15 +560,20 @@
557 notify(ObjectCreatedEvent(held_message))560 notify(ObjectCreatedEvent(held_message))
558 return held_message561 return held_message
559562
560 def getReviewableMessages(self):563 def getReviewableMessages(self, message_id_filter=None):
561 """See `IMailingList`."""564 """See `IMailingList`."""
562 return MessageApproval.select("""565 store = Store.of(self)
563 MessageApproval.mailing_list = %s AND566 clauses = [
564 MessageApproval.status = %s AND567 MessageApproval.mailing_listID==self.id,
565 MessageApproval.message = Message.id568 MessageApproval.status==PostedMessageStatus.NEW,
566 """ % sqlvalues(self, PostedMessageStatus.NEW),569 MessageApproval.messageID==Message.id,
567 clauseTables=['Message'],570 ]
568 orderBy=['posted_date', 'Message.rfc822msgid'])571 if message_id_filter is not None:
572 clauses.append(Message.rfc822msgid.is_in(message_id_filter))
573 results = store.find((MessageApproval, Message),
574 *clauses)
575 results.order_by(MessageApproval.posted_date, Message.rfc822msgid)
576 return DecoratedResultSet(results, operator.itemgetter(0))
569577
570 def purge(self):578 def purge(self):
571 """See `IMailingList`."""579 """See `IMailingList`."""