~launchpad-pqm/launchpad/devel

8687.15.14 by Karl Fogel
Add the copyright header block to files under lib/lp/blueprints/.
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
2736.1.16 by Mark Shuttleworth
ability to add someone else as a subscriber
3
4
"""Views for SpecificationSubscription."""
5
6
__metaclass__ = type
3691.73.1 by Mark Shuttleworth
Allow subscribers to be classed as essential to a spec's plan.
7
__all__ = [
8
    'SpecificationSubscriptionAddView',
9
    'SpecificationSubscriptionEditView',
10
    ]
2736.1.16 by Mark Shuttleworth
ability to add someone else as a subscriber
11
2736.1.19 by Mark Shuttleworth
clean up generalform with zcml directive support
12
7182.6.1 by Guilherme Salgado
convert SpecificationSubscriptionEditView into a LFV
13
from canonical.launchpad import _
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
14
from canonical.launchpad.webapp import (
11929.9.1 by Tim Penhey
Move launchpadform into lp.app.browser.
15
    canonical_url,
16
    )
17
from lp.app.browser.launchpadform import (
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
18
    action,
19
    LaunchpadEditFormView,
20
    LaunchpadFormView,
21
    )
8376.1.1 by Curtis Hovey
Migrated blueprint code to lp.blueprints. Resolved several circular import issues. Fixed specgraph 06-dependancies and 14-non-ascii-imagemap tests that fail on Jauny, but are fine on Hardy.
22
from lp.blueprints.interfaces.specificationsubscription import (
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
23
    ISpecificationSubscription,
24
    )
7362.9.16 by Jonathan Lange
Merge lower thread
25
26
27
class SpecificationSubscriptionAddView(LaunchpadFormView):
28
29
    schema = ISpecificationSubscription
30
    field_names = ['person', 'essential']
31
    label = 'Subscribe someone else'
32
    for_input = True
33
34
    @action(_('Continue'), name='continue')
35
    def continue_action(self, action, data):
36
        self.context.subscribe(data['person'], self.user, data['essential'])
37
        self.next_url = canonical_url(self.context)
38
39
    @property
40
    def cancel_url(self):
41
        return canonical_url(self.context)
7417.2.6 by Guilherme Salgado
Add a cancel action to the converted page
42
3691.73.1 by Mark Shuttleworth
Allow subscribers to be classed as essential to a spec's plan.
43
7182.6.1 by Guilherme Salgado
convert SpecificationSubscriptionEditView into a LFV
44
class SpecificationSubscriptionEditView(LaunchpadEditFormView):
45
46
    schema = ISpecificationSubscription
47
    field_names = ['essential']
48
    label = 'Edit subscription'
49
50
    @action(_('Change'), name='change')
51
    def change_action(self, action, data):
52
        self.updateContextFromData(data)
53
        self.next_url = canonical_url(self.context.specification)
9460.2.1 by Danilo Šegan
Convert a bunch of blueprints templates to generic-edit forms and introduce specification breadcrumb.
54
55
    @property
56
    def cancel_url(self):
57
        return canonical_url(self.context.specification)