~launchpad-pqm/launchpad/devel

8687.15.17 by Karl Fogel
Add the copyright header block to the rest of the files under lib/lp/.
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
6201.3.14 by Brad Crittenden
Moved ICommercialSubscription to a new module. Cleaned up tests.
4
# pylint: disable-msg=E0211,E0213
5
6
"""Interfaces including and related to ICommercialSubscription."""
7
8
__metaclass__ = type
9
10
__all__ = [
11
    'ICommercialSubscription',
12
    ]
13
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
14
from lazr.restful.declarations import (
15
    export_as_webservice_entry,
16
    exported,
17
    )
18
from lazr.restful.fields import ReferenceChoice
7431.2.10 by Brad Crittenden
Fix lint problems.
19
from zope.interface import Interface
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
20
from zope.schema import (
21
    Bool,
22
    Datetime,
23
    Int,
24
    Text,
25
    TextLine,
26
    )
7431.2.4 by Brad Crittenden
Export product attributes and the method forReview to allow licensing queries through the API.
27
14600.1.12 by Curtis Hovey
Move i18n to lp.
28
from lp import _
11318.5.1 by j.c.sackett
Migrated canonical.launchpad.fields to lp.services.fields
29
from lp.services.fields import PublicPersonChoice
6201.3.14 by Brad Crittenden
Moved ICommercialSubscription to a new module. Cleaned up tests.
30
31
32
class ICommercialSubscription(Interface):
33
    """A Commercial Subscription for a Product.
34
35
    If the product has a license which does not qualify for free
36
    hosting, a subscription needs to be purchased.
37
    """
7431.2.15 by Brad Crittenden
Changes per review
38
    # Mark commercial subscriptions as exported entries for the Launchpad API.
7431.2.4 by Brad Crittenden
Export product attributes and the method forReview to allow licensing queries through the API.
39
    export_as_webservice_entry()
40
7431.2.7 by Brad Crittenden
Correct permissions for newly exported entities; Add support for exporting CommercialSubscriptions.
41
    id = Int(title=_('ID'), readonly=True, required=True)
42
7431.2.4 by Brad Crittenden
Export product attributes and the method forReview to allow licensing queries through the API.
43
    product = exported(
44
        ReferenceChoice(
45
            title=_("Product which has commercial subscription"),
46
            required=True,
47
            readonly=True,
48
            vocabulary='Product',
11882.2.7 by Jonathan Lange
Make the product interface declaration responsible for fixing commercialsubscription.
49
            # Really IProduct.  Set properly in lp/registry/interfaces/product.py
7431.2.15 by Brad Crittenden
Changes per review
50
            schema=Interface,
7431.2.4 by Brad Crittenden
Export product attributes and the method forReview to allow licensing queries through the API.
51
            description=_(
7431.2.10 by Brad Crittenden
Fix lint problems.
52
                "Project for which this commercial subscription is "
53
                "applied.")))
7431.2.4 by Brad Crittenden
Export product attributes and the method forReview to allow licensing queries through the API.
54
55
    date_created = exported(
56
        Datetime(
57
            title=_('Date Created'),
58
            readonly=True,
59
            description=_("The date the first subscription was applied.")))
60
61
    date_last_modified = exported(
62
        Datetime(
63
            title=_('Date Modified'),
64
            description=_("The date the subscription was modified.")))
65
66
    date_starts = exported(
67
        Datetime(
68
            title=_('Beginning of Subscription'),
69
            description=_("The date the subscription starts.")))
70
71
    date_expires = exported(
72
        Datetime(
73
            title=_('Expiration Date'),
74
            description=_("The expiration date of the subscription.")))
75
76
    registrant = exported(
77
        PublicPersonChoice(
78
            title=_('Registrant'),
79
            required=True,
80
            readonly=True,
81
            vocabulary='ValidPerson',
82
            description=_("Person who redeemed the voucher.")))
83
84
    purchaser = exported(
85
        PublicPersonChoice(
86
            title=_('Purchaser'),
87
            required=True,
88
            readonly=True,
89
            vocabulary='ValidPerson',
90
            description=_("Person who purchased the voucher.")))
6201.3.14 by Brad Crittenden
Moved ICommercialSubscription to a new module. Cleaned up tests.
91
92
    sales_system_id = TextLine(
93
        title=_('Voucher'),
94
        description=_("Code to redeem subscription."))
95
96
    whiteboard = Text(
97
        title=_("Whiteboard"), required=False,
98
        description=_("Notes on this project subscription."))
6201.5.1 by Edwin Grubbs
Fixed product.requires_commercial_subscription and commercial_subscription.is_active
99
7431.2.4 by Brad Crittenden
Export product attributes and the method forReview to allow licensing queries through the API.
100
    is_active = exported(
101
        Bool(
102
            title=_('Active'),
103
            readonly=True,
104
            description=_("Whether this subscription is active.")))