class IBugSubscription(Interface):
    """The relationship between a person and a bug."""

    export_as_webservice_entry(publish_web_link=False, as_of="beta")

    id = Int(title=_('ID'), readonly=True, required=True)
    person = exported(PersonChoice(title=_('Person'),
                                   required=True,
                                   vocabulary='ValidPersonOrTeam',
                                   readonly=True,
                                   description=_(
                                       "The person's Launchpad ID or "
                                       "e-mail address.")),
                      as_of="beta")
    bug = exported(Reference(Interface,
                             title=_("Bug"),
                             required=True,
                             readonly=True),
                   as_of="beta")
    # We mark this as doNotSnapshot() because it's a magically-generated
    # Storm attribute and it causes Snapshot to break.
    bugID = doNotSnapshot(Int(title=u"The bug id.", readonly=True))
    bug_notification_level = exported(Choice(
        title=_("Bug notification level"),
        required=True,
        vocabulary=BugNotificationLevel,
        default=BugNotificationLevel.COMMENTS,
        description=_("The volume and type of bug notifications "
                      "this subscription will generate."),
    ),
                                      as_of="devel")
    date_created = exported(Datetime(title=_('Date subscribed'),
                                     required=True,
                                     readonly=True),
                            as_of="beta")
    subscribed_by = exported(PersonChoice(
        title=_('Subscribed by'),
        required=True,
        vocabulary='ValidPersonOrTeam',
        readonly=True,
        description=_("The person who created this subscription.")),
                             as_of="beta")

    display_subscribed_by = Attribute("`subscribed_by` formatted for display.")

    display_duplicate_subscribed_by = Attribute(
        "duplicate bug `subscribed_by` formatted for display.")

    @call_with(user=REQUEST_USER)
    @export_read_operation()
    @operation_for_version("beta")
    def canBeUnsubscribedByUser(user):
        """Can the user unsubscribe the subscriber from the bug?"""
Beispiel #2
0
class ISpecificationSubscription(Interface):
    """A subscription for a person to a specification."""

    export_as_webservice_entry(publish_web_link=False, as_of='devel')

    id = Int(title=_('ID'), required=True, readonly=True)
    person = PersonChoice(
        title=_('Subscriber'),
        required=True,
        vocabulary='ValidPersonOrTeam',
        readonly=True,
        description=_(
            'The person you would like to subscribe to this blueprint. '
            'They will be notified of the subscription by email.'))
    personID = Attribute('db person value')
    specification = Int(title=_('Specification'), required=True, readonly=True)
    specificationID = Attribute('db specification value')
    essential = Bool(title=_('Participation essential'),
                     required=True,
                     description=_(
                         'Check this if participation in the design of '
                         'the feature is essential.'),
                     default=False)

    @call_with(user=REQUEST_USER)
    @export_read_operation()
    @operation_for_version("devel")
    def canBeUnsubscribedByUser(user):
        """Can the user unsubscribe the subscriber from the specification?"""
Beispiel #3
0
class IBranchMergeQueue(Interface):
    """An interface for managing branch merges."""

    export_as_webservice_entry()

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

    registrant = exported(
        PublicPersonChoice(
            title=_("The user that registered the branch."),
            required=True, readonly=True,
            vocabulary='ValidPersonOrTeam'))

    owner = exported(
        PersonChoice(
            title=_('Owner'),
            required=True, readonly=True,
            vocabulary='UserTeamsParticipationPlusSelf',
            description=_("The owner of the merge queue.")))

    name = exported(
        TextLine(
            title=_('Name'), required=True,
            description=_(
                "Keep very short, unique, and descriptive, because it will "
                "be used in URLs.  "
                "Examples: main, devel, release-1.0, gnome-vfs.")))

    description = exported(
        Text(
            title=_('Description'), required=False,
            description=_(
                'A short description of the purpose of this merge queue.')))

    configuration = exported(
        TextLine(
            title=_('Configuration'), required=False, readonly=True,
            description=_(
                "A JSON string of configuration values.")))

    date_created = exported(
        Datetime(
            title=_('Date Created'),
            required=True,
            readonly=True))

    branches = exported(
        CollectionField(
            title=_('Dependent Branches'),
            description=_(
                'A collection of branches that this queue manages.'),
            readonly=True,
            value_type=Reference(Interface)))

    @mutator_for(configuration)
    @operation_parameters(
        config=TextLine(title=_("A JSON string of configuration values.")))
    @export_write_operation()
    def setMergeQueueConfig(config):
        """Set the JSON string configuration of the merge queue.
Beispiel #4
0
class ILiveFSEditableAttributes(IHasOwner):
    """`ILiveFS` attributes that can be edited.

    These attributes need launchpad.View to see, and launchpad.Edit to change.
    """
    date_last_modified = exported(Datetime(
        title=_("Date last modified"), required=True, readonly=True))

    owner = exported(PersonChoice(
        title=_("Owner"), required=True, readonly=False,
        vocabulary="AllUserTeamsParticipationPlusSelf",
        description=_("The owner of this live filesystem image.")))

    distro_series = exported(Reference(
        IDistroSeries, title=_("Distro Series"), required=True, readonly=False,
        description=_("The series for which the image should be built.")))

    name = exported(TextLine(
        title=_("Name"), required=True, readonly=False,
        constraint=name_validator,
        description=_("The name of the live filesystem image.")))

    metadata = exported(Dict(
        title=_(
            "A dict of data about the image.  Entries here will be passed to "
            "the builder slave."),
        key_type=TextLine(), required=True, readonly=False))
class IQuestionSubscription(Interface):
    """A subscription for a person to a question."""

    export_as_webservice_entry(publish_web_link=False, as_of='devel')

    id = Int(title=_('ID'), readonly=True, required=True)
    person = exported(PersonChoice(title=_('Person'),
                                   required=True,
                                   vocabulary='ValidPersonOrTeam',
                                   readonly=True,
                                   description=_(
                                       "The person's Launchpad ID or "
                                       "e-mail address.")),
                      as_of="devel")
    question = exported(Reference(Interface,
                                  title=_("Question"),
                                  required=True,
                                  readonly=True),
                        as_of="devel")
    date_created = exported(Datetime(title=_('Date subscribed'),
                                     required=True,
                                     readonly=True),
                            as_of="devel")

    def canBeUnsubscribedByUser(user):
        """Can the user unsubscribe the subscriber from the question?"""
class IBugActivity(Interface):
    """A log of all things that have happened to a bug."""
    export_as_webservice_entry()

    bug = exported(BugField(title=_('Bug'), readonly=True))

    datechanged = exported(
        Datetime(title=_('Date Changed'),
                 description=_("The date on which this activity occurred."),
                 readonly=True))

    personID = Attribute('DB ID for Person')
    person = exported(
        PersonChoice(title=_('Person'),
                     required=True,
                     vocabulary='ValidPersonOrTeam',
                     readonly=True,
                     description=_("The person's Launchpad ID or "
                                   "e-mail address.")))

    whatchanged = exported(
        TextLine(title=_('What Changed'),
                 description=_("The property of the bug that changed."),
                 readonly=True))

    target = TextLine(
        title=_('Change Target'),
        required=False,
        readonly=True,
        description=_(
            'The target of what changed, if the change occurred on a '
            'bugtask.'))

    attribute = TextLine(
        title=_('Changed Attribute'),
        required=True,
        readonly=True,
        description=_(
            "The attribute that changed.  If the change occurred on a "
            "bugtask, this will be the bugtask's attribute; otherwise "
            "it will be the bug attribute, and the same as 'what "
            "changed'."))

    oldvalue = exported(
        TextLine(title=_('Old Value'),
                 description=_("The value before the change."),
                 readonly=True))

    newvalue = exported(
        TextLine(title=_('New Value'),
                 description=_("The value after the change."),
                 readonly=True))

    message = exported(
        Text(title=_('Message'),
             description=_("Additional information about what changed."),
             readonly=True))
Beispiel #7
0
class IGitActivity(Interface):
    """An activity log entry for a Git repository."""

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

    repository = Reference(
        title=_("Repository"),
        required=True,
        readonly=True,
        schema=IGitRepository,
        description=_("The repository that this log entry is for."))

    date_changed = Datetime(
        title=_("Date changed"),
        required=True,
        readonly=True,
        description=_("The time when this change happened."))

    changer = PublicPersonChoice(
        title=_("Changer"),
        required=True,
        readonly=True,
        vocabulary="ValidPerson",
        description=_("The user who made this change."))

    changee = PersonChoice(
        title=_("Changee"),
        required=False,
        readonly=True,
        vocabulary="ValidPersonOrTeam",
        description=_("The person or team that this change was applied to."))

    changee_description = Attribute(
        "A human-readable description of the changee.")

    what_changed = Choice(
        title=_("What changed"),
        required=True,
        readonly=True,
        vocabulary=GitActivityType,
        description=_("The property of the repository that changed."))

    old_value = Dict(
        title=_("Old value"),
        required=False,
        readonly=True,
        description=_("Representation of the value before the change."),
        key_type=TextLine(),
        value_type=Text())

    new_value = Dict(
        title=_("New value"),
        required=False,
        readonly=True,
        description=_("Representation of the value after the change."),
        key_type=TextLine(),
        value_type=Text())
Beispiel #8
0
class IHasBugSupervisor(Interface):

    bug_supervisor = exported(
        PersonChoice(
            title=_("Bug Supervisor"),
            description=_(
                "The Launchpad id of the person or team (preferred) responsible "
                "for bug management."),
            required=False,
            vocabulary='ValidPersonOrTeam',
            readonly=False))
Beispiel #9
0
class IStructuralSubscriptionPublic(Interface):
    """The public parts of a subscription to a Launchpad structure."""

    id = Int(title=_('ID'), readonly=True, required=True)
    product = Int(title=_('Product'), required=False, readonly=True)
    productseries = Int(title=_('Product series'),
                        required=False,
                        readonly=True)
    projectgroup = Int(title=_('Project group'), required=False, readonly=True)
    milestone = Int(title=_('Milestone'), required=False, readonly=True)
    distribution = Int(title=_('Distribution'), required=False, readonly=True)
    distroseries = Int(title=_('Distribution series'),
                       required=False,
                       readonly=True)
    sourcepackagename = Int(title=_('Source package name'),
                            required=False,
                            readonly=True)
    subscriber = exported(
        PersonChoice(title=_('Subscriber'),
                     required=True,
                     vocabulary='ValidPersonOrTeam',
                     readonly=True,
                     description=_("The person subscribed.")))
    subscribed_by = exported(
        PublicPersonChoice(
            title=_('Subscribed by'),
            required=True,
            vocabulary='ValidPersonOrTeam',
            readonly=True,
            description=_("The person creating the subscription.")))
    date_created = exported(
        Datetime(title=_("The date on which this subscription was created."),
                 required=False,
                 readonly=True))
    date_last_updated = exported(
        Datetime(
            title=_("The date on which this subscription was last updated."),
            required=False,
            readonly=True))

    target = exported(
        Reference(
            schema=Interface,  # IStructuralSubscriptionTarget
            required=True,
            readonly=True,
            title=_("The structure to which this subscription belongs.")))

    bug_filters = exported(
        CollectionField(
            title=_('List of bug filters that narrow this subscription.'),
            readonly=True,
            required=False,
            value_type=Reference(schema=Interface)))  # IBugSubscriptionFilter
Beispiel #10
0
class IAbstractSubscriptionInfo(Interface):

    bug = BugField(
        title=_("Bug"), readonly=True, required=True,
        description=_("A bug that this subscription is on. "
                      "If subscription is on a duplicate "
                      "bug, references that bug."))

    principal = PersonChoice(
        title=_("Subscriber"), required=True, readonly=True,
        vocabulary='ValidPersonOrTeam',
        description=_(
            "The person or team for which this information is gathered."))
class IBugSubscriptionFilterMute(Interface):
    """A mute on an IBugSubscriptionFilter."""

    person = PersonChoice(
        title=_('Person'), required=True, vocabulary='ValidPersonOrTeam',
        readonly=True, description=_("The person subscribed."))
    filter = Reference(
        IBugSubscriptionFilter, title=_("Subscription filter"),
        required=True, readonly=True,
        description=_("The subscription filter to be muted."))
    date_created = Datetime(
        title=_("The date on which the mute was created."), required=False,
        readonly=True)
Beispiel #12
0
class IPersonSubscriptions(Interface):
    """Subscription information for a given person and bug."""

    count = Attribute(
        'The total number of subscriptions, real and virtual')

    muted = Bool(
       title=_("Bug is muted?"),
       description=_("Is the bug muted?"),
       default=False, readonly=True)

    bug = BugField(
        title=_("Bug"), readonly=True, required=True,
        description=_("A bug that this subscription is on. "
                      "If subscription is on a duplicate "
                      "bug, references that bug."))

    person = PersonChoice(
        title=_("Subscriber"), required=True, readonly=True,
        vocabulary='ValidPersonOrTeam',
        description=_("The person for which this information is gathered."))

    direct = Attribute(
        "An IRealSubscriptionInfoCollection.  Contains information about all "
        "direct subscriptions. Includes those through membership in teams "
        "directly subscribed to a bug.")

    from_duplicate = Attribute(
        "An IRealSubscriptionInfoCollection.  Contains information about all "
        "subscriptions through duplicate bugs. Includes those through team "
        "membership.")

    as_owner = Attribute(
        "An IVirtualSubscriptionInfoCollection containing information about "
        "all virtual subscriptions as target owner when no bug supervisor "
        "is defined for the target, including those through team "
        "memberships.")

    as_assignee = Attribute(
        "An IVirtualSubscriptionInfoCollection containing information about "
        "all virtual subscriptions as an assignee, including those through "
        "team memberships.")

    def reload():
        """Reload subscriptions for a person/bug."""

    def getDataForClient():
        """Get data for use in client-side code.
