← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] lp:~cjwatson/launchpad/processors-for-everyone into lp:launchpad

 

Review: Approve code



Diff comments:

> 
> === modified file 'lib/lp/soyuz/configure.zcml'
> --- lib/lp/soyuz/configure.zcml	2015-09-21 19:21:57 +0000
> +++ lib/lp/soyuz/configure.zcml	2015-09-23 12:20:46 +0000
> @@ -365,7 +365,7 @@
>              permission="launchpad.Edit"
>              interface="lp.soyuz.interfaces.archive.IArchiveEdit"
>              set_attributes="build_debug_symbols description displayname
> -                            publish publish_debug_symbols status
> +                            processors publish publish_debug_symbols status

Should processors still be settable now that it's all behind setProcessors?

>                              suppress_subscription_notifications"/>
>          <!--
>             NOTE: The 'private' permission controls who can turn a public
> 
> === modified file 'lib/lp/soyuz/model/archive.py'
> --- lib/lp/soyuz/model/archive.py	2015-09-16 06:53:39 +0000
> +++ lib/lp/soyuz/model/archive.py	2015-09-23 12:20:46 +0000
> @@ -2129,23 +2131,60 @@
>          """See `IArchive`."""
>          self.processors = set(self.processors + [processor])
>  
> +    @property
> +    def available_processors(self):
> +        """See `IArchive`."""
> +        # Circular imports.
> +        from lp.registry.model.distroseries import DistroSeries
> +        from lp.soyuz.model.distroarchseries import DistroArchSeries
> +
> +        clauses = [
> +            Processor.id == DistroArchSeries.processor_id,
> +            DistroArchSeries.distroseriesID == DistroSeries.id,
> +            DistroSeries.distribution == self.distribution,
> +            ]
> +        if not self.permit_obsolete_series_uploads:
> +            clauses.append(DistroSeries.status != SeriesStatus.OBSOLETE)
> +        return Store.of(self).find(Processor, *clauses).config(
> +            distinct=(Processor.id,))

That's also just "distinct=True".

> +
>      def _getProcessors(self):
>          return list(Store.of(self).find(
>              Processor,
>              Processor.id == ArchiveArch.processor_id,
>              ArchiveArch.archive == self))
>  
> -    def setProcessors(self, processors):
> +    def setProcessors(self, processors, check_permissions=False, user=None):
>          """See `IArchive`."""
> +        if check_permissions:
> +            can_modify = None
> +            if user is not None:
> +                roles = IPersonRoles(user)
> +                authz = lambda perm: getAdapter(self, IAuthorization, perm)
> +                if authz('launchpad.Admin').checkAuthenticated(roles):
> +                    can_modify = lambda proc: True
> +                elif authz('launchpad.Edit').checkAuthenticated(roles):
> +                    can_modify = lambda proc: not proc.restricted
> +            if can_modify is None:
> +                raise Unauthorized(
> +                    'Permission launchpad.Admin or launchpad.Edit required '
> +                    'on %s.' % self)
> +        else:
> +            can_modify = lambda proc: True
> +
>          enablements = dict(Store.of(self).find(
>              (Processor, ArchiveArch),
>              Processor.id == ArchiveArch.processor_id,
>              ArchiveArch.archive == self))
>          for proc in enablements:
>              if proc not in processors:
> +                if not can_modify(proc):
> +                    raise CannotModifyArchiveProcessor(proc)
>                  Store.of(self).remove(enablements[proc])
>          for proc in processors:
>              if proc not in self.processors:
> +                if not can_modify(proc):
> +                    raise CannotModifyArchiveProcessor(proc)
>                  archivearch = ArchiveArch()
>                  archivearch.archive = self
>                  archivearch.processor = proc


-- 
https://code.launchpad.net/~cjwatson/launchpad/processors-for-everyone/+merge/272093
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.


References