def proposeGoal(self, goal, proposer):
     """See ISpecification."""
     if goal is None:
         # we are clearing goals
         self.productseries = None
         self.distroseries = None
     elif (IProductSeries.providedBy(goal) and
           goal.product == self.target):
         # set the product series as a goal
         self.productseries = goal
         self.goal_proposer = proposer
         self.date_goal_proposed = UTC_NOW
         # and make sure there is no leftover distroseries goal
         self.distroseries = None
     elif (IDistroSeries.providedBy(goal) and
           goal.distribution == self.target):
         # set the distroseries goal
         self.distroseries = goal
         self.goal_proposer = proposer
         self.date_goal_proposed = UTC_NOW
         # and make sure there is no leftover distroseries goal
         self.productseries = None
     else:
         raise GoalProposeError('Inappropriate goal.')
     # record who made the proposal, and when
     self.goal_proposer = proposer
     self.date_goal_proposed = UTC_NOW
     # and of course set the goal status to PROPOSED
     self.goalstatus = SpecificationGoalStatus.PROPOSED
     # the goal should now also not have a decider
     self.goal_decider = None
     self.date_goal_decided = None
     if goal is not None and goal.personHasDriverRights(proposer):
         self.acceptBy(proposer)
Exemple #2
0
 def milestone_row_uri_template(self):
     if IProductSeries.providedBy(self.context):
         pillar = self.context.product
     else:
         pillar = self.context.distribution
     uri = canonical_url(pillar, path_only_if_possible=True)
     return '%s/+milestone/{name}/+productseries-table-row' % uri
 def proposeGoal(self, goal, proposer):
     """See ISpecification."""
     if goal is None:
         # we are clearing goals
         self.productseries = None
         self.distroseries = None
     elif (IProductSeries.providedBy(goal) and goal.product == self.target):
         # set the product series as a goal
         self.productseries = goal
         self.goal_proposer = proposer
         self.date_goal_proposed = UTC_NOW
         # and make sure there is no leftover distroseries goal
         self.distroseries = None
     elif (IDistroSeries.providedBy(goal)
           and goal.distribution == self.target):
         # set the distroseries goal
         self.distroseries = goal
         self.goal_proposer = proposer
         self.date_goal_proposed = UTC_NOW
         # and make sure there is no leftover distroseries goal
         self.productseries = None
     else:
         raise GoalProposeError('Inappropriate goal.')
     # record who made the proposal, and when
     self.goal_proposer = proposer
     self.date_goal_proposed = UTC_NOW
     # and of course set the goal status to PROPOSED
     self.goalstatus = SpecificationGoalStatus.PROPOSED
     # the goal should now also not have a decider
     self.goal_decider = None
     self.date_goal_decided = None
     if goal is not None and goal.personHasDriverRights(proposer):
         self.acceptBy(proposer)
 def milestone_row_uri_template(self):
     if IProductSeries.providedBy(self.context):
         pillar = self.context.product
     else:
         pillar = self.context.distribution
     uri = canonical_url(pillar, path_only_if_possible=True)
     return '%s/+milestone/{name}/+productseries-table-row' % uri
Exemple #5
0
    def primary_translatable(self):
        """Return the context's primary translatable if it's a product series.
        """
        translatable = self.context.primary_translatable

        if not IProductSeries.providedBy(translatable):
            return None

        return translatable
Exemple #6
0
    def primary_translatable(self):
        """Return the context's primary translatable if it's a product series.
        """
        translatable = self.context.primary_translatable

        if not IProductSeries.providedBy(translatable):
            return None

        return translatable
def get_specification_active_product_filter(context):
    if (IDistribution.providedBy(context) or IDistroSeries.providedBy(context)
        or IProduct.providedBy(context) or IProductSeries.providedBy(context)):
        return [], []
    from lp.registry.model.product import Product
    tables = [
        LeftJoin(Product, Specification.productID == Product.id)]
    active_products = (
        Or(Specification.product == None, Product.active == True))
    return tables, [active_products]