Beispiel #13
0
class ISourcePackageRecipeEditableAttributes(IHasOwner):
    """ISourcePackageRecipe attributes that can be edited.

    These attributes need launchpad.View to see, and launchpad.Edit to change.
    """
    daily_build_archive = exported(
        Reference(IArchive, title=_("The archive to use for daily builds.")))

    builder_recipe = Attribute(
        _("The bzr-builder data structure for the recipe."))

    owner = exported(
        PersonChoice(
            title=_('Owner'),
            required=True,
            readonly=False,
            vocabulary='UserTeamsParticipationPlusSelf',
            description=_("The person or team who can edit this recipe.")))

    distroseries = exported(
        List(ReferenceChoice(schema=IDistroSeries,
                             vocabulary='BuildableDistroSeries'),
             title=_("Default distribution series"),
             description=_("If built daily, these are the distribution "
                           "versions that the recipe will be built for."),
             readonly=True))
    build_daily = exported(
        Bool(title=_("Built daily"),
             description=_(
                 "Automatically build each day, if the source has changed.")))

    name = exported(
        TextLine(title=_("Name"),
                 required=True,
                 constraint=name_validator,
                 description=_(
                     "The name of the recipe is part of the URL and needs to "
                     "be unique for the given owner.")))

    description = exported(
        Description(title=_('Description'),
                    required=False,
                    description=_('A short description of the recipe.')))

    date_last_modified = exported(Datetime(required=True, readonly=True))

    is_stale = Bool(title=_('Recipe is stale.'))
Beispiel #14
0
class IGitRuleGrantView(Interface):
    """`IGitRuleGrant` attributes that require launchpad.View."""

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

    repository = Reference(
        title=_("Repository"), required=True, readonly=True,
        schema=IGitRepository,
        description=_("The repository that this grant is for."))

    rule = Reference(
        title=_("Rule"), required=True, readonly=True,
        schema=IGitRule,
        description=_("The rule that this grant is for."))

    grantor = PublicPersonChoice(
        title=_("Grantor"), required=True, readonly=True,
        vocabulary="ValidPerson",
        description=_("The user who created this grant."))

    grantee_type = Choice(
        title=_("Grantee type"), required=True, readonly=True,
        vocabulary=GitGranteeType,
        description=_("The type of grantee for this grant."))

    grantee = PersonChoice(
        title=_("Grantee"), required=False, readonly=True,
        vocabulary="ValidPersonOrTeam",
        description=_("The person being granted access."))

    combined_grantee = Attribute(
        "The overall grantee of this grant: either a `GitGranteeType` (other "
        "than `PERSON`) or an `IPerson`.")

    date_created = Datetime(
        title=_("Date created"), required=True, readonly=True,
        description=_("The time when this grant was created."))

    date_last_modified = Datetime(
        title=_("Date last modified"), required=True, readonly=True,
        description=_("The time when this grant was last modified."))
class ICodeReviewVoteReferencePublic(Interface):
    """The public attributes for code review vote references."""

    id = Int(title=_("The ID of the vote reference"))

    branch_merge_proposal = exported(
        Reference(
            title=_("The merge proposal that is the subject of this vote"),
            required=True,
            schema=IBranchMergeProposal))

    date_created = exported(
        Datetime(title=_('Date Created'), required=True, readonly=True))

    registrant = exported(
        PublicPersonChoice(
            title=_("The person who originally registered this vote"),
            required=True,
            vocabulary='ValidPersonOrTeam'))

    reviewer = exported(
        PersonChoice(title=_('Reviewer'),
                     required=True,
                     description=_('A person who you want to review this.'),
                     vocabulary='ValidBranchReviewer'))

    review_type = exported(
        TextLine(title=_('Review type'),
                 required=False,
                 description=_(
                     "Lowercase keywords describing the type of review.")))

    comment = exported(
        Reference(title=_(
            "The code review comment that contains the most recent vote."),
                  required=True,
                  schema=ICodeReviewComment))

    is_pending = exported(
        Bool(title=_("Is the pending?"), required=True, readonly=True))
class IArchiveSubscriberUI(Interface):
    """A custom interface for user interaction with archive subscriptions.

    IArchiveSubscriber uses a datetime field for date_expires, whereas
    we simply want to use a date field when users create or edit new
    subscriptions.
    """
    subscriber = PersonChoice(
        title=_("Subscriber"),
        required=True,
        vocabulary='ValidPersonOrTeam',
        description=_("The person or team to grant access."))

    date_expires = Date(title=_("Date of Expiration"),
                        required=False,
                        description=_(
                            "The date when the access will expire. "
                            "Leave this blank for access that should "
                            "never expire."))

    description = Text(title=_("Description"),
                       required=False,
                       description=_("Optional notes about this access."))
Beispiel #17
0
    def setUpFields(self):
        super(SourcePackageRecipeEditView, self).setUpFields()

        # Ensure distro series widget allows input
        self.form_fields['distroseries'].for_input = True

        if check_permission('launchpad.Admin', self.context):
            # Exclude the PPA archive dropdown.
            self.form_fields = self.form_fields.omit('daily_build_archive')

            owner_field = self.schema['owner']
            any_owner_choice = PersonChoice(
                __name__='owner',
                title=owner_field.title,
                description=(u"As an administrator you are able to reassign"
                             u" this branch to any person or team."),
                required=True,
                vocabulary='ValidPersonOrTeam')
            any_owner_field = form.Fields(any_owner_choice,
                                          render_context=self.render_context)
            # Replace the normal owner field with a more permissive vocab.
            self.form_fields = self.form_fields.omit('owner')
            self.form_fields = any_owner_field + self.form_fields
