Esempio n. 1
0
        class BranchEditSchema(Interface):
            """Defines the fields for the edit form.

            This is necessary so as to make an editable field for the
            branch privacy.  Normally the field is not editable through
            the interface in order to stop direct setting of the private
            attribute, but in this case we actually want the user to be
            able to edit it.
            """
            use_template(IBranch, include=[
                'name',
                'url',
                'description',
                'lifecycle_status',
                'whiteboard',
                ])
            information_type = copy_field(
                IBranch['information_type'], readonly=False,
                vocabulary=InformationTypeVocabulary(types=info_types))
            reviewer = copy_field(IBranch['reviewer'], required=True)
            owner = copy_field(IBranch['owner'], readonly=False)
            target = Reference(
                title=_('Branch target'), required=True,
                schema=IBranchTarget,
                description=_('The project (if any) this branch pertains to. '
                    'If no project is specified, then it is a personal '
                    'branch'))
Esempio n. 2
0
 def renderValue(self, value):
     # Render the items with subordinate fields and support markup.
     self.bug_trackers = dict(self.renderItems(value))
     self.product = self.context.context
     # The view must also use GhostWidget for the 'remote_product' field.
     self.remote_product = copy_field(IProduct['remote_product'])
     self.remote_product_widget = CustomWidgetFactory(TextWidget)
     setUpWidget(self,
                 'remote_product',
                 self.remote_product,
                 IInputWidget,
                 prefix='field',
                 value=self.product.remote_product,
                 context=self.product)
     # The view must also use GhostWidget for the 'enable_bug_expiration'
     # field.
     self.enable_bug_expiration = copy_field(
         IProduct['enable_bug_expiration'])
     self.enable_bug_expiration_widget = CustomWidgetFactory(CheckBoxWidget)
     setUpWidget(self,
                 'enable_bug_expiration',
                 self.enable_bug_expiration,
                 IInputWidget,
                 prefix='field',
                 value=self.product.enable_bug_expiration,
                 context=self.product)
     return self.template()
Esempio n. 3
0
    def initialize(self):
        """See `LaunchpadView.initialize`."""
        review_status_field = copy_field(
            ICodeImport['review_status'], required=False, default=None)
        self.review_status_widget = CustomWidgetFactory(DropdownWidgetWithAny)
        setUpWidget(self, 'review_status',  review_status_field, IInputWidget)

        rcs_type_field = copy_field(
            ICodeImport['rcs_type'], required=False, default=None)
        self.rcs_type_widget = CustomWidgetFactory(DropdownWidgetWithAny)
        setUpWidget(self, 'rcs_type',  rcs_type_field, IInputWidget)

        # status should be None if either (a) there were no query arguments
        # supplied, i.e. the user browsed directly to this page (this is when
        # hasValidInput returns False) or (b) the user chose 'Any' in the
        # status widget (this is when hasValidInput returns True but
        # getInputValue returns None).
        review_status = None
        if self.review_status_widget.hasValidInput():
            review_status = self.review_status_widget.getInputValue()
        # Similar for 'type'
        rcs_type = None
        if self.rcs_type_widget.hasValidInput():
            rcs_type = self.rcs_type_widget.getInputValue()

        imports = self.context.search(
            review_status=review_status, rcs_type=rcs_type)

        self.batchnav = BatchNavigator(imports, self.request)
Esempio n. 4
0
class EditCodeImportForm(Interface):
    """The fields presented on the form for editing a code import."""

    url = copy_field(ICodeImport['url'], readonly=False)
    cvs_root = copy_field(ICodeImport['cvs_root'], readonly=False)
    cvs_module = copy_field(ICodeImport['cvs_module'], readonly=False)
    whiteboard = copy_field(IBranch['whiteboard'])