Exemple #8
0
def get_specification_active_product_filter(context):
    if (IDistribution.providedBy(context) or IDistroSeries.providedBy(context)
            or IProduct.providedBy(context)
            or IProductSeries.providedBy(context)):
        return [], []
    from lp.registry.model.product import Product
    tables = [LeftJoin(Product, Specification.productID == Product.id)]
    active_products = (Or(Specification.product == None,
                          Product.active == True))
    return tables, [active_products]
Exemple #9
0
 def __init__(self, context=None):
     super(BranchRestrictedOnProductVocabulary, self).__init__(context)
     if IProduct.providedBy(self.context):
         self.product = self.context
     elif IProductSeries.providedBy(self.context):
         self.product = self.context.product
     elif IBranch.providedBy(self.context):
         self.product = self.context.product
     else:
         # An unexpected type.
         raise AssertionError('Unexpected context type')
Exemple #10
0
 def _getBugtasks(self, target, ignore_privacy=False):
     """Return the list `IBugTask`s associated with the target."""
     if IProductSeries.providedBy(target):
         params = BugTaskSearchParams(user=self.user)
         params.setProductSeries(target)
     else:
         params = BugTaskSearchParams(milestone=target,
                                      user=self.user,
                                      ignore_privacy=ignore_privacy)
     bugtasks = getUtility(IBugTaskSet).search(params)
     return list(bugtasks)
 def _getBugtasks(self, target, ignore_privacy=False):
     """Return the list `IBugTask`s associated with the target."""
     if IProductSeries.providedBy(target):
         params = BugTaskSearchParams(user=self.user)
         params.setProductSeries(target)
     else:
         params = BugTaskSearchParams(
             milestone=target, user=self.user,
             ignore_privacy=ignore_privacy)
     bugtasks = getUtility(IBugTaskSet).search(params)
     return list(bugtasks)
Exemple #12
0
 def __init__(self, context=None):
     super(BranchRestrictedOnProductVocabulary, self).__init__(context)
     if IProduct.providedBy(self.context):
         self.product = self.context
     elif IProductSeries.providedBy(self.context):
         self.product = self.context.product
     elif IBranch.providedBy(self.context):
         self.product = self.context.product
     else:
         # An unexpected type.
         raise AssertionError('Unexpected context type')
def milestone_matches_bugtask(milestone, bugtask):
    """ Return True if the milestone can be set against this bugtask."""
    bug_target = bugtask.target
    naked_milestone = removeSecurityProxy(milestone)

    if IProduct.providedBy(bug_target):
        return bugtask.product.id == naked_milestone.productID
    elif IProductSeries.providedBy(bug_target):
        return bugtask.productseries.product.id == naked_milestone.productID
    elif (IDistribution.providedBy(bug_target)
          or IDistributionSourcePackage.providedBy(bug_target)):
        return bugtask.distribution.id == naked_milestone.distributionID
    elif (IDistroSeries.providedBy(bug_target)
          or ISourcePackage.providedBy(bug_target)):
        return bugtask.distroseries.id == naked_milestone.distroseriesID
    return False
def milestone_matches_bugtask(milestone, bugtask):
    """ Return True if the milestone can be set against this bugtask."""
    bug_target = bugtask.target
    naked_milestone = removeSecurityProxy(milestone)

    if IProduct.providedBy(bug_target):
        return bugtask.product.id == naked_milestone.productID
    elif IProductSeries.providedBy(bug_target):
        return bugtask.productseries.product.id == naked_milestone.productID
    elif (IDistribution.providedBy(bug_target) or
          IDistributionSourcePackage.providedBy(bug_target)):
        return bugtask.distribution.id == naked_milestone.distributionID
    elif (IDistroSeries.providedBy(bug_target) or
          ISourcePackage.providedBy(bug_target)):
        return bugtask.distroseries.id == naked_milestone.distroseriesID
    return False