Beispiel #18
0
class IProductView(
    ICanGetMilestonesDirectly, IHasAppointedDriver, IHasBranches,
    IHasExternalBugTracker,
    IHasMergeProposals, IHasMilestones, IHasExpirableBugs,
    IHasMugshot, IHasSprints, IHasTranslationImports,
    ITranslationPolicy, IKarmaContext, IMakesAnnouncements,
    IOfficialBugTagTargetPublic, IHasOOPSReferences,
    IHasRecipes, IHasCodeImports, IServiceUsage, IHasGitRepositories):
    """Public IProduct properties."""

    registrant = exported(
        PublicPersonChoice(
            title=_('Registrant'),
            required=True,
            readonly=True,
            vocabulary='ValidPersonOrTeam',
            description=_("This person registered the project in "
                          "Launchpad.")))

    driver = exported(
        PersonChoice(
            title=_("Driver"),
            description=_(
                "This person or team will be able to set feature goals for "
                "and approve bug targeting or backporting for ANY major "
                "series in this project. You might want to leave this blank "
                "and just appoint a team for each specific series, rather "
                "than having one project team that does it all."),
            required=False, vocabulary='ValidPersonOrTeam'))

    summary = exported(
        Summary(
            title=_('Summary'),
            description=_(
                "A short paragraph to introduce the project's work.")))

    description = exported(
        Description(
            title=_('Description'),
            required=False,
            description=_(
                "Details about the project's work, highlights, goals, and "
                "how to contribute. Use plain text, paragraphs are preserved "
                "and URLs are linked in pages. Don't repeat the Summary.")))

    datecreated = exported(
        Datetime(
            title=_('Date Created'),
            required=True, readonly=True,
            description=_("The date this project was created in Launchpad.")),
        exported_as='date_created')

    homepageurl = exported(
        URIField(
            title=_('Homepage URL'),
            required=False,
            allowed_schemes=['http', 'https', 'ftp'], allow_userinfo=False,
            description=_("""The project home page. Please include
                the http://""")),
        exported_as="homepage_url")

    wikiurl = exported(
        URIField(
            title=_('Wiki URL'),
            required=False,
            allowed_schemes=['http', 'https', 'ftp'], allow_userinfo=False,
            description=_("""The full URL of this project's wiki, if it has
                one. Please include the http://""")),
        exported_as='wiki_url')

    screenshotsurl = exported(
        URIField(
            title=_('Screenshots URL'),
            required=False,
            allowed_schemes=['http', 'https', 'ftp'], allow_userinfo=False,
            description=_("""The full URL for screenshots of this project,
                if available. Please include the http://""")),
        exported_as='screenshots_url')

    downloadurl = exported(
        URIField(
            title=_('Download URL'),
            required=False,
            allowed_schemes=['http', 'https', 'ftp'], allow_userinfo=False,
            description=_("""The full URL where downloads for this project
                are located, if available. Please include the http://""")),
        exported_as='download_url')

    programminglang = exported(
        TextLine(
            title=_('Programming Languages'),
            required=False,
            description=_("""A comma delimited list of programming
                languages used for this project.""")),
        exported_as='programming_language')

    sourceforgeproject = exported(
        TextLine(
            title=_('Sourceforge Project'),
            required=False,
            constraint=sourceforge_project_name_validator,
            description=_("""The SourceForge project name for
                this project, if it is in sourceforge.""")),
        exported_as='sourceforge_project')

    freshmeatproject = exported(
        TextLine(
            title=_('Freshmeat Project'),
            required=False, description=_("""The Freshmeat project name for
                this project, if it is in freshmeat. [DEPRECATED]""")),
        exported_as='freshmeat_project')

    homepage_content = Text(
        title=_("Homepage Content"), required=False,
        description=_(
            "The content of this project's home page. Edit this and it will "
            "be displayed for all the world to see. It is NOT a wiki "
            "so you cannot undo changes."))

    mugshot = exported(
        MugshotImageUpload(
            title=_("Brand"), required=False,
            default_image_resource='/@@/product-mugshot',
            description=_(
                "A large image of exactly 192x192 pixels, that will be "
                "displayed on this project's home page in Launchpad. It "
                "should be no bigger than 100kb in size.")),
        exported_as='brand')

    autoupdate = Bool(
        title=_('Automatic update'),
        description=_("Whether or not this project's attributes are "
                      "updated automatically."))

    private_bugs = exported(
        Bool(
            title=_('Private bugs (obsolete; always False)'), readonly=True,
            description=_("Replaced by bug_sharing_policy.")),
        ('devel', dict(exported=False)))

    branch_sharing_policy = exported(Choice(
        title=_('Branch sharing policy'),
        description=_("Sharing policy for this project's branches."),
        required=True, readonly=True, vocabulary=BranchSharingPolicy),
        as_of='devel')
    bug_sharing_policy = exported(Choice(
        title=_('Bug sharing policy'),
        description=_("Sharing policy for this project's bugs."),
        required=True, readonly=True, vocabulary=BugSharingPolicy),
        as_of='devel')
    specification_sharing_policy = exported(Choice(
        title=_('Blueprint sharing policy'),
        description=_("Sharing policy for this project's specifications."),
        required=True, readonly=True, vocabulary=SpecificationSharingPolicy),
        as_of='devel')

    licenses = exported(
        Set(title=_('Licences'),
            value_type=Choice(vocabulary=License)))

    license_info = exported(
        Description(
            title=_('Description of additional licences'),
            required=False,
            description=_(
                "Description of licences that do not appear in the list "
                "above.")))

    bugtracker = exported(
        ProductBugTracker(
            title=_('Bugs are tracked'),
            vocabulary="BugTracker"),
        exported_as='bug_tracker')

    sourcepackages = Attribute(_("List of packages for this product"))

    date_next_suggest_packaging = exported(
        Datetime(
            title=_('Next suggest packaging date'),
            description=_(
                "Obsolete. The date to resume Ubuntu package suggestions."),
            required=False),
        ('devel', dict(exported=False)))

    distrosourcepackages = Attribute(_("List of distribution packages for "
        "this product"))

    ubuntu_packages = Attribute(
        _("List of distribution packages for this product in Ubuntu"))

    series = exported(
        doNotSnapshot(
            CollectionField(value_type=Object(schema=IProductSeries))))

    development_focus = exported(
        ReferenceChoice(
            title=_('Development focus'), required=True,
            vocabulary='FilteredProductSeries',
            schema=IProductSeries,
            description=_(
                'The series that represents the master or trunk branch. '
                'The Bazaar URL lp:<project> points to the development focus '
                'series branch.')))
    development_focusID = Attribute("The development focus ID.")

    releases = exported(
        doNotSnapshot(
            CollectionField(
                title=_("An iterator over the ProductReleases for "
                        "this product."),
                readonly=True,
                value_type=Reference(schema=IProductRelease))))

    translation_focus = exported(
        ReferenceChoice(
            title=_("Translation focus"), required=False,
            vocabulary='FilteredProductSeries',
            schema=IProductSeries,
            description=_(
                'Project series that translators should focus on.')))

    translatable_packages = Attribute(
        "A list of the source packages for this product that can be "
        "translated sorted by distroseries.name and sourcepackage.name.")

    translatable_series = Attribute(
        "A list of the series of this product for which we have translation "
        "templates.")

    obsolete_translatable_series = Attribute("""
        A list of the series of this product with obsolete translation
        templates.""")

    primary_translatable = Attribute(
        "The best guess we have for what new translators will want to "
        "translate for a given product: the latest series for which we have "
        "templates, and failing that, an Ubuntu package.")

    translationgroups = Attribute("The list of applicable translation "
        "groups for a product. There can be several: one from the product, "
        "and potentially one from the project, too.")

    commercial_subscription = exported(
        Reference(
            ICommercialSubscription,
            title=_("Commercial subscriptions"),
            description=_(
                "An object which contains the timeframe and the voucher "
                "code of a subscription.")))

    commercial_subscription_is_due = exported(
            Bool(
                title=_("Commercial subscription is due"),
                readonly=True,
                description=_(
                    "Whether the project's licensing requires a new "
                    "commercial subscription to use launchpad.")))

    has_current_commercial_subscription = Attribute("""
        Whether the project has a current commercial subscription.""")

    license_status = Attribute("""
        Whether the licence is OPENSOURCE, UNREVIEWED, or PROPRIETARY.""")

    remote_product = exported(
        TextLine(
            title=_('Remote bug tracker project id'), required=False,
            description=_(
                "Some bug trackers host multiple projects at the same URL "
                "and require an identifier for the specific project.")))

    active_or_packaged_series = Attribute(
        _("Series that are active and/or have been packaged."))

    packagings = Attribute(_("All the packagings for the project."))

    security_contact = exported(
        TextLine(
            title=_('Security contact'), required=False, readonly=True,
            description=_('Security contact (obsolete; always None)')),
            ('devel', dict(exported=False)), as_of='1.0')

    vcs = exported(
        Choice(
            title=_("VCS"),
            required=False,
            vocabulary=VCSType,
            description=_(
                "Version control system for this project's code.")))

    inferred_vcs = Choice(
        title=_("Inferred VCS"),
        readonly=True,
        vocabulary=VCSType,
        description=_(
            "Inferred version control system for this project's code."))

    def getAllowedBugInformationTypes():
        """Get the information types that a bug in this project can have.

        :return: A sequence of `InformationType`s.
        """

    def getDefaultBugInformationType():
        """Get the default information type of a new bug in this project.

        :return: The `InformationType`.
        """

    def getVersionSortedSeries(statuses=None, filter_statuses=None):
        """Return all the series sorted by the name field as a version.

        The development focus field is an exception. It will always
        be sorted first.

        :param statuses: If statuses is not None, only include series
                         which are in the given statuses.
        :param filter_statuses: Filter out any series with statuses listed in
                                filter_statuses.
        """

    def redeemSubscriptionVoucher(voucher, registrant, purchaser,
                                  subscription_months, whiteboard=None,
                                  current_datetime=None):
        """Redeem a voucher and extend the subscription expiration date.

        The voucher must have already been verified to be redeemable.
        :param voucher: The voucher id as tracked in the external system.
        :param registrant: Who is redeeming the voucher.
        :param purchaser: Who purchased the voucher.  May not be known.
        :param subscription_months: integer indicating the number of months
            the voucher is for.
        :param whiteboard: Notes for this activity.
        :param current_datetime: Current time.  Will be datetime.now() if not
            specified.
        :return: None
        """

    def getPackage(distroseries):
        """Return a package in that distroseries for this product."""

    @operation_parameters(
        name=TextLine(title=_("Name"), required=True))
    @operation_returns_entry(IProductSeries)
    @export_read_operation()
    def getSeries(name):
        """Return the series for this product for the given name, or None."""

    @operation_parameters(
        version=TextLine(title=_("Version"), required=True))
    @operation_returns_entry(IProductRelease)
    @export_read_operation()
    def getRelease(version):
        """Return the release for this product that has the version given."""

    def getMilestonesAndReleases():
        """Return all the milestones and releases for this product."""

    def packagedInDistros():
        """Returns the distributions this product has been packaged in."""

    def userCanEdit(user):
        """Can the user edit this product?"""

    def getLinkedBugWatches():
        """Return all the bug watches that are linked to this Product.

        Being linked, means that a bug watch having the same bug tracker
        as this Product is using, is linked to a bug task targeted to
        this Product.
        """

    @operation_parameters(
        include_inactive=Bool(title=_("Include inactive"),
                              required=False, default=False))
    @export_read_operation()
    @export_operation_as('get_timeline')
    def getTimeline(include_inactive):
        """Return basic timeline data useful for creating a diagram.
Beispiel #19
0
class IProductLimitedView(IHasIcon, IHasLogo, IHasOwner, ILaunchpadUsage):
    """Attributes that must be visible for person with artifact grants
    on bugs, branches or specifications for the product.
    """

    display_name = exported(
        TextLine(
            title=_('Display Name'),
            description=_("""The name of the project as it would appear in a
                paragraph.""")),
        exported_as='display_name')

    displayname = Attribute('Display name (deprecated)')

    icon = exported(
        IconImageUpload(
            title=_("Icon"), required=False,
            default_image_resource='/@@/product',
            description=_(
                "A small image of exactly 14x14 pixels and at most 5kb in "
                "size, that can be used to identify this project. The icon "
                "will be displayed next to the project name everywhere in "
                "Launchpad that we refer to the project and link to it.")))

    logo = exported(
        LogoImageUpload(
            title=_("Logo"), required=False,
            default_image_resource='/@@/product-logo',
            description=_(
                "An image of exactly 64x64 pixels that will be displayed in "
                "the heading of all pages related to this project. It should "
                "be no bigger than 50kb in size.")))

    name = exported(
        ProductNameField(
            title=_('Name'),
            constraint=name_validator,
            description=_(
                "At least one lowercase letter or number, followed by "
                "letters, numbers, dots, hyphens or pluses. "
                "Keep this name short; it is used in URLs as shown above.")))

    owner = exported(
        PersonChoice(
            title=_('Maintainer'),
            required=True,
            vocabulary='ValidPillarOwner',
            description=_("The restricted team, moderated team, or person "
                          "who maintains the project information in "
                          "Launchpad.")))
    projectgroup = exported(
        ReferenceChoice(
            title=_('Part of'),
            required=False,
            vocabulary='ProjectGroup',
            schema=IProjectGroup,
            description=_(
                'Project group. This is an overarching initiative that '
                'includes several related projects. For example, the Mozilla '
                'Project produces Firefox, Thunderbird and Gecko. This '
                'information is used to group those projects in a coherent '
                'way. If you make this project part of a group, the group '
                'preferences and decisions around bug tracking, translation '
                'and security policy will apply to this project.')),
        exported_as='project_group')

    title = exported(
        Title(
            title=_('Title'),
            description=_("The project title. Should be just a few words."),
            readonly=True))
class IArchiveSubscriberView(Interface):
    """An interface for launchpad.View ops on archive subscribers."""

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

    archive_id = Int(title=_('Archive ID'), required=True, readonly=True)
    archive = exported(
        Reference(IArchive,
                  title=_("Archive"),
                  required=True,
                  readonly=True,
                  description=_("The archive for this subscription.")))

    registrant = exported(
        Reference(
            IPerson,
            title=_("Registrant"),
            required=True,
            readonly=True,
            description=_("The person who registered this subscription.")))

    date_created = exported(
        Datetime(
            title=_("Date Created"),
            required=True,
            readonly=True,
            description=_("The timestamp when the subscription was created.")))

    subscriber = exported(
        PersonChoice(title=_("Subscriber"),
                     required=True,
                     readonly=True,
                     vocabulary='ValidPersonOrTeam',
                     description=_("The person who is subscribed.")))
    subscriber_id = Attribute('database ID of the subscriber.')

    date_expires = exported(
        Datetime(
            title=_("Date of Expiration"),
            required=False,
            description=_("The timestamp when the subscription will expire.")))

    status = exported(
        Choice(title=_("Status"),
               required=True,
               vocabulary=ArchiveSubscriberStatus,
               description=_("The status of this subscription.")))

    description = exported(
        Text(title=_("Description"),
             required=False,
             description=_("Free text describing this subscription.")))

    date_cancelled = Datetime(
        title=_("Date of Cancellation"),
        required=False,
        description=_("The timestamp when the subscription was cancelled."))

    cancelled_by = Reference(
        IPerson,
        title=_("Cancelled By"),
        required=False,
        description=_("The person who cancelled the subscription."))

    displayname = TextLine(title=_("Subscription displayname"), required=False)

    def getNonActiveSubscribers():
        """Return the people included in this subscription.
