~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# pylint: disable-msg=E0211,E0213

"""Interfaces including and related to ICommercialSubscription."""

__metaclass__ = type

__all__ = [
    'ICommercialSubscription',
    ]

from lazr.restful.declarations import (
    export_as_webservice_entry,
    exported,
    )
from lazr.restful.fields import ReferenceChoice
from zope.interface import Interface
from zope.schema import (
    Bool,
    Datetime,
    Int,
    Text,
    TextLine,
    )

from lp import _
from lp.services.fields import PublicPersonChoice


class ICommercialSubscription(Interface):
    """A Commercial Subscription for a Product.

    If the product has a license which does not qualify for free
    hosting, a subscription needs to be purchased.
    """
    # Mark commercial subscriptions as exported entries for the Launchpad API.
    export_as_webservice_entry()

    id = Int(title=_('ID'), readonly=True, required=True)

    product = exported(
        ReferenceChoice(
            title=_("Product which has commercial subscription"),
            required=True,
            readonly=True,
            vocabulary='Product',
            # Really IProduct.  Set properly in lp/registry/interfaces/product.py
            schema=Interface,
            description=_(
                "Project for which this commercial subscription is "
                "applied.")))

    date_created = exported(
        Datetime(
            title=_('Date Created'),
            readonly=True,
            description=_("The date the first subscription was applied.")))

    date_last_modified = exported(
        Datetime(
            title=_('Date Modified'),
            description=_("The date the subscription was modified.")))

    date_starts = exported(
        Datetime(
            title=_('Beginning of Subscription'),
            description=_("The date the subscription starts.")))

    date_expires = exported(
        Datetime(
            title=_('Expiration Date'),
            description=_("The expiration date of the subscription.")))

    registrant = exported(
        PublicPersonChoice(
            title=_('Registrant'),
            required=True,
            readonly=True,
            vocabulary='ValidPerson',
            description=_("Person who redeemed the voucher.")))

    purchaser = exported(
        PublicPersonChoice(
            title=_('Purchaser'),
            required=True,
            readonly=True,
            vocabulary='ValidPerson',
            description=_("Person who purchased the voucher.")))

    sales_system_id = TextLine(
        title=_('Voucher'),
        description=_("Code to redeem subscription."))

    whiteboard = Text(
        title=_("Whiteboard"), required=False,
        description=_("Notes on this project subscription."))

    is_active = exported(
        Bool(
            title=_('Active'),
            readonly=True,
            description=_("Whether this subscription is active.")))