launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01689
[Merge] lp:~stevenk/launchpad/create-ppas-via-api into lp:launchpad/devel
Steve Kowalik has proposed merging lp:~stevenk/launchpad/create-ppas-via-api into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
--
https://code.launchpad.net/~stevenk/launchpad/create-ppas-via-api/+merge/39378
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/create-ppas-via-api into lp:launchpad/devel.
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2010-10-16 15:09:47 +0000
+++ lib/lp/soyuz/browser/archive.py 2010-10-26 15:26:24 +0000
@@ -1813,22 +1813,9 @@
'The default PPA is already activated. Please specify a '
'name for the new PPA and resubmit the form.')
- # XXX cprov 2009-03-27 bug=188564: We currently only create PPAs
- # for Ubuntu distribution. This check should be revisited when we
- # start supporting PPAs for other distribution (debian, mainly).
- if proposed_name is not None and proposed_name == self.ubuntu.name:
- self.setFieldError(
- 'name',
- "Archives cannot have the same name as its distribution.")
-
- try:
- self.context.getPPAByName(proposed_name)
- except NoSuchPPA:
- pass
- else:
- self.setFieldError(
- 'name',
- "You already have a PPA named '%s'." % proposed_name)
+ errors = getUtility(IArchive).validatePPAName(proposed_name)
+ if errors is not None:
+ self.setFieldError('name', errors)
if default_ppa is None and not data.get('accepted'):
self.setFieldError(
@@ -1847,11 +1834,9 @@
# XXX cprov 2009-03-27 bug=188564: We currently only create PPAs
# for Ubuntu distribution. PPA creation should be revisited when we
# start supporting other distribution (debian, mainly).
- ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
-
ppa = getUtility(IArchiveSet).new(
owner=self.context, purpose=ArchivePurpose.PPA,
- distribution=ubuntu, name=name,
+ distribution=self.ubuntu, name=name,
displayname=data['displayname'], description=data['description'])
self.next_url = canonical_url(ppa)
=== modified file 'lib/lp/soyuz/interfaces/archive.py'
--- lib/lp/soyuz/interfaces/archive.py 2010-08-23 16:51:11 +0000
+++ lib/lp/soyuz/interfaces/archive.py 2010-10-26 15:26:24 +0000
@@ -889,6 +889,11 @@
def getPackageDownloadTotal(bpr):
"""Get the total download count for a given package."""
+ def validatePPAName(proposed_name):
+ """Return if a proposed name for a PPA is valid.
+
+ :param proposed_name: A String identifying the proposed PPA name.
+ """
class IArchiveView(IHasBuildRecords):
"""Archive interface for operations restricted by view privilege."""
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2010-10-24 12:46:23 +0000
+++ lib/lp/soyuz/model/archive.py 2010-10-26 15:26:24 +0000
@@ -2139,3 +2139,16 @@
)
return results.order_by(SourcePackagePublishingHistory.id)
+
+ @classmethod
+ def validatePPAName(self, proposed_name):
+ ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
+ if proposed_name is not None and proposed_name == ubuntu.name:
+ return (
+ "Archives cannot have the same name as its distribution.")
+ try:
+ self.getPPAByName(proposed_name)
+ except NoSuchPPA:
+ return None
+ else:
+ return "You already have a PPA named '%s'." % proposed_name
Follow ups