class IProductSeriesView(ISeriesMixin, IHasAppointedDriver, IHasOwner,
                         ISpecificationGoal, IHasMilestones,
                         IHasOfficialBugTags, IHasExpirableBugs,
                         IHasTranslationImports, IHasTranslationTemplates,
                         IServiceUsage):
    status = exported(
        Choice(title=_('Status'),
               required=True,
               vocabulary=SeriesStatus,
               default=SeriesStatus.DEVELOPMENT))

    parent = Attribute('The structural parent of this series - the product')

    datecreated = exported(Datetime(title=_('Date Registered'),
                                    required=True,
                                    readonly=True),
                           exported_as='date_created')

    owner = exported(
        PersonChoice(
            title=_('Owner'),
            required=True,
            vocabulary='ValidOwner',
            description=_('Project owner, either a valid Person or Team')))

    driver = exported(
        PersonChoice(
            title=_("Release manager"),
            description=_(
                "The person or team responsible for decisions about features "
                "and bugs that will be targeted to this series. If you don't "
                "nominate someone here, then the owner of this series will "
                "automatically have those permissions, as will the project "
                "and project group drivers."),
            required=False,
            vocabulary='ValidPersonOrTeam'))

    title = exported(
        Title(title=_('Title'),
              description=_("The product series title.  "
                            "Should be just a few words.")))

    displayname = exported(TextLine(
        title=_('Display Name'),
        description=_(
            "Display name.  In this case we have removed the underlying "
            "database field, and this attribute just returns the name.")),
                           exported_as='display_name')

    releases = exported(
        CollectionField(title=_("An iterator over the releases in this "
                                "Series, sorted with latest release first."),
                        readonly=True,
                        value_type=Reference(schema=IProductRelease)))

    release_files = Attribute("An iterator over the release files in this "
                              "Series, sorted with latest release first.")

    packagings = Attribute("An iterator over the Packaging entries "
                           "for this product series.")

    specifications = Attribute("The specifications targeted to this "
                               "product series.")

    sourcepackages = Attribute(
        _("List of distribution packages for this "
          "product series"))

    milestones = exported(doNotSnapshot(
        CollectionField(title=_("The visible milestones associated with this "
                                "project series, ordered by date expected."),
                        readonly=True,
                        value_type=Reference(schema=IMilestone))),
                          exported_as='active_milestones')

    all_milestones = exported(
        doNotSnapshot(
            CollectionField(title=_(
                "All milestones associated with this project series, "
                "ordered by date expected."),
                            readonly=True,
                            value_type=Reference(schema=IMilestone))))

    branch = exported(
        ReferenceChoice(title=_('Branch'),
                        vocabulary='BranchRestrictedOnProduct',
                        schema=IBranch,
                        required=False,
                        description=_(
                            "The Bazaar branch for this series.  Leave blank "
                            "if this series is not maintained in Bazaar.")))

    translations_autoimport_mode = exported(Choice(
        title=_('Import settings'),
        vocabulary=TranslationsBranchImportMode,
        required=True,
        description=_("Specify which files will be imported from the "
                      "source code branch.")),
                                            as_of="devel")

    potemplate_count = Int(
        title=_("The total number of POTemplates in this series."),
        readonly=True,
        required=True)

    productserieslanguages = Attribute(
        "The set of ProductSeriesLanguages for this series.")

    translations_branch = ReferenceChoice(
        title=_("Translations export branch"),
        vocabulary='HostedBranchRestrictedOnOwner',
        schema=IBranch,
        required=False,
        description=_("A Bazaar branch to commit translation snapshots to.  "
                      "Leave blank to disable."))

    all_specifications = doNotSnapshot(
        Attribute('All specifications linked to this series.'))

    def getCachedReleases():
        """Gets a cached copy of this series' releases.

        Returns None if there is no release."""

    def getLatestRelease():
        """Gets the most recent release in the series.

        Returns None if there is no release."""

    def getRelease(version):
        """Get the release in this series that has the specified version.
        Return None is there is no such release.
        """

    def getPackage(distroseries):
        """Return the SourcePackage for this project series in the supplied
        distroseries. This will use a Packaging record if one exists, but
        it will also work through the ancestry of the distroseries to try
        to find a Packaging entry that may be relevant."""

    def getUbuntuTranslationFocusPackage():
        """Return the SourcePackage that packages this project in Ubuntu's
        translation focus or current series or any series, in that order."""

    def setPackaging(distroseries, sourcepackagename, owner):
        """Create or update a Packaging record for this product series,
        connecting it to the given distroseries and source package name.
        """

    def getPackagingInDistribution(distribution):
        """Return all the Packaging entries for this product series for the
        given distribution. Note that this only returns EXPLICT packaging
        entries, it does not look at distro series ancestry in the same way
        that IProductSeries.getPackage() does.
        """

    def getPOTemplate(name):
        """Return the POTemplate with this name for the series."""

    # where are the tarballs released from this branch placed?
    releasefileglob = exported(TextLine(
        title=_("Release URL pattern"),
        required=False,
        constraint=validate_release_glob,
        description=_('A URL pattern that matches releases that are part '
                      'of this series.  Launchpad automatically scans this '
                      'site to import new releases.  Example: '
                      'http://ftp.gnu.org/gnu/emacs/emacs-21.*.tar.gz')),
                               exported_as='release_finder_url_pattern')

    releaseverstyle = Attribute("The version numbering style for this "
                                "series of releases.")

    is_development_focus = Attribute(
        _("Is this series the development focus for the product?"))

    @operation_parameters(include_inactive=Bool(title=_("Include inactive"),
                                                required=False,
                                                default=False))
    @export_read_operation()
    @export_operation_as('get_timeline')
    def getTimeline(include_inactive):
        """Return basic timeline data useful for creating a diagram.
Beispiel #22
0
class ISnapEditableAttributes(IHasOwner):
    """`ISnap` attributes that can be edited.

    These attributes need launchpad.View to see, and launchpad.Edit to change.
    """
    date_last_modified = exported(Datetime(
        title=_("Date last modified"), required=True, readonly=True))

    owner = exported(PersonChoice(
        title=_("Owner"), required=True, readonly=False,
        vocabulary="AllUserTeamsParticipationPlusSelf",
        description=_("The owner of this snap package.")))

    distro_series = exported(Reference(
        IDistroSeries, title=_("Distro Series"),
        required=False, readonly=False,
        description=_(
            "The series for which the snap package should be built.  If not "
            "set, Launchpad will infer an appropriate series from "
            "snapcraft.yaml.")))

    name = exported(TextLine(
        title=_("Name"), required=True, readonly=False,
        constraint=name_validator,
        description=_("The name of the snap package.")))

    description = exported(Text(
        title=_("Description"), required=False, readonly=False,
        description=_("A description of the snap package.")))

    branch = exported(ReferenceChoice(
        title=_("Bazaar branch"), schema=IBranch, vocabulary="Branch",
        required=False, readonly=False,
        description=_(
            "A Bazaar branch containing a snap/snapcraft.yaml, "
            "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
            ".snapcraft.yaml recipe at the top level.")))

    git_repository = exported(ReferenceChoice(
        title=_("Git repository"),
        schema=IGitRepository, vocabulary="GitRepository",
        required=False, readonly=True,
        description=_(
            "A Git repository with a branch containing a snap/snapcraft.yaml, "
            "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
            ".snapcraft.yaml recipe at the top level.")))

    git_repository_url = exported(URIField(
        title=_("Git repository URL"), required=False, readonly=True,
        description=_(
            "The URL of a Git repository with a branch containing a "
            "snap/snapcraft.yaml, build-aux/snap/snapcraft.yaml, "
            "snapcraft.yaml, or .snapcraft.yaml recipe at the top level."),
        allowed_schemes=["git", "http", "https"],
        allow_userinfo=True,
        allow_port=True,
        allow_query=False,
        allow_fragment=False,
        trailing_slash=False))

    git_path = TextLine(
        title=_("Git branch path"), required=False, readonly=False,
        description=_(
            "The path of the Git branch containing a snap/snapcraft.yaml, "
            "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
            ".snapcraft.yaml recipe at the top level."))
    _api_git_path = exported(
        TextLine(
            title=git_path.title, required=False, readonly=False,
            description=git_path.description),
        exported_as="git_path")

    git_ref = exported(Reference(
        IGitRef, title=_("Git branch"), required=False, readonly=False,
        description=_(
            "The Git branch containing a snap/snapcraft.yaml, "
            "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
            ".snapcraft.yaml recipe at the top level.")))

    build_source_tarball = exported(Bool(
        title=_("Build source tarball"),
        required=True, readonly=False,
        description=_(
            "Whether builds of this snap package should also build a tarball "
            "containing all source code, including external dependencies.")))

    auto_build = exported(Bool(
        title=_("Automatically build when branch changes"),
        required=True, readonly=False,
        description=_(
            "Whether this snap package is built automatically when the branch "
            "containing its snap/snapcraft.yaml, "
            "build-aux/snap/snapcraft.yaml, snapcraft.yaml, or "
            ".snapcraft.yaml recipe changes.")))

    auto_build_archive = exported(Reference(
        IArchive, title=_("Source archive for automatic builds"),
        required=False, readonly=False,
        description=_(
            "The archive from which automatic builds of this snap package "
            "should be built.")))

    auto_build_pocket = exported(Choice(
        title=_("Pocket for automatic builds"),
        vocabulary=PackagePublishingPocket, required=False, readonly=False,
        description=_(
            "The package stream within the source distribution series to use "
            "when building the snap package.")))

    auto_build_channels = exported(Dict(
        title=_("Source snap channels for automatic builds"),
        key_type=TextLine(), required=False, readonly=False,
        description=_(
            "A dictionary mapping snap names to channels to use when building "
            "this snap package.  Currently only 'core' and 'snapcraft' keys "
            "are supported.")))

    is_stale = Bool(
        title=_("Snap package is stale and is due to be rebuilt."),
        required=True, readonly=False)

    store_upload = exported(Bool(
        title=_("Automatically upload to store"),
        required=True, readonly=False,
        description=_(
            "Whether builds of this snap package are automatically uploaded "
            "to the store.")))

    # XXX cjwatson 2016-12-08: We should limit this to series that are
    # compatible with distro_series, but that entails validating the case
    # where both are changed in a single PATCH request in such a way that
    # neither is compatible with the old value of the other.  As far as I
    # can tell lazr.restful only supports per-field validation.
    store_series = exported(ReferenceChoice(
        title=_("Store series"),
        schema=ISnappySeries, vocabulary="SnappySeries",
        required=False, readonly=False,
        description=_(
            "The series in which this snap package should be published in the "
            "store.")))

    store_distro_series = ReferenceChoice(
        title=_("Store and distro series"),
        schema=ISnappyDistroSeries, vocabulary="SnappyDistroSeries",
        required=False, readonly=False)

    store_name = exported(TextLine(
        title=_("Registered store package name"),
        required=False, readonly=False,
        description=_(
            "The registered name of this snap package in the store.")))

    store_secrets = List(
        value_type=TextLine(), title=_("Store upload tokens"),
        required=False, readonly=False,
        description=_(
            "Serialized secrets issued by the store and the login service to "
            "authorize uploads of this snap package."))

    store_channels = exported(List(
        title=_("Store channels"),
        required=False, readonly=False, constraint=channels_validator,
        description=_(
            "Channels to release this snap package to after uploading it to "
            "the store. A channel is defined by a combination of an optional "
            " track, a risk, and an optional branch, e.g. "
            "'2.1/stable/fix-123', '2.1/stable', 'stable/fix-123', or "
            "'stable'.")))
Beispiel #23
0
class IBuilderView(IHasBuildRecords, IHasOwner):

    id = Attribute("Builder identifier")

    processor = exported(ReferenceChoice(
        title=_('Processor'),
        required=True,
        vocabulary='Processor',
        schema=IProcessor,
        description=_(
            'DEPRECATED: Processor identifying jobs which can be built by '
            'this device. Use `processors` instead to handle multiple '
            'supported architectures.')),
                         as_of='devel')

    processors = exported(List(
        title=_("Processors"),
        description=_("Processors identifying jobs which can be built by this "
                      "device."),
        value_type=ReferenceChoice(vocabulary='Processor', schema=IProcessor)),
                          as_of='devel')

    owner = exported(
        PersonChoice(title=_('Owner'),
                     required=True,
                     vocabulary='ValidOwner',
                     description=_('Builder owner, a Launchpad member which '
                                   'will be responsible for this device.')))

    url = exported(
        TextLine(title=_('URL'),
                 required=True,
                 constraint=builder_url_validator,
                 description=_(
                     'The URL to the build machine, used as a unique '
                     'identifier. Includes protocol, host and port only, '
                     'e.g.: http://farm.com:8221/')))

    name = exported(
        TextLine(
            title=_('Name'),
            required=True,
            constraint=name_validator,
            description=_('Builder Slave Name used for reference purposes')))

    title = exported(
        Title(title=_('Title'),
              required=True,
              description=_(
                  'The builder slave title. Should be just a few words.')))

    virtualized = exported(
        Bool(title=_('Virtualized'),
             required=True,
             default=False,
             description=_('Whether or not the builder is a virtual Xen '
                           'instance.')))

    manual = exported(
        Bool(title=_('Manual Mode'),
             required=False,
             default=False,
             description=_('The auto-build system does not dispatch '
                           'jobs automatically for slaves in manual mode.')))

    builderok = exported(
        Bool(title=_('Builder State OK'),
             required=True,
             default=True,
             description=_('Whether or not the builder is ok')))

    failnotes = exported(
        Text(title=_('Failure Notes'),
             required=False,
             description=_('The reason for a builder not being ok')))

    vm_host = exported(
        TextLine(title=_('VM host'),
                 required=False,
                 description=_('The machine hostname hosting the virtual '
                               'buildd-slave, e.g.: foobar-host.ppa')))

    vm_reset_protocol = exported(
        Choice(title=_("VM reset protocol"),
               vocabulary=BuilderResetProtocol,
               readonly=False,
               required=False,
               description=_("The protocol version for resetting the VM.")))

    active = exported(
        Bool(title=_('Publicly Visible'),
             required=False,
             default=True,
             description=_('Whether or not to present the builder publicly.')))

    currentjob = Attribute("BuildQueue instance for job being processed.")

    current_build = exported(
        Reference(
            title=_("Current build"),
            required=False,
            readonly=True,
            schema=Interface,  # Really IBuildFarmJob.
            description=_("The job currently running on this builder.")),
        as_of="devel")

    failure_count = exported(
        Int(title=_('Failure Count'),
            required=False,
            default=0,
            description=_("Number of consecutive failures for this builder.")))

    version = exported(
        Text(title=_('Version'),
             required=False,
             description=_('The version of launchpad-buildd on the slave.')))

    clean_status = exported(
        Choice(
            title=_("Clean status"),
            vocabulary=BuilderCleanStatus,
            readonly=True,
            description=_(
                "The readiness of the slave to take a job. Only internal build "
                "infrastructure bots need to or should write to this.")))

    date_clean_status_changed = exported(
        Datetime(title=_("Date clean status changed"),
                 readonly=True,
                 description=_(
                     "The date the builder's clean status last changed.")))

    def gotFailure():
        """Increment failure_count on the builder."""

    def resetFailureCount():
        """Set the failure_count back to zero."""

    def failBuilder(reason):
        """Mark builder as failed for a given reason."""

    def acquireBuildCandidate():
        """Acquire a build candidate in an atomic fashion.