Esempio n. 5
0
class SetBranchForm(Interface):
    """The fields presented on the form for setting a branch."""

    use_template(ICodeImport, ['cvs_module'])

    rcs_type = Choice(title=_("Type of RCS"),
        required=False, vocabulary=RevisionControlSystems,
        description=_(
            "The version control system to import from. "))

    repo_url = URIField(
        title=_("Branch URL"), required=True,
        description=_("The URL of the branch."),
        allowed_schemes=["http", "https"],
        allow_userinfo=False, allow_port=True, allow_query=False,
        allow_fragment=False, trailing_slash=False)

    branch_location = copy_field(
        IProductSeries['branch'], __name__='branch_location',
        title=_('Branch'),
        description=_(
            "The Bazaar branch for this series in Launchpad, "
            "if one exists."))

    branch_type = Choice(
        title=_('Import type'), vocabulary=BRANCH_TYPE_VOCABULARY,
        description=_("The type of import"), required=True)

    branch_name = copy_field(
        IBranch['name'], __name__='branch_name', title=_('Branch name'),
        description=_(''), required=True)

    branch_owner = copy_field(
        IBranch['owner'], __name__='branch_owner', title=_('Branch owner'),
        description=_(''), required=True)
Esempio n. 6
0
class IPOTemplateEditForm(IPOTemplate):

    sourcepackagename = copy_field(IPOTemplate['sourcepackagename'],
                                   vocabularyName='DistributionSourcePackage')

    from_sourcepackagename = copy_field(
        IPOTemplate['from_sourcepackagename'],
        vocabularyName='DistributionSourcePackage')
Esempio n. 7
0
class IEditCodeReviewComment(Interface):
    """Interface for use as a schema for CodeReviewComment forms."""

    vote = copy_field(ICodeReviewComment['vote'], required=False)

    review_type = copy_field(
        ICodeReviewVoteReference['review_type'],
        description=u'Lowercase keywords describing the type of review you '
        'are performing.')

    comment = Text(title=_('Comment'), required=False)
Esempio n. 8
0
class ISetLocation(Interface):
    """An interface for setting the location and time zone of an object."""

    @call_with(user=REQUEST_USER)
    @operation_parameters(
        latitude=copy_field(IHasLocation['latitude'], required=True),
        longitude=copy_field(IHasLocation['longitude'], required=True),
        time_zone=copy_field(IHasLocation['time_zone'], required=True))
    @export_write_operation()
    @operation_for_version('beta')
    def setLocation(latitude, longitude, time_zone, user):
        """Specify the location and time zone of a person."""
Esempio n. 9
0
class GitRefRegisterMergeProposalSchema(Interface):
    """The schema to define the form for registering a new merge proposal."""

    target_git_repository = Choice(
        title=_("Target repository"),
        vocabulary="GitRepository", required=True, readonly=True,
        description=_("The repository that the source will be merged into."))

    target_git_path = TextLine(
        title=_("Target branch"), required=True, readonly=True,
        description=_(
            "The branch within the target repository that the source will "
            "be merged into."))

    prerequisite_git_repository = Choice(
        title=_("Prerequisite repository"),
        vocabulary="GitRepository", required=False, readonly=True,
        description=_(
            "A repository containing a branch that should be merged before "
            "this one.  (Its changes will not be shown in the diff.)"))

    prerequisite_git_path = TextLine(
        title=_("Prerequisite branch"), required=False, readonly=True,
        description=_(
            "A branch within the prerequisite repository that should be "
            "merged before this one.  (Its changes will not be shown in the "
            "diff.)"))

    comment = Text(
        title=_('Description of the change'), required=False,
        description=_('Describe what changes your branch introduces, '
                      'what bugs it fixes, or what features it implements. '
                      'Ideally include rationale and how to test. '
                      'You do not need to repeat information from the commit '
                      'message here.'))

    reviewer = copy_field(
        ICodeReviewVoteReference['reviewer'], required=False)

    review_type = copy_field(
        ICodeReviewVoteReference['review_type'],
        description=u'Lowercase keywords describing the type of review you '
                     'would like to be performed.')

    commit_message = IBranchMergeProposal['commit_message']

    needs_review = Bool(
        title=_("Needs review"), required=True, default=True,
        description=_(
            "Is the proposal ready for review now?"))
Esempio n. 10
0
class IDistroSeriesAddForm(Interface):

    name = copy_field(
        IDistroSeries["name"],
        description=_("The name of this series as used for URLs."))

    version = copy_field(IDistroSeries["version"],
                         description=_("The version of the new series."))

    display_name = copy_field(IDistroSeries["display_name"],
                              description=_(
                                  "The name of the new series as it would "
                                  "appear in a paragraph."))

    summary = copy_field(IDistroSeries["summary"])
