~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/blueprints/subscribers.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-09 09:23:38 UTC
  • mfrom: (14333.2.13 history-model)
  • Revision ID: launchpad@pqm.canonical.com-20111209092338-se7u5l0skqzaes1v
[r=jcsackett][bug=295214, 894836,
 898200] Keep sort button ob bug listing pages in sync with the
 displayed data

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
__metaclass__ = type
5
5
 
6
6
 
 
7
from canonical.database.sqlbase import block_implicit_flushes
7
8
from lp.blueprints.enums import SpecificationGoalStatus
8
9
from lp.registry.interfaces.person import IPerson
9
 
from lp.services.database.sqlbase import block_implicit_flushes
10
10
 
11
11
 
12
12
@block_implicit_flushes
28
28
    if event.user is None:
29
29
        return
30
30
    spec.updateLifecycleStatus(IPerson(event.user))
31
 
 
32
 
 
33
 
@block_implicit_flushes
34
 
def spec_created(spec, event):
35
 
    """Assign karma to the user who created the spec."""
36
 
    IPerson(event.user).assignKarma(
37
 
        'addspec', product=spec.product, distribution=spec.distribution)
38
 
 
39
 
 
40
 
@block_implicit_flushes
41
 
def spec_modified(spec, event):
42
 
    """Check changes made to the spec and assign karma if needed."""
43
 
    user = IPerson(event.user)
44
 
    spec_delta = event.object.getDelta(event.object_before_modification, user)
45
 
    if spec_delta is None:
46
 
        return
47
 
 
48
 
    # easy 1-1 mappings from attribute changing to karma
49
 
    attrs_actionnames = {
50
 
        'title': 'spectitlechanged',
51
 
        'summary': 'specsummarychanged',
52
 
        'specurl': 'specurlchanged',
53
 
        'priority': 'specpriority',
54
 
        'productseries': 'specseries',
55
 
        'distroseries': 'specseries',
56
 
        'milestone': 'specmilestone',
57
 
        }
58
 
 
59
 
    for attr, actionname in attrs_actionnames.items():
60
 
        if getattr(spec_delta, attr, None) is not None:
61
 
            user.assignKarma(
62
 
                actionname, product=spec.product,
63
 
                distribution=spec.distribution)
64
 
 
65
 
 
66
 
@block_implicit_flushes
67
 
def spec_branch_created(spec_branch, event):
68
 
    """Assign karma to the user who linked the spec to the branch."""
69
 
    spec_branch.branch.target.assignKarma(
70
 
        spec_branch.registrant, 'specbranchcreated')