~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/adapters/notification.py

  • Committer: j.c.sackett
  • Date: 2011-08-31 15:00:45 UTC
  • mfrom: (13834 devel)
  • mto: This revision was merged to the branch mainline in revision 13840.
  • Revision ID: jonathan.sackett@canonical.com-20110831150045-7s7u8upka5yx5c5c
MergedĀ inĀ devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
def notify(blamer, spr, bprs, customfiles, archive, distroseries, pocket,
128
128
           summary_text=None, changes=None, changesfile_content=None,
129
129
           changesfile_object=None, action=None, dry_run=False,
130
 
           logger=None, announce_from_person=None):
 
130
           logger=None, announce_from_person=None, previous_version=None):
131
131
    """Notify about
132
132
 
133
133
    :param blamer: The `IPerson` who is to blame for this notification.
149
149
    :param announce_from_person: If passed, use this `IPerson` as the From: in
150
150
        announcement emails.  If the person has no preferred email address,
151
151
        the person is ignored and the default From: is used instead.
 
152
    :param previous_version: If specified, the change log on the email will
 
153
        include all of the source package's change logs after that version
 
154
        up to and including the passed spr's version.
152
155
    """
153
156
    # If this is a binary or mixed upload, we don't send *any* emails
154
157
    # provided it's not a rejection or a security upload:
213
216
 
214
217
    attach_changes = not archive.is_ppa
215
218
 
216
 
    def build_and_send_mail(action, recipients, from_addr=None, bcc=None):
 
219
    def build_and_send_mail(action, recipients, from_addr=None, bcc=None,
 
220
                            previous_version=None):
217
221
        subject = calculate_subject(
218
222
            spr, bprs, customfiles, archive, distroseries, pocket, action)
219
223
        body = assemble_body(
220
224
            blamer, spr, bprs, archive, distroseries, summarystring, changes,
221
 
            action)
 
225
            action, previous_version=previous_version)
222
226
        body = body.encode("utf8")
223
227
        send_mail(
224
228
            spr, archive, recipients, subject, body, dry_run,
226
230
            attach_changes=attach_changes, from_addr=from_addr, bcc=bcc,
227
231
            logger=logger)
228
232
 
229
 
    build_and_send_mail(action, recipients)
 
233
    build_and_send_mail(
 
234
        action, recipients, previous_version=previous_version)
230
235
 
231
236
    info = fetch_information(spr, bprs, changes)
232
237
    from_addr = info['changedby']
254
259
 
255
260
        build_and_send_mail(
256
261
            'announcement', [str(distroseries.changeslist)], from_addr,
257
 
            bcc_addr)
 
262
            bcc_addr, previous_version=previous_version)
258
263
 
259
264
 
260
265
def assemble_body(blamer, spr, bprs, archive, distroseries, summary, changes,
261
 
                  action):
 
266
                  action, previous_version=None):
262
267
    """Assemble the e-mail notification body."""
263
268
    if changes is None:
264
269
        changes = {}
265
 
    info = fetch_information(spr, bprs, changes)
 
270
    info = fetch_information(
 
271
        spr, bprs, changes, previous_version=previous_version)
266
272
    information = {
267
273
        'STATUS': ACTION_DESCRIPTIONS[action],
268
274
        'SUMMARY': summary,
269
275
        'DATE': 'Date: %s' % info['date'],
270
 
        'CHANGESFILE': info['changesfile'],
 
276
        'CHANGESFILE': info['changelog'],
271
277
        'DISTRO': distroseries.distribution.title,
272
278
        'ANNOUNCE': 'No announcement sent',
273
279
        'CHANGEDBY': '',
596
602
        pocket != PackagePublishingPocket.SECURITY)
597
603
 
598
604
 
599
 
def fetch_information(spr, bprs, changes):
 
605
def fetch_information(spr, bprs, changes, previous_version=None):
600
606
    changedby = None
601
607
    changedby_displayname = None
602
608
    maintainer = None
613
619
    elif spr or bprs:
614
620
        if not spr and bprs:
615
621
            spr = bprs[0].build.source_package_release
616
 
        changesfile = spr.changelog_entry
 
622
        changesfile = spr.aggregate_changelog(previous_version)
617
623
        date = spr.dateuploaded
618
624
        changedby = person_to_email(spr.creator)
619
625
        maintainer = person_to_email(spr.maintainer)
629
635
        changesfile = date = None
630
636
 
631
637
    return {
632
 
        'changesfile': changesfile,
 
638
        'changelog': changesfile,
633
639
        'date': date,
634
640
        'changedby': changedby,
635
641
        'changedby_displayname': changedby_displayname,