Esempio n. 11
0
 def person_picker(self):
     field = copy_field(
         ISnap['owner'],
         vocabularyName='AllUserTeamsParticipationPlusSelfSimpleDisplay')
     return InlinePersonEditPickerWidget(
         self.context, field, format_link(self.context.owner),
         header='Change owner', step_title='Select a new owner')
Esempio n. 12
0
class IBuilderEdit(Interface):
    @mutator_for(IBuilderView['clean_status'])
    @operation_parameters(status=copy_field(IBuilderView['clean_status']))
    @export_write_operation()
    @operation_for_version('devel')
    def setCleanStatus(status):
        """Update the clean status."""
Esempio n. 13
0
class BugSupervisorEditSchema(Interface):
    """Defines the fields for the edit form.

    This is necessary to make an editable field for bug supervisor as it is
    defined as read-only in the interface to prevent setting it directly.
    """
    bug_supervisor = copy_field(IHasBugSupervisor['bug_supervisor'],
                                readonly=False)
Esempio n. 14
0
class ISourcePackageRecipeEdit(Interface):
    """ISourcePackageRecipe methods that require launchpad.Edit permission."""
    @mutator_for(ISourcePackageRecipeView['recipe_text'])
    @operation_for_version("devel")
    @operation_parameters(recipe_text=copy_field(
        ISourcePackageRecipeView['recipe_text']))
    @export_write_operation()
    def setRecipeText(recipe_text):
        """Set the text of the recipe."""

    @mutator_for(ISourcePackageRecipeEditableAttributes['distroseries'])
    @operation_parameters(distroseries=copy_field(
        ISourcePackageRecipeEditableAttributes['distroseries']))
    @export_write_operation()
    @operation_for_version("devel")
    def updateSeries(distroseries):
        """Replace this recipe's distro series."""
 def person_picker(self):
     field = copy_field(
         ISourcePackageRecipe['owner'],
         vocabularyName='UserTeamsParticipationPlusSelfSimpleDisplay')
     return InlinePersonEditPickerWidget(
         self.context, field,
         format_link(self.context.owner),
         header='Change owner',
         step_title='Select a new owner')
Esempio n. 16
0
 def setUpFields(self):
     super(SourcePackageChangeUpstreamStepOne, self).setUpFields()
     series = self.context.productseries
     if series is not None:
         default = series.product
     else:
         default = None
     product_field = copy_field(IProductSeries['product'], default=default)
     self.form_fields += Fields(product_field)
Esempio n. 17
0
 class information_type_schema(Interface):
     information_type_field = copy_field(
         IBug['information_type'], readonly=False,
         vocabulary=InformationTypeVocabulary(types=info_types))
     # A hidden field used to determine if the new information type
     # should be validated to ensure the bug does not become invisible
     # after the change.
     validate_change = Bool(
         title=u"Validate change", required=False, default=False)
Esempio n. 18
0
class IGitNascentRuleGrant(Interface):
    """An access grant in the process of being created.

    This represents parameters for a grant that have been deserialised from
    a webservice request, but that have not yet been attached to a rule.
    """

    grantee_type = copy_field(IGitRuleGrant["grantee_type"])

    grantee = copy_field(IGitRuleGrant["grantee"])

    can_create = copy_field(
        IGitRuleGrant["can_create"], required=False, default=False)

    can_push = copy_field(
        IGitRuleGrant["can_push"], required=False, default=False)

    can_force_push = copy_field(
        IGitRuleGrant["can_force_push"], required=False, default=False)
Esempio n. 19
0
 def setUpFields(self):
     super(SourcePackageChangeUpstreamStepOne, self).setUpFields()
     series = self.context.productseries
     if series is not None:
         default = series.product
     else:
         default = None
     product_field = copy_field(
         IProductSeries['product'], default=default)
     self.form_fields += Fields(product_field)
Esempio n. 20
0
class IGitNascentRule(Interface):
    """An access rule in the process of being created.

    This represents parameters for a rule that have been deserialised from a
    webservice request, but that have not yet been attached to a repository.
    """

    ref_pattern = copy_field(IGitRule["ref_pattern"])

    grants = List(value_type=InlineObject(schema=IGitNascentRuleGrant))