Beispiel #24
0
class ITranslationImportQueueEntry(Interface):
    """An entry of the Translation Import Queue."""
    export_as_webservice_entry(
        singular_name='translation_import_queue_entry',
        plural_name='translation_import_queue_entries')

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

    path = exported(
        TextLine(
            title=_("Path"),
            description=_(
                "The path to this file inside the source tree. Includes the"
                " filename."),
            required=True))

    importer = exported(
        PersonChoice(
            title=_("Uploader"),
            required=True,
            readonly=True,
            description=_(
                "The person that uploaded this file to Launchpad."),
            vocabulary="ValidOwner"),
        exported_as="uploader")

    dateimported = exported(
        Datetime(
            title=_("The timestamp when this queue entry was created."),
            required=True,
            readonly=True),
        exported_as="date_created")

    productseries = exported(
        Reference(
            title=_("Series"),
            required=False,
            readonly=True,
            schema=IProductSeries))

    distroseries = exported(
        Reference(
            title=_("Series"),
            required=False,
            readonly=True,
            schema=IDistroSeries))

    sourcepackagename = Choice(
        title=_("Source Package Name"),
        description=_(
            "The source package from where this entry comes."),
        required=False,
        vocabulary="SourcePackageName")

    by_maintainer = Bool(
        title=_(
            "This upload was done by the maintainer "
            "of the project or package."),
        description=_(
            "If checked, the translations in this import will be marked "
            "as is_current_upstream."),
        required=True,
        default=False)

    content = Attribute(
        "An ILibraryFileAlias reference with the file content. Must not be"
        " None.")

    format = exported(
        Choice(
            title=_('The file format of the import.'),
            vocabulary=TranslationFileFormat,
            required=True,
            readonly=True))

    status = exported(
        Choice(
            title=_("The status of the import."),
            vocabulary=RosettaImportStatus,
            required=True,
            readonly=True))

    date_status_changed = exported(
        Datetime(
            title=_("The timestamp when the status was changed."),
            required=True))

    is_targeted_to_ubuntu = Attribute(
        "True if this entry is to be imported into the Ubuntu distribution.")

    sourcepackage = exported(
        Reference(
            schema=ISourcePackage,
            title=_("The sourcepackage associated with this entry."),
            readonly=True))

    guessed_potemplate = Attribute(
        "The IPOTemplate that we can guess this entry could be imported into."
        " None if we cannot guess it.")

    import_into = Attribute("The Object where this entry will be imported. Is"
        " None if we don't know where to import it.")

    pofile = Field(
        title=_("The IPOfile where this entry should be imported."),
        required=False)

    potemplate = Field(
        title=_("The IPOTemplate associated with this entry."),
        description=_("The IPOTemplate associated with this entry. If path"
        " notes a .pot file, it should be used as the place where this entry"
        " will be imported, if it's a .po file, it indicates the template"
        " associated with tha translation."),
        required=False)

    error_output = exported(
        Text(
            title=_("Error output"),
            description=_("Output from most recent import attempt."),
            required=False,
            readonly=True))

    def canAdmin(roles):
        """Check if the user can administer this entry."""

    def canEdit(roles):
        """Check if the user can edit this entry."""

    def canSetStatus(new_status, user):
        """Check if the user can set this new status."""

    @call_with(user=REQUEST_USER)
    @operation_parameters(new_status=copy_field(status))
    @export_write_operation()
    def setStatus(new_status, user):
        """Transition to a new status if possible.

        :param new_status: Status to transition to.
        :param user: The user that is doing the transition.
        """

    def setErrorOutput(output):
        """Set `error_output` string."""

    def addWarningOutput(output):
        """Optionally add warning output to `error_output`.

        This may not do everything you expect of it.  Read the code if
        you need certainty.
        """

    def getGuessedPOFile():
        """Return an IPOFile that we think this entry should be imported into.

        Return None if we cannot guess it."""

    def getFileContent():
        """Return the imported file content as a stream."""

    def getTemplatesOnSameDirectory():
        """Return import queue entries stored on the same directory as self.

        The returned entries will be only .pot entries.
        """

    def getElapsedTimeText():
        """Return a string representing elapsed time since we got the file.
Beispiel #25
0
class IBranchSubscription(Interface):
    """The relationship between a person and a branch."""
    export_as_webservice_entry()

    id = Int(title=_('ID'), readonly=True, required=True)
    personID = Int(title=_('Person ID'), required=True, readonly=True)
    person = exported(
        PersonChoice(
            title=_('Person'),
            required=True,
            vocabulary='ValidPersonOrTeam',
            readonly=True,
            description=_(
                'Enter the launchpad id, or email '
                'address of the person you wish to subscribe to this branch. '
                'If you are unsure, use the "Choose..." option to find the '
                'person in Launchpad. You can only subscribe someone who is '
                'a registered user of the system.')))
    branch = exported(
        Reference(title=_('Branch ID'),
                  required=True,
                  readonly=True,
                  schema=IBranch))
    notification_level = exported(
        Choice(
            title=_('Notification Level'),
            required=True,
            vocabulary=BranchSubscriptionNotificationLevel,
            default=BranchSubscriptionNotificationLevel.ATTRIBUTEONLY,
            description=_(
                'Attribute notifications are sent when branch details are '
                'changed such as lifecycle status and name.  Revision '
                'notifications are generated when new branch revisions are '
                'found due to the branch being updated through either pushes '
                'to the hosted branches or the mirrored branches being '
                'updated.')))
    max_diff_lines = exported(
        Choice(
            title=_('Generated Diff Size Limit'),
            required=True,
            vocabulary=BranchSubscriptionDiffSize,
            default=BranchSubscriptionDiffSize.ONEKLINES,
            description=_(
                'Diffs greater than the specified number of lines will not '
                'be sent to the subscriber.  The subscriber will still '
                'receive an email with the new revision details even if the '
                'diff is larger than the specified number of lines.')))
    review_level = exported(
        Choice(title=_('Code review Level'),
               required=True,
               vocabulary=CodeReviewNotificationLevel,
               default=CodeReviewNotificationLevel.FULL,
               description=_(
                   'Control the kind of review activity that triggers '
                   'notifications.')))

    subscribed_by = exported(
        PersonChoice(
            title=_('Subscribed by'),
            required=True,
            vocabulary='ValidPersonOrTeam',
            readonly=True,
            description=_("The person who created this subscription.")))

    @call_with(user=REQUEST_USER)
    @export_read_operation()
    def canBeUnsubscribedByUser(user):
        """Can the user unsubscribe the subscriber from the branch?"""
Beispiel #26
0
class IBugTask(IHasDateCreated, IHasBug, IBugTaskDelete):
    """A bug needing fixing in a particular product or package."""
    export_as_webservice_entry()

    id = Int(title=_("Bug Task #"))
    bug = exported(
        BugField(title=_("Bug"), readonly=True))
    product = Choice(
        title=_('Project'), required=False, vocabulary='Product')
    productID = Attribute('The product ID')
    productseries = Choice(
        title=_('Series'), required=False, vocabulary='ProductSeries')
    productseriesID = Attribute('The product series ID')
    sourcepackagename = Choice(
        title=_("Package"), required=False,
        vocabulary='SourcePackageName')
    sourcepackagenameID = Attribute('The sourcepackagename ID')
    distribution = Choice(
        title=_("Distribution"), required=False, vocabulary='Distribution')
    distributionID = Attribute('The distribution ID')
    distroseries = Choice(
        title=_("Series"), required=False,
        vocabulary='DistroSeries')
    distroseriesID = Attribute('The distroseries ID')
    milestone = exported(ReferenceChoice(
        title=_('Milestone'),
        required=False,
        readonly=True,
        vocabulary='BugTaskMilestone',
        schema=Interface))  # IMilestone
    milestoneID = Attribute('The id of the milestone.')

    # The status and importance's vocabularies do not
    # contain an UNKNOWN item in bugtasks that aren't linked to a remote
    # bugwatch; this would be better described in a separate interface,
    # but adding a marker interface during initialization is expensive,
    # and adding it post-initialization is not trivial.
    # Note that status is a property because the model only exposes INCOMPLETE
    # but the DB stores INCOMPLETE_WITH_RESPONSE and
    # INCOMPLETE_WITHOUT_RESPONSE for query efficiency.
    status = exported(
        Choice(title=_('Status'), vocabulary=BugTaskStatus,
               default=BugTaskStatus.NEW, readonly=True))
    _status = Attribute('The actual status DB column used in queries.')
    importance = exported(
        Choice(title=_('Importance'), vocabulary=BugTaskImportance,
               default=BugTaskImportance.UNDECIDED, readonly=True))
    assignee = exported(
        PersonChoice(
            title=_('Assigned to'), required=False,
            vocabulary='ValidAssignee',
            readonly=True))
    assigneeID = Int(title=_('The assignee ID (for eager loading)'))
    bugtargetdisplayname = exported(
        Text(title=_("The short, descriptive name of the target"),
             readonly=True),
        exported_as='bug_target_display_name')
    bugtargetname = exported(
        Text(title=_("The target as presented in mail notifications"),
             readonly=True),
        exported_as='bug_target_name')
    bugwatch = exported(
        ReferenceChoice(
            title=_("Remote Bug Details"), required=False,
            schema=IBugWatch,
            vocabulary='BugWatch', description=_(
                "Select the bug watch that "
                "represents this task in the relevant bug tracker. If none "
                "of the bug watches represents this particular bug task, "
                "leave it as (None). Linking the remote bug watch with the "
                "task in this way means that a change in the remote bug "
                "status will change the status of this bug task in "
                "Launchpad.")),
        exported_as='bug_watch')
    date_assigned = exported(
        Datetime(title=_("Date Assigned"),
                 description=_("The date on which this task was assigned "
                               "to someone."),
                 readonly=True,
                 required=False))
    datecreated = exported(
        Datetime(title=_("Date Created"),
                 description=_("The date on which this task was created."),
                 readonly=True),
        exported_as='date_created')
    date_confirmed = exported(
        Datetime(title=_("Date Confirmed"),
                 description=_("The date on which this task was marked "
                               "Confirmed."),
                 readonly=True,
                 required=False))
    date_incomplete = exported(
        Datetime(title=_("Date Incomplete"),
                 description=_("The date on which this task was marked "
                               "Incomplete."),
                 readonly=True,
                 required=False))
    date_inprogress = exported(
        Datetime(title=_("Date In Progress"),
                 description=_("The date on which this task was marked "
                               "In Progress."),
                 readonly=True,
                 required=False),
        exported_as='date_in_progress')
    date_closed = exported(
        Datetime(title=_("Date Closed"),
                 description=_("The date on which this task was marked "
                               "either Won't Fix, Invalid or Fix Released."),
                 readonly=True,
                 required=False))
    date_left_new = exported(
        Datetime(title=_("Date left new"),
                 description=_("The date on which this task was marked "
                               "with a status higher than New."),
                 readonly=True,
                 required=False))
    date_triaged = exported(
        Datetime(title=_("Date Triaged"),
                 description=_("The date on which this task was marked "
                               "Triaged."),
                 readonly=True,
                 required=False))
    date_fix_committed = exported(
        Datetime(title=_("Date Fix Committed"),
                 description=_("The date on which this task was marked "
                               "Fix Committed."),
                 readonly=True,
                 required=False))
    date_fix_released = exported(
        Datetime(title=_("Date Fix Released"),
                 description=_("The date on which this task was marked "
                               "Fix Released."),
                 readonly=True,
                 required=False))
    date_left_closed = exported(
        Datetime(title=_("Date left closed"),
                 description=_("The date on which this task was "
                               "last reopened."),
                 readonly=True,
                 required=False))
    age = Datetime(title=_("Age"),
                   description=_("The age of this task, expressed as the "
                                 "length of time between the creation date "
                                 "and now."))
    task_age = Int(title=_("Age of the bug task"),
            description=_("The age of this task in seconds, a delta between "
                         "now and the date the bug task was created."))
    owner = exported(
        Reference(title=_("The owner"), schema=Interface, readonly=True))
    target = exported(Reference(
        title=_('Target'), required=True, schema=Interface,  # IBugTarget
        readonly=True,
        description=_("The software in which this bug should be fixed.")))
    title = exported(
        Text(title=_("The title of the bug related to this bugtask"),
             readonly=True))
    related_tasks = exported(
        CollectionField(
            description=_(
                "IBugTasks related to this one, namely other "
                "IBugTasks on the same IBug."),
            value_type=Reference(schema=Interface),  # Will be specified later
            readonly=True))
    pillar = Choice(
        title=_('Pillar'),
        description=_("The LP pillar (product or distribution) "
                      "associated with this task."),
        vocabulary='DistributionOrProduct', readonly=True)
    other_affected_pillars = Attribute(
        "The other pillars (products or distributions) affected by this bug. "
        "This returns a list of pillars OTHER THAN the pillar associated "
        "with this particular bug.")
    # This property does various database queries. It is a property so a
    # "snapshot" of its value will be taken when a bugtask is modified, which
    # allows us to compare it to the current value and see if there are any
    # new subscribers that should get an email containing full bug details
    # (rather than just the standard change mail.) It is a property on
    # IBugTask because we currently only ever need this value for events
    # handled on IBugTask.
    bug_subscribers = Field(
        title=_("A list of IPersons subscribed to the bug, whether directly "
                "or indirectly."), readonly=True)

    conjoined_master = Attribute(
        "The series-specific bugtask in a conjoined relationship")
    conjoined_slave = Attribute(
        "The generic bugtask in a conjoined relationship")

    is_complete = exported(
        Bool(description=_(
                "True or False depending on whether or not there is more "
                "work required on this bug task."),
             readonly=True))

    @operation_returns_collection_of(Interface)  # Actually IBug.
    @call_with(user=REQUEST_USER, limit=10)
    @export_read_operation()
    def findSimilarBugs(user, limit=10):
        """Return the list of possible duplicates for this BugTask."""

    @call_with(user=REQUEST_USER)
    @operation_parameters(person=copy_field(assignee))
    @export_read_operation()
    @operation_for_version("devel")
    def getContributorInfo(user, person):
        """Is the person a contributor to bugs in this task's pillar?

        :param user: The user doing the search. Private bugs that this
            user doesn't have access to won't be included in the search.
        :param person: The person to check to see if they are a contributor.

        Return a dict with the following values:
        is_contributor: True if the user has any bugs assigned to him in the
        context of this bug task's pillar, either directly or by team
        participation.
        person_name: the displayname of the person
        pillar_name: the displayname of the bug task's pillar

        This API call is provided for use by the client Javascript where the
        calling context does not have access to the person or pillar names.
        """

    def getConjoinedMaster(bugtasks, bugtasks_by_package=None):
        """Return the conjoined master in the given bugtasks, if any.

        :param bugtasks: The bugtasks to be considered when looking for
            the conjoined master.
        :param bugtasks_by_package: A cache, mapping a
            `ISourcePackageName` to a list of bug tasks targeted to such
            a package name. Both distribution and distro series tasks
            should be included in this list.

        This method exists mainly to allow calculating the conjoined
        master from a cached list of bug tasks, reducing the number of
        db queries needed.
        """

    def subscribe(person, subscribed_by):
        """Subscribe this person to the underlying bug.

        This method was documented as being required here so that
        MentorshipOffers could happen on IBugTask. If that was the sole reason
        this method should be deletable. When we move to context-less bug
        presentation (where the bug is at /bugs/n?task=ubuntu) then we can
        eliminate this if it is no longer useful.
        """

    def isSubscribed(person):
        """Return True if the person is an explicit subscriber to the
        underlying bug for this bugtask.

        This method was documented as being required here so that
        MentorshipOffers could happen on IBugTask. If that was the sole
        reason then this method should be deletable.  When we move to
        context-less bug presentation (where the bug is at
        /bugs/n?task=ubuntu) then we can eliminate this if it is no
        longer useful.
        """

    @mutator_for(milestone)
    @rename_parameters_as(new_milestone='milestone')
    @operation_parameters(new_milestone=copy_field(milestone))
    @call_with(user=REQUEST_USER)
    @export_write_operation()
    def transitionToMilestone(new_milestone, user):
        """Set the BugTask milestone.

        Set the bugtask milestone, making sure that the user is
        authorised to do so.
        """

    @mutator_for(importance)
    @rename_parameters_as(new_importance='importance')
    @operation_parameters(new_importance=copy_field(importance))
    @call_with(user=REQUEST_USER)
    @export_write_operation()
    def transitionToImportance(new_importance, user):
        """Set the BugTask importance.

        Set the bugtask importance, making sure that the user is
        authorised to do so.
        """

    def canTransitionToStatus(new_status, user):
        """Return True if the user is allowed to change the status to
        `new_status`.

        :new_status: new status from `BugTaskStatus`
        :user: the user requesting the change

        Some status transitions, e.g. Triaged, require that the user
        be a bug supervisor or the owner of the project.
        """

    @mutator_for(status)
    @rename_parameters_as(new_status='status')
    @operation_parameters(
        new_status=copy_field(status))
    @call_with(user=REQUEST_USER)
    @export_write_operation()
    def transitionToStatus(new_status, user):
        """Perform a workflow transition to the new_status.

        :new_status: new status from `BugTaskStatus`
        :user: the user requesting the change

        For certain statuses, e.g. Confirmed, other actions will
        happen, like recording the date when the task enters this
        status.

        Some status transitions require extra conditions to be met.
        See `canTransitionToStatus` for more details.
        """

    def userCanSetAnyAssignee(user):
        """Check if the current user can set anybody sa a bugtask assignee.

        Owners, drivers, bug supervisors and Launchpad admins can always
        assign to someone else.  Other users can assign to someone else if a
        bug supervisor is not defined.
        """

    def userCanUnassign(user):
        """Check if the current user can set assignee to None."""

    @mutator_for(assignee)
    @operation_parameters(assignee=copy_field(assignee))
    @export_write_operation()
    def transitionToAssignee(assignee, validate=True):
        """Perform a workflow transition to the given assignee.

        When the bugtask assignee is changed from None to an IPerson
        object, the date_assigned is set on the task. If the assignee
        value is set to None, date_assigned is also set to None.
        """

    def validateTransitionToTarget(target):
        """Check whether a transition to this target is legal.

        :raises IllegalTarget: if the new target is not allowed.
        """

    @mutator_for(target)
    @call_with(user=REQUEST_USER)
    @operation_parameters(
        target=copy_field(target))
    @export_write_operation()
    def transitionToTarget(target, user):
        """Convert the bug task to a different bug target."""

    def updateTargetNameCache():
        """Update the targetnamecache field in the database.

        This method is meant to be called when an IBugTask is created or
        modified and will also be called from the update_stats.py cron script
        to ensure that the targetnamecache is properly updated when, for
        example, an IDistribution is renamed.
        """

    def asEmailHeaderValue():
        """Return a value suitable for an email header value for this bugtask.

        The return value is a single line of arbitrary length, so header
        folding should be done by the callsite, as needed.

        For an upstream task, this value might look like:

          product=firefox; status=New; importance=Critical; assignee=None;

        See doc/bugmail-headers.txt for a complete explanation and more
        examples.
        """

    def getDelta(old_task):
        """Compute the delta from old_task to this task.

        Returns an IBugTaskDelta or None if there were no changes between
        old_task and this task.
        """

    def getPackageComponent():
        """Return the task's package's component or None.

        Returns the component associated to the current published
        package in that distribution's current series. If the task is
        not a package task, returns None.
        """

    def userHasDriverPrivileges(user):
        """Does the user have driver privileges on the current bugtask?

        :return: A boolean.
        """

    def userHasBugSupervisorPrivileges(user):
        """Is the user privileged and allowed to change details on a bug?