Exemple #15
0
    def setTarget(self, target):
        """Constrain the search to only return items in target.

        This is equivalent to calling setProduct etc but the type of target
        does not need to be known to the caller.

        :param target: A `IHasBug`, or some search term like all/any/none on
            `IHasBug`. If using all/any all the targets must be of the
            same type due to implementation limitations. Currently only
            distroseries and productseries `IHasBug` implementations are
            supported.
        """
        # Yay circular deps.
        from lp.registry.interfaces.distribution import IDistribution
        from lp.registry.interfaces.distroseries import IDistroSeries
        from lp.registry.interfaces.product import IProduct
        from lp.registry.interfaces.productseries import IProductSeries
        from lp.registry.interfaces.milestone import IMilestone
        from lp.registry.interfaces.projectgroup import IProjectGroup
        from lp.registry.interfaces.sourcepackage import ISourcePackage
        from lp.registry.interfaces.distributionsourcepackage import \
            IDistributionSourcePackage
        if isinstance(target, (any, all)):
            assert len(target.query_values), \
                'cannot determine target with no targets'
            instance = target.query_values[0]
        else:
            instance = target
        if IDistribution.providedBy(instance):
            self.setDistribution(target)
        elif IDistroSeries.providedBy(instance):
            self.setDistroSeries(target)
        elif IProduct.providedBy(instance):
            self.setProduct(target)
        elif IProductSeries.providedBy(instance):
            self.setProductSeries(target)
        elif IMilestone.providedBy(instance):
            self.milestone = target
        elif ISourcePackage.providedBy(instance):
            self.setSourcePackage(target)
        elif IDistributionSourcePackage.providedBy(instance):
            self.setSourcePackage(target)
        elif IProjectGroup.providedBy(instance):
            self.setProjectGroup(target)
        else:
            raise AssertionError("unknown target type %r" % target)
    def setTarget(self, target):
        """Constrain the search to only return items in target.

        This is equivalent to calling setProduct etc but the type of target
        does not need to be known to the caller.

        :param target: A `IHasBug`, or some search term like all/any/none on
            `IHasBug`. If using all/any all the targets must be of the
            same type due to implementation limitations. Currently only
            distroseries and productseries `IHasBug` implementations are
            supported.
        """
        # Yay circular deps.
        from lp.registry.interfaces.distribution import IDistribution
        from lp.registry.interfaces.distroseries import IDistroSeries
        from lp.registry.interfaces.product import IProduct
        from lp.registry.interfaces.productseries import IProductSeries
        from lp.registry.interfaces.milestone import IMilestone
        from lp.registry.interfaces.projectgroup import IProjectGroup
        from lp.registry.interfaces.sourcepackage import ISourcePackage
        from lp.registry.interfaces.distributionsourcepackage import \
            IDistributionSourcePackage
        if isinstance(target, (any, all)):
            assert len(target.query_values), \
                'cannot determine target with no targets'
            instance = target.query_values[0]
        else:
            instance = target
        if IDistribution.providedBy(instance):
            self.setDistribution(target)
        elif IDistroSeries.providedBy(instance):
            self.setDistroSeries(target)
        elif IProduct.providedBy(instance):
            self.setProduct(target)
        elif IProductSeries.providedBy(instance):
            self.setProductSeries(target)
        elif IMilestone.providedBy(instance):
            self.milestone = target
        elif ISourcePackage.providedBy(instance):
            self.setSourcePackage(target)
        elif IDistributionSourcePackage.providedBy(instance):
            self.setSourcePackage(target)
        elif IProjectGroup.providedBy(instance):
            self.setProject(target)
        else:
            raise AssertionError("unknown target type %r" % target)