Esempio n. 21
0
class IMaloneApplication(ILaunchpadApplication):
    """Application root for malone."""
    export_as_webservice_collection(IBug)

    def searchTasks(search_params):
        """Search IBugTasks with the given search parameters."""

    @call_with(user=REQUEST_USER)
    @operation_parameters(bug_id=copy_field(IBug['id']),
                          related_bug=Reference(schema=IBug))
    @export_read_operation()
    @operation_for_version('devel')
    def getBugData(user, bug_id, related_bug=None):
        """Search bugtasks matching the specified criteria.

        The only criteria currently supported is to search for a bugtask with
        the specified bug id.

        :return: a list of matching bugs represented as json data
        """

    bug_count = Attribute("The number of bugs recorded in Launchpad")
    bugwatch_count = Attribute("The number of links to external bug trackers")
    bugtask_count = Attribute("The number of bug tasks in Launchpad")
    projects_with_bugs_count = Attribute(
        "The number of products and "
        "distributions which have bugs in Launchpad.")
    shared_bug_count = Attribute("The number of bugs that span multiple "
                                 "products and distributions")
    bugtracker_count = Attribute("The number of bug trackers in Launchpad")
    top_bugtrackers = Attribute("The BugTrackers with the most watches.")

    @collection_default_content()
    def empty_list():
        """Return an empty set - only exists to keep lazr.restful happy."""

    @call_with(owner=REQUEST_USER)
    @operation_parameters(target=Reference(
        schema=IBugTarget,
        required=True,
        title=u"The project, distribution or source package that has "
        "this bug."))
    @export_factory_operation(IBug, [
        'title', 'description', 'tags', 'information_type', 'security_related',
        'private'
    ])
    def createBug(owner,
                  title,
                  description,
                  target,
                  information_type=None,
                  tags=None,
                  security_related=None,
                  private=None):
        """Create a bug (with an appropriate bugtask) and return it.
Esempio n. 22
0
class NewCodeImportForm(Interface):
    """The fields presented on the form for editing a code import."""

    use_template(IBranch, ['owner'])
    use_template(ICodeImport, ['rcs_type', 'cvs_root', 'cvs_module'])

    svn_branch_url = URIField(
        title=_("Branch URL"), required=False,
        description=_(
            "The URL of a Subversion branch, starting with svn:// or "
            "http(s)://.   You can include a username and password as part "
            "of the url, but this will be displayed on the branch page."),
        allowed_schemes=["http", "https", "svn"],
        allow_userinfo=True,
        allow_port=True,
        allow_query=False,
        allow_fragment=False,
        trailing_slash=False)

    git_repo_url = URIField(
        title=_("Repo URL"), required=False,
        description=_(
            "The URL of the git repository.  The HEAD branch will be "
            "imported."),
        allowed_schemes=["git", "http", "https"],
        allow_userinfo=True,
        allow_port=True,
        allow_query=False,
        allow_fragment=False,
        trailing_slash=False)

    bzr_branch_url = URIField(
        title=_("Branch URL"), required=False,
        description=_("The URL of the Bazaar branch."),
        allowed_schemes=["http", "https", "bzr", "ftp"],
        allow_userinfo=True,
        allow_port=True,
        allow_query=False,     # Query makes no sense in Bazaar
        allow_fragment=False,  # Fragment makes no sense in Bazaar
        trailing_slash=False)

    branch_name = copy_field(
        IBranch['name'],
        __name__='branch_name',
        title=_('Branch Name'),
        description=_(
            "This will be used in the branch URL to identify the "
            "imported branch.  Examples: main, trunk."),
        )

    product = Choice(
        title=_('Project'),
        description=_("The Project to associate the code import with."),
        vocabulary="Product",
        )
Esempio n. 23
0
class AddSpecificationDependencySchema(Interface):

    dependency = copy_field(
        ISpecificationDependency['dependency'],
        readonly=False,
        description=_("If another blueprint needs to be fully implemented "
                      "before this feature can be started, then specify that "
                      "dependency here so Launchpad knows about it and can "
                      "give you an accurate project plan.  You can enter the "
                      "name of a blueprint that has the same target, or the "
                      "URL of any blueprint."))
Esempio n. 24
0
class IGitRepositoryModerate(Interface):
    """IGitRepository methods that can be called by more than one community."""
    @mutator_for(IGitRepositoryView["information_type"])
    @operation_parameters(
        information_type=copy_field(IGitRepositoryView["information_type"]), )
    @call_with(user=REQUEST_USER)
    @export_write_operation()
    @operation_for_version("devel")
    def transitionToInformationType(information_type,
                                    user,
                                    verify_policy=True):
        """Set the information type for this repository.
