Exemplo n.º 1
0
 def createDelta(self, user=None, **kwargs):
     if user is None:
         user = self.user
     return BugDelta(bug=self.bug,
                     bugurl=canonical_url(self.bug),
                     user=user,
                     **kwargs)
Exemplo n.º 2
0
def notify_bugtask_edited(modified_bugtask, event):
    """Notify CC'd subscribers of this bug that something has changed
    on this task.

    modified_bugtask must be an IBugTask. event must be an
    IObjectModifiedEvent.
    """
    bugtask_delta = event.object.getDelta(event.object_before_modification)
    bug_delta = BugDelta(bug=event.object.bug,
                         bugurl=canonical_url(event.object.bug),
                         bugtask_deltas=bugtask_delta,
                         user=IPerson(event.user))

    event_creator = IPerson(event.user)
    previous_subscribers = event.object_before_modification.bug_subscribers
    current_subscribers = event.object.bug_subscribers
    prev_subs_set = set(previous_subscribers)
    cur_subs_set = set(current_subscribers)
    new_subs = cur_subs_set.difference(prev_subs_set)

    add_bug_change_notifications(bug_delta,
                                 old_bugtask=event.object_before_modification,
                                 new_subscribers=new_subs)

    send_bug_details_to_new_bug_subscribers(event.object.bug,
                                            previous_subscribers,
                                            current_subscribers,
                                            event_creator=event_creator)
Exemplo n.º 3
0
def get_bug_delta(old_bug, new_bug, user):
    """Compute the delta from old_bug to new_bug.

    old_bug and new_bug are IBug's. user is an IPerson. Returns an
    IBugDelta if there are changes, or None if there were no changes.
    """
    changes = {}
    fields = [
        "title", "description", "name", "information_type", "duplicateof",
        "tags"
    ]
    for field_name in fields:
        # fields for which we show old => new when their values change
        old_val = getattr(old_bug, field_name)
        new_val = getattr(new_bug, field_name)
        if old_val != new_val:
            changes[field_name] = {}
            changes[field_name]["old"] = old_val
            changes[field_name]["new"] = new_val

    if changes:
        changes["bug"] = new_bug
        changes["bug_before_modification"] = old_bug
        changes["bugurl"] = canonical_url(new_bug)
        changes["user"] = user
        return BugDelta(**changes)
    else:
        return None
Exemplo n.º 4
0
def notify_bug_attachment_removed(bugattachment, event):
    """Notify that an attachment has been removed."""
    bug = bugattachment.bug
    bug_delta = BugDelta(bug=bug,
                         bugurl=canonical_url(bug),
                         user=IPerson(event.user),
                         attachment={
                             'old': bugattachment,
                             'new': None
                         })

    add_bug_change_notifications(bug_delta)
Exemplo n.º 5
0
def notify_bug_attachment_added(bugattachment, event):
    """Notify CC'd list that a new attachment has been added.

    bugattachment must be an IBugAttachment. event must be an
    IObjectCreatedEvent.
    """
    bug = bugattachment.bug
    bug_delta = BugDelta(bug=bug,
                         bugurl=canonical_url(bug),
                         user=IPerson(event.user),
                         attachment={
                             'new': bugattachment,
                             'old': None
                         })

    add_bug_change_notifications(bug_delta)