Exemple #17
0
    def __init__(self, context):
        StandardLaunchpadFacets.__init__(self, context)
        target = context.translationtarget
        if IProductSeries.providedBy(target):
            self._is_product_series = True
            self.target_facets = ProductSeriesFacets(target)
        elif ISourcePackage.providedBy(target):
            self._is_product_series = False
            self.target_facets = SourcePackageFacets(target)
        else:
            # We don't know yet how to handle this target.
            raise NotImplementedError

        # Enable only the menus that the translation target uses.
        self.enable_only = self.target_facets.enable_only

        # From an IPOTemplate URL, we reach its translationtarget (either
        # ISourcePackage or IProductSeries using self.target.
        self.target = '../../'
    def __init__(self, context):
        StandardLaunchpadFacets.__init__(self, context)
        target = context.translationtarget
        if IProductSeries.providedBy(target):
            self._is_product_series = True
            self.target_facets = ProductSeriesFacets(target)
        elif ISourcePackage.providedBy(target):
            self._is_product_series = False
            self.target_facets = SourcePackageFacets(target)
        else:
            # We don't know yet how to handle this target.
            raise NotImplementedError

        # Enable only the menus that the translation target uses.
        self.enable_only = self.target_facets.enable_only

        # From an IPOTemplate URL, we reach its translationtarget (either
        # ISourcePackage or IProductSeries using self.target.
        self.target = '../../'
    def _getShortRequestName(self, request):
        """Return a short request name for use in email subjects."""
        if IPOFile.providedBy(request):
            title = '%s translation of %s' % (
                request.language.englishname,
                request.potemplate.name)
            productseries = request.potemplate.productseries
            distroseries = request.potemplate.distroseries
            sourcepackagename = request.potemplate.sourcepackagename
        elif IPOTemplate.providedBy(request):
            title = '%s template' % (request.name)
            productseries = request.productseries
            distroseries = request.distroseries
            sourcepackagename = request.sourcepackagename
        elif IProductSeries.providedBy(request):
            title = None
            productseries = request
            distroseries = None
            sourcepackagename = None
        elif ISourcePackage.providedBy(request):
            title = None
            productseries = None
            distroseries = request.distroseries
            sourcepackagename = request.sourcepackagename
        else:
            raise AssertionError(
                "We can not figure out short name for this translation "
                "export origin.")

        if productseries is not None:
            root = '%s %s' % (
                productseries.product.displayname,
                productseries.name)
        else:
            root = '%s %s %s' % (
                distroseries.distribution.displayname,
                distroseries.displayname,
                sourcepackagename.name)
        if title is not None:
            return '%s - %s' % (root, title)
        else:
            return root
Exemple #20
0
    def _getByName(self, version):
        """Return the content object for the specified version.

        The version is specified either by the context directly or by the
        context's referenced productseries.  Overridden from
        `ContentFieldName`.
        """
        # Import locally to avoid circular imports.
        from lp.registry.interfaces.productseries import (
            IProductSeries)
        if IProductSeries.providedBy(self.context):
            productseries = self.context
        else:
            productseries = self.context.productseries
        releaseset = getUtility(IProductReleaseSet)
        release = releaseset.getBySeriesAndVersion(productseries, version)
        if release == self.context:
            # A ProductRelease may edit itself; do not report that another
            # ProductRelease exists with the same version.
            return None
        return release
Exemple #21
0
 def _getByName(self, name):
     """Return the named milestone from the context."""
     # IProductSeries and IDistroSeries are imported here to
     # avoid an import loop.
     from lp.registry.interfaces.productseries import (IProductSeries)
     from lp.registry.interfaces.distroseries import IDistroSeries
     if IMilestone.providedBy(self.context):
         milestone = self.context.target.getMilestone(name)
     elif IProductSeries.providedBy(self.context):
         milestone = self.context.product.getMilestone(name)
     elif IDistroSeries.providedBy(self.context):
         milestone = self.context.distribution.getMilestone(name)
     else:
         raise AssertionError(
             'Editing a milestone in an unexpected context: %r' %
             self.context)
     if milestone is not None:
         self.errormessage = _(
             "The name %%s is already used by a milestone in %s." %
             milestone.target.displayname)
     return milestone