Esempio n. 25
0
class IProductEditRestricted(IOfficialBugTagTargetRestricted):
    """`IProduct` properties which require launchpad.Edit permission."""

    @mutator_for(IProductView['bug_sharing_policy'])
    @operation_parameters(bug_sharing_policy=copy_field(
        IProductView['bug_sharing_policy']))
    @export_write_operation()
    @operation_for_version("devel")
    def setBugSharingPolicy(bug_sharing_policy):
        """Mutator for bug_sharing_policy.

        Checks authorization and entitlement.
        """

    @mutator_for(IProductView['branch_sharing_policy'])
    @operation_parameters(
        branch_sharing_policy=copy_field(
            IProductView['branch_sharing_policy']))
    @export_write_operation()
    @operation_for_version("devel")
    def setBranchSharingPolicy(branch_sharing_policy):
        """Mutator for branch_sharing_policy.

        Checks authorization and entitlement.
        """

    @mutator_for(IProductView['specification_sharing_policy'])
    @operation_parameters(
        specification_sharing_policy=copy_field(
            IProductView['specification_sharing_policy']))
    @export_write_operation()
    @operation_for_version("devel")
    def setSpecificationSharingPolicy(specification_sharing_policy):
        """Mutator for specification_sharing_policy.

        Checks authorization and entitlement.
        """

    def checkInformationType(value):
        """Check whether the information type change should be permitted.
Esempio n. 26
0
class ISnapEditSchema(Interface):
    """Schema for adding or editing a snap package."""

    use_template(ISnap, include=[
        'owner',
        'name',
        'private',
        'require_virtualized',
        'allow_internet',
        'build_source_tarball',
        'auto_build',
        'auto_build_channels',
        'store_upload',
        ])
    store_distro_series = Choice(
        vocabulary='BuildableSnappyDistroSeries', required=True,
        title=u'Series')
    vcs = Choice(vocabulary=VCSType, required=True, title=u'VCS')

    # Each of these is only required if vcs has an appropriate value.  Later
    # validation takes care of adjusting the required attribute.
    branch = copy_field(ISnap['branch'], required=True)
    git_ref = copy_field(ISnap['git_ref'], required=True)

    # These are only required if auto_build is True.  Later validation takes
    # care of adjusting the required attribute.
    auto_build_archive = copy_field(ISnap['auto_build_archive'], required=True)
    auto_build_pocket = copy_field(ISnap['auto_build_pocket'], required=True)

    # This is only required if store_upload is True.  Later validation takes
    # care of adjusting the required attribute.
    store_name = copy_field(ISnap['store_name'], required=True)
    store_channels = copy_field(ISnap['store_channels'], required=True)
Esempio n. 27
0
 def renderValue(self, value):
     # Render the items with subordinate fields and support markup.
     self.bug_trackers = dict(self.renderItems(value))
     self.product = self.context.context
     # The view must also use GhostWidget for the 'remote_product' field.
     self.remote_product = copy_field(IProduct['remote_product'])
     self.remote_product_widget = CustomWidgetFactory(TextWidget)
     setUpWidget(
         self, 'remote_product', self.remote_product, IInputWidget,
         prefix='field', value=self.product.remote_product,
         context=self.product)
     # The view must also use GhostWidget for the 'enable_bug_expiration'
     # field.
     self.enable_bug_expiration = copy_field(
         IProduct['enable_bug_expiration'])
     self.enable_bug_expiration_widget = CustomWidgetFactory(
         CheckBoxWidget)
     setUpWidget(
         self, 'enable_bug_expiration', self.enable_bug_expiration,
         IInputWidget, prefix='field',
         value=self.product.enable_bug_expiration, context=self.product)
     return self.template()
Esempio n. 28
0
 def _prependMilestoneField(self):
     """Add Milestone Choice field with custom terms."""
     terms = [
         SimpleTerm(milestone, milestone.name, milestone.name)
         for milestone in self.context.all_milestones
         if milestone.product_release is None]
     terms.insert(0, SimpleTerm(None, None, '- Select Milestone -'))
     milestone_field = FormFields(
         copy_field(
             IProductRelease['milestone'],
             __name__='milestone_for_release',
             vocabulary=SimpleVocabulary(terms)))
     self.form_fields = milestone_field + self.form_fields
Esempio n. 29
0
 def _prependMilestoneField(self):
     """Add Milestone Choice field with custom terms."""
     terms = [
         SimpleTerm(milestone, milestone.name, milestone.name)
         for milestone in self.context.all_milestones
         if milestone.product_release is None]
     terms.insert(0, SimpleTerm(None, None, '- Select Milestone -'))
     milestone_field = FormFields(
         copy_field(
             IProductRelease['milestone'],
             __name__='milestone_for_release',
             vocabulary=SimpleVocabulary(terms)))
     self.form_fields = milestone_field + self.form_fields
Esempio n. 30
0
class IProductReleaseEditRestricted(Interface):
    """`IProductRelease` properties which require `launchpad.Edit`."""

    @call_with(uploader=REQUEST_USER, from_api=True)
    @operation_parameters(
        filename=TextLine(),
        signature_filename=TextLine(),
        content_type=TextLine(),
        file_content=Bytes(constraint=productrelease_file_size_constraint),
        signature_content=Bytes(
            constraint=productrelease_signature_size_constraint),
        file_type=copy_field(IProductReleaseFile['filetype'], required=False))
    @export_factory_operation(IProductReleaseFile, ['description'])
    @export_operation_as('add_file')
    def addReleaseFile(filename, file_content, content_type,
                       uploader, signature_filename=None,
                       signature_content=None,
                       file_type=UpstreamFileType.CODETARBALL,
                       description=None, from_api=False):
        """Add file to the library and link to this `IProductRelease`.

        The signature file will also be added if available.

        :param filename: Name of the file being uploaded.
        :param file_content: StringIO or file object.
        :param content_type: A MIME content type string.
        :param uploader: The person who uploaded the file.
        :param signature_filename: Name of the uploaded gpg signature file.
        :param signature_content: StringIO or file object.
        :param file_type: An `UpstreamFileType` enum value.
        :param description: Info about the file.
        :returns: `IProductReleaseFile` object.
        :raises: InvalidFilename if the filename is invalid or a duplicate
            of a file previously added to the release.
        """

    @export_write_operation()
    @export_operation_as('delete')
    def destroySelf():
        """Delete this release.