class IGitSubscription(Interface):
    """The relationship between a person and a Git repository."""

    # XXX cjwatson 2015-01-19 bug=760849: "beta" is a lie to get WADL
    # generation working.  Individual attributes must set their version to
    # "devel".
    export_as_webservice_entry(as_of="beta")

    id = Int(title=_("ID"), readonly=True, required=True)
    person_id = Int(title=_("Person ID"), required=True, readonly=True)
    person = exported(
        PersonChoice(
            title=_("Person"),
            required=True,
            vocabulary="ValidPersonOrTeam",
            readonly=True,
            description=_(
                'Enter the launchpad id, or email address of the person you '
                'wish to subscribe to this repository. If you are unsure, use '
                'the "Choose..." option to find the person in Launchpad. You '
                'can only subscribe someone who is a registered user of the '
                'system.')))
    repository = exported(
        Reference(title=_("Repository ID"),
                  required=True,
                  readonly=True,
                  schema=IGitRepository))
    notification_level = exported(
        Choice(
            title=_("Notification Level"),
            required=True,
            vocabulary=BranchSubscriptionNotificationLevel,
            default=BranchSubscriptionNotificationLevel.ATTRIBUTEONLY,
            description=_(
                "Attribute notifications are sent when repository details are "
                "changed such as lifecycle status and name.  Revision "
                "notifications are generated when new revisions are found.")))
    max_diff_lines = exported(
        Choice(
            title=_("Generated Diff Size Limit"),
            required=True,
            vocabulary=BranchSubscriptionDiffSize,
            default=BranchSubscriptionDiffSize.ONEKLINES,
            description=_(
                "Diffs greater than the specified number of lines will not "
                "be sent to the subscriber.  The subscriber will still "
                "receive an email with the new revision details even if the "
                "diff is larger than the specified number of lines.")))
    review_level = exported(
        Choice(title=_("Code review Level"),
               required=True,
               vocabulary=CodeReviewNotificationLevel,
               default=CodeReviewNotificationLevel.FULL,
               description=_(
                   "Control the kind of review activity that triggers "
                   "notifications.")))

    subscribed_by = exported(
        PersonChoice(
            title=_("Subscribed by"),
            required=True,
            vocabulary="ValidPersonOrTeam",
            readonly=True,
            description=_("The person who created this subscription.")))

    @call_with(user=REQUEST_USER)
    @export_read_operation()
    @operation_for_version("devel")
    def canBeUnsubscribedByUser(user):
        """Can the user unsubscribe the subscriber from the repository?"""