Exemple #22
0
    def branch_deletion_actions(self):
        """Return the branch deletion actions as a zpt-friendly dict.

        The keys are 'delete' and 'alter'; the values are dicts of
        'item', 'reason' and 'allowed'.
        """
        row_dict = {'delete': [], 'alter': [], 'break_link': []}
        for item, action, reason, allowed in (
            self.display_deletion_requirements):
            if IBugBranch.providedBy(item):
                action = 'break_link'
            elif ISpecificationBranch.providedBy(item):
                action = 'break_link'
            elif IProductSeries.providedBy(item):
                action = 'break_link'
            row = {'item': item,
                   'reason': reason,
                   'allowed': allowed,
                  }
            row_dict[action].append(row)
        return row_dict
 def _getByName(self, name):
     """Return the named milestone from the context."""
     # IProductSeries and IDistroSeries are imported here to
     # avoid an import loop.
     from lp.registry.interfaces.productseries import (
         IProductSeries)
     from lp.registry.interfaces.distroseries import IDistroSeries
     if IMilestone.providedBy(self.context):
         milestone = self.context.target.getMilestone(name)
     elif IProductSeries.providedBy(self.context):
         milestone = self.context.product.getMilestone(name)
     elif IDistroSeries.providedBy(self.context):
         milestone = self.context.distribution.getMilestone(name)
     else:
         raise AssertionError(
             'Editing a milestone in an unexpected context: %r'
             % self.context)
     if milestone is not None:
         self.errormessage = _(
             "The name %%s is already used by a milestone in %s."
             % milestone.target.displayname)
     return milestone
    def _getShortRequestName(self, request):
        """Return a short request name for use in email subjects."""
        if IPOFile.providedBy(request):
            title = '%s translation of %s' % (request.language.englishname,
                                              request.potemplate.name)
            productseries = request.potemplate.productseries
            distroseries = request.potemplate.distroseries
            sourcepackagename = request.potemplate.sourcepackagename
        elif IPOTemplate.providedBy(request):
            title = '%s template' % (request.name)
            productseries = request.productseries
            distroseries = request.distroseries
            sourcepackagename = request.sourcepackagename
        elif IProductSeries.providedBy(request):
            title = None
            productseries = request
            distroseries = None
            sourcepackagename = None
        elif ISourcePackage.providedBy(request):
            title = None
            productseries = None
            distroseries = request.distroseries
            sourcepackagename = request.sourcepackagename
        else:
            raise AssertionError(
                "We can not figure out short name for this translation "
                "export origin.")

        if productseries is not None:
            root = '%s %s' % (productseries.product.displayname,
                              productseries.name)
        else:
            root = '%s %s %s' % (distroseries.distribution.displayname,
                                 distroseries.displayname,
                                 sourcepackagename.name)
        if title is not None:
            return '%s - %s' % (root, title)
        else:
            return root
    def initialize(self):
        if IPerson.providedBy(self.context):
            self.is_person = True
        elif IDistribution.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.show_series = True
        elif IProduct.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_series = True
        elif IProjectGroup.providedBy(self.context):
            self.is_project = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_target = True
            self.show_series = True
        elif IProjectGroupSeries.providedBy(self.context):
            self.show_milestone = True
            self.show_target = True
            self.show_series = True
        elif (IProductSeries.providedBy(self.context) or
              IDistroSeries.providedBy(self.context)):
            self.is_series = True
            self.show_milestone = True
        elif ISprint.providedBy(self.context):
            self.is_sprint = True
            self.show_target = True
        else:
            raise AssertionError('Unknown blueprint listing site.')

        if IHasDrivers.providedBy(self.context):
            self.has_drivers = True

        self.batchnav = BatchNavigator(
            self.specs, self.request,
            size=config.launchpad.default_batch_size)
    def initialize(self):
        if IPerson.providedBy(self.context):
            self.is_person = True
        elif IDistribution.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.show_series = True
        elif IProduct.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_series = True
        elif IProjectGroup.providedBy(self.context):
            self.is_project = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_target = True
            self.show_series = True
        elif IProjectGroupSeries.providedBy(self.context):
            self.show_milestone = True
            self.show_target = True
            self.show_series = True
        elif (IProductSeries.providedBy(self.context)
              or IDistroSeries.providedBy(self.context)):
            self.is_series = True
            self.show_milestone = True
        elif ISprint.providedBy(self.context):
            self.is_sprint = True
            self.show_target = True
        else:
            raise AssertionError('Unknown blueprint listing site.')

        if IHasDrivers.providedBy(self.context):
            self.has_drivers = True

        self.batchnav = BatchNavigator(
            self.specs, self.request, size=config.launchpad.default_batch_size)
Exemple #27
0
 def driver_title(self):
     """The title of the driver."""
     if IProductSeries.providedBy(self.context):
         return "release manager"
     else:
         return 'driver'