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).
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
12
12
@block_implicit_flushes
28
28
if event.user is None:
30
30
spec.updateLifecycleStatus(IPerson(event.user))
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)
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:
48
# easy 1-1 mappings from attribute changing to karma
50
'title': 'spectitlechanged',
51
'summary': 'specsummarychanged',
52
'specurl': 'specurlchanged',
53
'priority': 'specpriority',
54
'productseries': 'specseries',
55
'distroseries': 'specseries',
56
'milestone': 'specmilestone',
59
for attr, actionname in attrs_actionnames.items():
60
if getattr(spec_delta, attr, None) is not None:
62
actionname, product=spec.product,
63
distribution=spec.distribution)
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')