class IBranchMergeProposalView(Interface):

    registrant = exported(
        PublicPersonChoice(
            title=_('Person'),
            required=True,
            vocabulary='ValidPersonOrTeam',
            readonly=True,
            description=_('The person who registered the merge proposal.')))

    description = exported(
        Text(title=_('Description'),
             required=False,
             description=_(
                 "A detailed description of the changes that are being "
                 "addressed by the branch being proposed to be merged."),
             max_length=50000))

    whiteboard = Whiteboard(title=_('Whiteboard'),
                            required=False,
                            description=_('Notes about the merge.'))

    queue_status = exported(
        Choice(title=_('Status'),
               vocabulary=BranchMergeProposalStatus,
               required=True,
               readonly=True,
               description=_("The current state of the proposal.")))

    # Not to be confused with a code reviewer. A code reviewer is someone who
    # can vote or has voted on a proposal.
    reviewer = exported(
        PersonChoice(title=_('Review person or team'),
                     required=False,
                     readonly=True,
                     vocabulary='ValidPersonOrTeam',
                     description=_(
                         "The person that accepted (or rejected) the code "
                         "for merging.")))

    next_preview_diff_job = Attribute(
        'The next BranchMergeProposalJob that will update a preview diff.')

    preview_diffs = Attribute('All preview diffs for this merge proposal.')

    preview_diff = exported(
        Reference(IPreviewDiff,
                  title=_('The current diff of the source branch against the '
                          'target branch.'),
                  readonly=True))

    reviewed_revision_id = exported(Text(
        title=_("The revision id that has been approved by the reviewer.")),
                                    exported_as='reviewed_revid')

    commit_message = exported(
        Summary(title=_("Commit Message"),
                required=False,
                description=_("The commit message that should be used when "
                              "merging the source branch."),
                strip_text=True))

    queue_position = exported(
        Int(title=_("Queue Position"),
            required=False,
            readonly=True,
            description=_("The position in the queue.")))

    queuer = exported(
        PublicPersonChoice(
            title=_('Queuer'),
            vocabulary='ValidPerson',
            required=False,
            readonly=True,
            description=_("The person that queued up the branch.")))

    queued_revision_id = exported(Text(
        title=_("Queued Revision ID"),
        readonly=True,
        required=False,
        description=_("The revision id that has been queued for "
                      "landing.")),
                                  exported_as='queued_revid')

    merged_revno = exported(
        Int(title=_("Merged Revision Number"),
            required=False,
            readonly=True,
            description=_("The revision number on the target branch which "
                          "contains the merge from the source branch.")))

    date_merged = exported(
        Datetime(title=_('Date Merged'),
                 required=False,
                 readonly=True,
                 description=_(
                     "The date that the source branch was merged into "
                     "the target branch")))

    title = Attribute(
        "A nice human readable name to describe the merge proposal. "
        "This is generated from the source and target branch, and used "
        "as the tal fmt:link text and for email subjects.")

    merge_reporter = exported(
        PublicPersonChoice(
            title=_("Merge Reporter"),
            vocabulary="ValidPerson",
            required=False,
            readonly=True,
            description=_("The user that marked the branch as merged.")))

    supersedes = exported(
        Reference(title=_("Supersedes"),
                  schema=Interface,
                  required=False,
                  readonly=True,
                  description=_("The branch merge proposal that this one "
                                "supersedes.")))
    superseded_by = exported(
        Reference(title=_("Superseded By"),
                  schema=Interface,
                  required=False,
                  readonly=True,
                  description=_(
                      "The branch merge proposal that supersedes this one.")))

    date_created = exported(
        Datetime(title=_('Date Created'), required=True, readonly=True))
    date_review_requested = exported(
        Datetime(title=_('Date Review Requested'),
                 required=False,
                 readonly=True))
    date_reviewed = exported(
        Datetime(title=_('Date Reviewed'), required=False, readonly=True))
    date_queued = exported(
        Datetime(title=_('Date Queued'), required=False, readonly=True))
    root_message_id = Text(
        title=_('The email message id from the first message'), required=False)
    all_comments = exported(
        CollectionField(
            title=_("All messages discussing this merge proposal"),
            # Really ICodeReviewComment.
            value_type=Reference(schema=Interface),
            readonly=True))

    address = exported(
        TextLine(title=_('The email address for this proposal.'),
                 readonly=True,
                 description=_('Any emails sent to this address will result'
                               'in comments being added.')))

    revision_end_date = Datetime(title=_('Cutoff date for showing revisions.'),
                                 required=False,
                                 readonly=True)

    @operation_parameters(id=Int(title=_("A CodeReviewComment ID.")))
    # Really ICodeReviewComment.
    @operation_returns_entry(Interface)
    @export_read_operation()
    def getComment(id):
        """Return the CodeReviewComment with the specified ID."""

    @call_with(user=REQUEST_USER)
    # Really IBugTask.
    @operation_returns_collection_of(Interface)
    @export_read_operation()
    @operation_for_version('devel')
    def getRelatedBugTasks(user):
        """Return the Bug tasks related to this merge proposal."""

    def getRevisionsSinceReviewStart():
        """Return all the revisions added since the review began.

        Revisions are grouped by creation (i.e. push) time.
        :return: An iterator of (date, iterator of revision data)
        """

    def getVoteReference(id):
        """Return the CodeReviewVoteReference with the specified ID."""

    def getNotificationRecipients(min_level):
        """Return the people who should be notified.

        Recipients will be returned as a dictionary where the key is the
        person, and the values are (subscription, rationale) tuples.

        :param min_level: The minimum notification level needed to be
            notified.
        """

    votes = exported(
        CollectionField(
            title=_('The votes cast or expected for this proposal'),
            # Really ICodeReviewVoteReference.
            value_type=Reference(schema=Interface),
            readonly=True))

    def isValidTransition(next_state, user=None):
        """True if it is valid for user update the proposal to next_state."""

    def isMergable():
        """Is the proposal in a state that allows it to being merged?

        As long as the proposal isn't in one of the end states, it is valid
        to be merged.
        """

    def getUnlandedSourceBranchRevisions():
        """Return a sequence of `BranchRevision` objects.

        Returns up to 10 revisions that are in the revision history for the
        source branch that are not in the revision history of the target
        branch.  These are the revisions that have been committed to the
        source branch since it branched off the target branch.
        """

    def getUsersVoteReference(user):
        """Get the existing vote reference for the given user.

        :return: A `CodeReviewVoteReference` or None.
        """

    def generateIncrementalDiff(old_revision, new_revision, diff=None):
        """Generate an incremental diff for the merge proposal.

        :param old_revision: The `Revision` to generate the diff from.
        :param new_revision: The `Revision` to generate the diff to.
        :param diff: If supplied, a pregenerated `Diff`.
        """

    def getIncrementalDiffs(revision_list):
        """Return a list of diffs for the specified revisions.
Beispiel #29
0
class IInlineExample(Interface):

    person = PersonChoice(vocabulary="ValidPersonOrTeam")

    status = Choice(vocabulary=JobStatus)
Beispiel #30
0
class IPOTemplate(IRosettaStats):
    """A translation template."""

    export_as_webservice_entry(singular_name='translation_template',
                               plural_name='translation_templates')

    id = exported(
        Int(title=u"The translation template id.",
            required=True,
            readonly=True))

    name = exported(
        TextLine(title=_("Template name"),
                 description=_(
                     "The name of this PO template, for example "
                     "'evolution-2.2'. Each translation template has a "
                     "unique name in its package. It's important to get this "
                     "correct, because Launchpad will recommend alternative "
                     "translations based on the name."),
                 constraint=valid_name,
                 required=True))

    translation_domain = exported(
        TextLine(
            title=_("Translation domain"),
            description=_(
                "The translation domain for a translation template. "
                "Used with PO file format when generating MO files for inclusion "
                "in language pack or MO tarball exports."),
            required=True))

    description = exported(
        Text(
            title=_("Description"),
            description=_(
                "Please provide a brief description of the content "
                "of this translation template, for example, telling translators "
                "if this template contains strings for end-users or other "
                "developers."),
            required=False))

    header = Text(
        title=_('Header'),
        description=_("The standard template header in its native format."),
        required=True)

    iscurrent = exported(Bool(
        title=_("Template is active"),
        description=_(
            "If unchecked, people can no longer change the template's "
            "translations."),
        required=True,
        default=True),
                         exported_as='active')

    owner = exported(
        PersonChoice(
            title=_("Owner"),
            required=True,
            description=_(
                "The owner of the template in Launchpad can edit the template "
                "and change it's status, and can also upload new versions "
                "of the template when a new release is made or when the "
                "translation strings have been changed during development."),
            vocabulary="ValidOwner"))

    productseries = Choice(title=_("Series"),
                           required=False,
                           vocabulary="ProductSeries")

    distroseries = Choice(title=_("Series"),
                          required=False,
                          vocabulary="DistroSeries")

    sourcepackagename = Choice(
        title=_("Source Package Name"),
        description=_("The source package that uses this template."),
        required=False,
        vocabulary="SourcePackageName")

    sourcepackagenameID = Int(
        title=_("Source Package Name ID"),
        description=_("The ID of the source package that uses this template."),
        required=False,
        readonly=True)

    sourcepackage = Reference(
        ISourcePackage,
        title=u"Source package this template is for, if any.",
        required=False,
        readonly=True)

    from_sourcepackagename = Choice(
        title=_("From Source Package Name"),
        description=_(
            "The source package this template comes from (set it only if it's"
            " different from the previous 'Source Package Name'."),
        required=False,
        vocabulary="SourcePackageName")

    sourcepackageversion = TextLine(title=_("Source Package Version"),
                                    required=False)

    binarypackagename = Choice(
        title=_("Binary Package"),
        description=_("The package in which this template's translations are "
                      "installed."),
        required=False,
        vocabulary="BinaryPackageName")

    languagepack = exported(Bool(
        title=_("Include translations for this template in language packs?"),
        description=_(
            "Check this box if this template is part of a language pack so "
            "its translations should be exported that way."),
        required=True,
        default=False),
                            exported_as='exported_in_languagepacks')

    path = exported(
        TextLine(title=_(
            "Path of the template in the source tree, including filename."),
                 required=True))

    source_file = Object(title=_('Source file for this translation template'),
                         readonly=True,
                         schema=ILibraryFileAlias)

    source_file_format = exported(Choice(
        title=_("File format for the source file"),
        required=False,
        vocabulary=TranslationFileFormat),
                                  exported_as='format')

    priority = exported(
        Int(title=_('Priority'),
            required=True,
            default=0,
            description=_(
                'A number that describes how important this template is. Often '
                'there are multiple templates, and you can use this as a way '
                'of indicating which are more important and should be '
                'translated first. Pick any number - higher priority '
                'templates will generally be listed first.')))

    datecreated = Datetime(
        title=_('When this translation template was created.'),
        required=True,
        readonly=True)

    translationgroups = Attribute(
        _('''
            The `ITranslationGroup` objects that handle translations for this
            template.
            There can be several because they can be inherited from project to
            product, for example.
            '''))

    translationpermission = Choice(title=_('Translation permission'),
                                   required=True,
                                   readonly=True,
                                   description=_('''
            The permission system which is used for this translation template.
            This is inherited from the product, project and/or distro in which
            the translation template is found.
            '''),
                                   vocabulary='TranslationPermission')

    pofiles = exported(
        CollectionField(
            title=_("All translation files that exist for this template."),
            # Really IPOFile, see _schema_circular_imports.py.
            value_type=Reference(schema=Interface)),
        exported_as='translation_files')

    relatives_by_source = Attribute(
        _('''All `IPOTemplate` objects that have the same source.
            For example those that came from the same productseries or the
            same source package.
            '''))

    displayname = TextLine(title=_('The translation template brief name.'),
                           required=True,
                           readonly=True)

    title = TextLine(title=_('The translation template title.'),
                     required=True,
                     readonly=True)

    product = Object(
        title=_('The `IProduct` to which this translation template belongs.'),
        required=False,
        readonly=True,
        # Really IProduct, see _schema_circular_imports.py.
        schema=Interface)

    distribution = Object(title=_(
        'The `IDistribution` to which this translation template '
        'belongs.'),
                          readonly=True,
                          schema=IDistribution)

    messagecount = exported(Int(
        title=_('The number of translation messages for this template.'),
        required=True,
        readonly=True),
                            exported_as='message_count')

    language_count = exported(
        Int(title=_('The number of languages for which we have translations.'),
            required=True,
            readonly=True))

    translationtarget = Attribute(
        _('''
            The direct object in which this template is attached.
            This will either be an `ISourcePackage` or an `IProductSeries`.
            '''))

    date_last_updated = exported(
        Datetime(title=_('Date for last update'), required=True))

    uses_english_msgids = Bool(title=_("Uses English strings as msgids"),
                               readonly=True,
                               description=_("""
            Some formats, such as Mozilla's XPI, use symbolic msgids where
            gettext uses the original English strings to identify messages.
            """))

    translation_side = Int(title=_("Translation side"),
                           required=True,
                           readonly=True)

    def __iter__():
        """Return an iterator over current `IPOTMsgSet` in this template."""

    def clearPOFileCache():
        """Clear `POFile`-related cached data.

        As you work with a `POTemplate`, some data about its `POFile`s
        gets cached.  But if you're iterating over the template's
        translations one `POFile` at a time, you can drop any cached
        data about a `POFile` as soon as you're done with it.  Use this
        method to do that.
        """

    def setActive(active):
        """Toggle the iscurrent flag.

        Takes care of updating the suggestive potempalte cache when the
        template is disabled.
        """

    def getHeader():
        """Return an `ITranslationHeaderData` representing its header."""

    def getPOTMsgSetByMsgIDText(singular_text,
                                plural_text=None,
                                only_current=False,
                                context=None):
        """Return `IPOTMsgSet` indexed by `singular_text` from this template.

        If the key is a string or a unicode object, returns the
        `IPOTMsgSet` in this template that has a primary message ID
        with the given text.

        If `only_current` is True, then get only current message sets.

        If `context` is not None, look for a message set with that context
        value.

        If `plural_text` is not None, also filter by that plural text.

        If no `IPOTMsgSet` is found, return None.
        """

    def getPOTMsgSetBySequence(sequence):
        """Return the `IPOTMsgSet` with the given sequence or None.

        :arg sequence: The sequence number when the `IPOTMsgSet` appears.

        The sequence number must be > 0.
        """

    def getPOTMsgSets(current=True, prefetch=True):
        """Return an iterator over `IPOTMsgSet` objects in this template.

        :param current: Whether to limit the search to current
            POTMsgSets.
        :param prefetch: Whether to prefetch the `POMsgID`s attached to
            the POTMsgSets.  This is for optimization only.
        :return: All current POTMsgSets for the template if `current` is
            True, or all POTMsgSets for the template otherwise.
        """

    def getTranslationCredits():
        """Return an iterator over translation credits.

        Return all `IPOTMsgSet` objects in this template that are translation
        credits.
        """

    def getPOTMsgSetsCount(current=True):
        """Return the number of POTMsgSet objects related to this object.

        The current argument is used to select only current POTMsgSets or all
        of them.
        """

    def __getitem__(key):
        """Same as getPOTMsgSetByMsgIDText(), with only_current=True
        """

    def sharingKey():
        """A key for determining the sharing precedence of a template.

        Active templates have precedence over inactive ones.
        Development foci have precendence over non-development foci.
        Product development foci have precedence over Package development
        foci.
        """

    def getPOTMsgSetByID(id):
        """Return the POTMsgSet object related to this POTemplate with the id.

        If there is no POTMsgSet with that id and for that POTemplate, return
        None.
        """

    def languages():
        """This Return the set of languages for which we have POFiles for
        this POTemplate.
        """

    def getPOFileByPath(path):
        """Get the PO file of the given path.

        Return None if there is no such `IPOFile`.
        """

    def getPOFileByLang(language_code):
        """Get the PO file of the given language.

        Return None if there is no such POFile.
        """

    def getOtherSidePOTemplate():
        """Get the POTemplate with the same name on the other side of a
        packaging link.
        """

    def hasPluralMessage():
        """Test whether this template has any message sets which are plural
        message sets."""

    def export():
        """Return a serialized version as a string using its native format."""

    def exportWithTranslations():
        """Return an ExportedTranslationFile using its native format.

        It include all translations available.
        """

    def expireAllMessages():
        """Mark all of our message sets as not current (sequence=0)"""

    def newPOFile(language_code, create_sharing=True):
        """Return a new `IPOFile` for the given language.

        Raise LanguageNotFound if the language does not exist in the
        database.

        We should not have already an `IPOFile` for the given language_code.

        :param language_code: The code of the language for which to create
            the IPOFile.
        :param requester: The requester person. If given and will have edit
            permissions on the IPOFile, it becomes the owner. Otherwise
            rosetta_experts own the file.
        :param create_sharing: Whether the IPOFile should be created in all
            sharing templates, too. Should only be set to False to avoid
            loops when creating a new IPOTemplate.
        """

    def getDummyPOFile(language, requester=None, check_for_existing=True):
        """Return a DummyPOFile if there isn't already a persistent `IPOFile`

        Raise `LanguageNotFound` if the language does not exist in the
        database.

        This method is designed to be used by read only actions. This way you
        only create a POFile when you actually need to store data.

        We should not have already a POFile for the given language:
        if check_for_existing is set to False, no check will be done for this.
        """

    def createPOTMsgSetFromMsgIDs(msgid_singular,
                                  msgid_plural=None,
                                  context=None,
                                  sequence=0):
        """Creates a new template message in the database.

        :param msgid_singular: A reference to a singular msgid.
        :param msgid_plural: A reference to a plural msgid.  Can be None
            if the message is not a plural message.
        :param context: A context for the template message differentiating
            it from other template messages with exactly the same `msgid`.
        :param sequence: The sequence number of this POTMsgSet within this
            POTemplate. If 0, it is considered obsolete.
        :return: The newly created message set.
        """

    def createMessageSetFromText(singular_text,
                                 plural_text,
                                 context=None,
                                 sequence=0):
        """Creates a new template message in the database using strings.

        Similar to createMessageSetFromMessageID, but takes text objects
        (unicode or string) along with textual context, rather than a
        message IDs.

        :param singular_text: The string for the singular msgid.
        :param msgid_plural: The string for the plural msgid.  Must be None
            if the message is not a plural message.
        :param context: A context for the template message differentiating
            it from other template messages with exactly the same `msgid`.
        :param sequence: The sequence number of this POTMsgSet within this
            POTemplate. If 0, it is considered obsolete.
        :return: The newly created message set.
        """

    def getOrCreateSharedPOTMsgSet(singular_text,
                                   plural_text,
                                   context=None,
                                   initial_file_references=None,
                                   initial_source_comment=None):
        """Finds an existing shared POTMsgSet to use or creates a new one.

        :param singular_text: string containing singular form.
        :param plural_text: string containing plural form.
        :param context: context to differentiate between two messages with
        same singular_text and plural_text.
        :param initial_file_references: Initializer for file_references if
            a new POTMsgSet needs to be created.  Will not be set on an
            existing POTMsgSet.
        :param initial_source_comment: Initializer for source_comment if
            a new POTMsgSet needs to be created.  Will not be set on an
            existing POTMsgSet.
        :return: existing or new shared POTMsgSet with a sequence of 0
        in this POTemplate.
        """

    def importFromQueue(entry_to_import, logger=None, txn=None):
        """Import given queue entry.

        :param entry_to_import: `TranslationImportQueueEntry` specifying an
            approved import for this `POTemplate`
        :param logger: optional logger to report problems to.
        :param txn: optional transaction manager for intermediate
            commits.  Used to prevent long-running transactions that can
            lead to deadlocks.

        :return: a tuple of the subject line and body for a notification email
            to be sent to the uploader.
        """

    def getTranslationRows():
        """Return the `IVPOTexport` objects for this template."""

    def awardKarma(person, action_name):
        """Award karma for a translation action on this template."""

    def getTranslationPolicy():
        """Return the applicable `ITranslationPolicy` object.