Esempio n. 31
0
def optional_message_subject_field():
    """A modified message subject field allowing None as a value."""
    subject_field = copy_field(IMessage['subject'])
    subject_field.required = False
    return subject_field
Esempio n. 32
0
    IBugTaskSearch,
)
from lp.registry.enums import BugSharingPolicy
from lp.services.fields import Tag
from lp.services.webservice.apihelpers import (
    patch_plain_parameter_type,
    patch_reference_property,
)

search_tasks_params_common = {
    "order_by":
    List(title=_('List of fields by which the results are ordered.'),
         value_type=Text(),
         required=False),
    "search_text":
    copy_field(IBugTaskSearch['searchtext']),
    "status":
    copy_field(IBugTaskSearch['status']),
    "importance":
    copy_field(IBugTaskSearch['importance']),
    "information_type":
    copy_field(IBugTaskSearch['information_type']),
    "assignee":
    Reference(schema=Interface),
    "bug_reporter":
    Reference(schema=Interface),
    "bug_supervisor":
    Reference(schema=Interface),
    "bug_commenter":
    Reference(schema=Interface),
    "bug_subscriber":
Esempio n. 33
0
class IOfficialBugTagTargetPublic(IHasOfficialBugTags):
    """Public attributes for `IOfficialBugTagTarget`."""

    official_bug_tags = copy_field(IHasOfficialBugTags['official_bug_tags'],
                                   readonly=False)
Esempio n. 34
0
class ITeamMembership(Interface):
    """TeamMembership for Users.

    This table includes *direct* team members only.  Indirect memberships are
    handled by the TeamParticipation table.
    """
    export_as_webservice_entry()

    id = Int(title=_('ID'), required=True, readonly=True)
    team = exported(
        Reference(title=_("Team"),
                  required=True,
                  readonly=True,
                  schema=Interface))  # Specified in interfaces/person.py.
    person = exported(
        Reference(title=_("Member"),
                  required=True,
                  readonly=True,
                  schema=Interface),  # Specified in interfaces/person.py.
        exported_as='member')
    personID = Int(title=_("Person ID"), required=True, readonly=True)
    proposed_by = Attribute(_('Proponent'))
    reviewed_by = Attribute(
        _("The team admin who approved/rejected the member."))
    acknowledged_by = Attribute(
        _('The person (usually the member or someone acting on their behalf) '
          'that acknowledged (accepted/declined) a membership invitation.'))
    last_changed_by = exported(
        Reference(title=_('Last person who change this'),
                  required=False,
                  readonly=True,
                  schema=Interface))  # Specified in interfaces/person.py.

    datejoined = exported(Datetime(
        title=_("Date joined"),
        required=False,
        readonly=True,
        description=_("The date in which this membership was made "
                      "active for the first time.")),
                          exported_as='date_joined')
    dateexpires = exported(Datetime(title=_("Date expires"),
                                    required=False,
                                    readonly=True),
                           exported_as='date_expires')
    date_created = Datetime(
        title=_("Date created"),
        required=False,
        readonly=True,
        description=_("The date in which this membership was created."))
    date_proposed = Datetime(
        title=_("Date proposed"),
        required=False,
        readonly=True,
        description=_("The date in which this membership was proposed."))
    date_acknowledged = Datetime(
        title=_("Date acknowledged"),
        required=False,
        readonly=True,
        description=_("The date in which this membership was acknowledged by "
                      "the member (or someone acting on their behalf)."))
    date_reviewed = Datetime(
        title=_("Date reviewed"),
        required=False,
        readonly=True,
        description=_("The date in which this membership was approved/"
                      "rejected by one of the team's admins."))
    date_last_changed = Datetime(
        title=_("Date last changed"),
        required=False,
        readonly=True,
        description=_("The date in which this membership was last changed."))

    last_change_comment = exported(
        Text(title=_("Comment on the last change"),
             required=False,
             readonly=True))
    proponent_comment = Text(title=_("Proponent comment"),
                             required=False,
                             readonly=True)
    acknowledger_comment = Text(title=_("Acknowledger comment"),
                                required=False,
                                readonly=True)
    reviewer_comment = Text(title=_("Reviewer comment"),
                            required=False,
                            readonly=True)
    status = exported(
        Choice(title=_("The state of this membership"),
               required=True,
               readonly=True,
               vocabulary=TeamMembershipStatus))

    def isExpired():
        """Return True if this membership's status is EXPIRED."""

    def canChangeExpirationDate(person):
        """Can the given person change this membership's expiration date?

        A membership's expiration date can be changed by the team owner, by a
        Launchpad admin or by a team admin. In the latter case, though, the
        expiration date can only be changed if the admin is not changing
        their own membership.
        """

    @call_with(user=REQUEST_USER)
    @operation_parameters(date=copy_field(dateexpires))
    @export_write_operation()
    def setExpirationDate(date, user):
        """Set this membership's expiration date.

        The given date must be None or in the future and the given user must
        be allowed to change this membership's expiration date as per the
        rules defined in canChangeExpirationDate().
        """

    def canBeRenewedByMember():
        """Can this membership be renewed by the member themselves?

        A membership can be renewed if the team's renewal policy is ONDEMAND,
        the membership itself is active (status = [ADMIN|APPROVED]) and it's
        set to expire in less than DAYS_BEFORE_EXPIRATION_WARNING_IS_SENT
        days.
        """

    def sendSelfRenewalNotification():
        """Send an email to the team admins notifying that this membership
        has been renewed by the member themselves.

        This method must not be called if the team's renewal policy is not
        ONDEMAND.
        """

    def sendExpirationWarningEmail():
        """Send the member an email warning that the membership will expire.

        This method cannot be called for memberships without an expiration
        date. Emails are not sent to members if their membership has already
        expired or if the member is no longer active.

        :raises AssertionError: if the member has no expiration date of the
            team or if the TeamMembershipRenewalPolicy is AUTOMATIC.
        """

    @call_with(user=REQUEST_USER)
    @operation_parameters(status=copy_field(status),
                          comment=copy_field(reviewer_comment),
                          silent=Bool(title=_(
                              "Do not send notifications of status change.  "
                              "For use by Launchpad administrators only."),
                                      required=False,
                                      default=False))
    @export_write_operation()
    def setStatus(status, user, comment=None, silent=False):
        """Set the status of this membership.
Esempio n. 35
0
class IPackagesetSet(IPackagesetSetEdit):
    """An interface for multiple package sets."""
    export_as_webservice_collection(IPackageset)

    @operation_parameters(name=copy_field(IPackageset['name']),
                          distroseries=copy_field(IPackageset['distroseries']))
    @operation_returns_entry(IPackageset)
    @export_read_operation()
    def getByName(distroseries, name):
        """Return the single package set with the given name (if any).

        :param distroseries: the distroseries to which the new packageset
            is related.
        :param name: the name of the package set sought.

        :return: An `IPackageset` instance.
        :raise NoSuchPackageSet: if no package set is found.
        """

    @collection_default_content()
    def get():
        """Return all of the package sets in Launchpad.

        :return: A (potentially empty) sequence of `IPackageset` instances.
        """

    def getByOwner(owner):
        """Return the package sets belonging to the given owner (if any).

        :param owner: the owner of the package sets sought.

        :return: A (potentially empty) sequence of `IPackageset` instances.
        """

    @operation_parameters(distroseries=copy_field(
        IPackageset['distroseries'],
        description=_("The distribution series to which the packagesets "
                      "are related.")))
    @operation_returns_collection_of(IPackageset)
    @export_read_operation()
    @operation_for_version("beta")
    def getBySeries(distroseries):
        """Return the package sets associated with the given distroseries.

        :param distroseries: A `DistroSeries`.

        :return: An iterable collection of `IPackageset` instances.
        """

    def getForPackages(distroseries, sourcepackagename_ids):
        """Get `Packagesets` that directly contain the given packages.

        :param distroseries: `DistroSeries` to look in.  Only packagesets for
            this series will be returned.
        :param sourcepackagename_ids: A sequence of `SourcePackageName` ids.
            Only packagesets for these package names will be returned.
        :return: A dict mapping `SourcePackageName` ids to lists of their
            respective packagesets, in no particular order.
        """

    @operation_parameters(sourcepackagename=TextLine(
        title=_('Source package name'), required=True),
                          distroseries=copy_field(IPackageset['distroseries'],
                                                  required=False),
                          direct_inclusion=Bool(required=False))
    @operation_returns_collection_of(IPackageset)
    @export_read_operation()
    def setsIncludingSource(sourcepackagename,
                            distroseries=None,
                            direct_inclusion=False):
        """Get the package sets that include this source package.
Esempio n. 36
0
from lp.bugs.interfaces.bugtasksearch import (
    BugBlueprintSearch,
    BugBranchSearch,
    BugTagsSearchCombinator,
    IBugTaskSearch,
    )
from lp.registry.enums import BugSharingPolicy
from lp.services.fields import Tag


search_tasks_params_common = {
    "order_by": List(
        title=_('List of fields by which the results are ordered.'),
        value_type=Text(),
        required=False),
    "search_text": copy_field(IBugTaskSearch['searchtext']),
    "status": copy_field(IBugTaskSearch['status']),
    "importance": copy_field(IBugTaskSearch['importance']),
    "information_type": copy_field(IBugTaskSearch['information_type']),
    "assignee": Reference(schema=Interface),
    "bug_reporter": Reference(schema=Interface),
    "bug_supervisor": Reference(schema=Interface),
    "bug_commenter": Reference(schema=Interface),
    "bug_subscriber": Reference(schema=Interface),
    "structural_subscriber": Reference(schema=Interface),
    "owner": Reference(schema=Interface),
    "affected_user": Reference(schema=Interface),
    "has_patch": copy_field(IBugTaskSearch['has_patch']),
    "has_cve": copy_field(IBugTaskSearch['has_cve']),
    "tags": copy_field(IBugTaskSearch['tag']),
    "tags_combinator": copy_field(IBugTaskSearch['tags_combinator']),