~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/browser/archive.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-07-20 14:43:58 UTC
  • mfrom: (11065.6.5 394798-auto-buildd-secret)
  • Revision ID: launchpad@pqm.canonical.com-20100720144358-zr74x6m7bpb54o7f
[r=leonardr][ui=none][bug=394798] Generate buildd_secret when none is
        specified and an archive is being make secret.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
from canonical.cachedproperty import cachedproperty
48
48
from canonical.launchpad import _
 
49
from canonical.launchpad.components.tokens import create_token
49
50
from canonical.launchpad.helpers import english_list
50
51
from canonical.lazr.utils import smartquote
51
52
from lp.buildmaster.interfaces.buildbase import BuildStatus
1877
1878
 
1878
1879
    custom_widget('enabled_restricted_families', LabeledMultiCheckBoxWidget)
1879
1880
 
 
1881
    def updateContextFromData(self, data):
 
1882
        """Update context from form data.
 
1883
 
 
1884
        If the user did not specify a buildd secret but marked the 
 
1885
        archive as private, generate a secret for them.
 
1886
        """
 
1887
        if data['private'] and data['buildd_secret'] is None:
 
1888
            # buildd secrets are only used by builders, autogenerate one.
 
1889
            self.context.buildd_secret = create_token(16)
 
1890
            del(data['buildd_secret'])
 
1891
        super(ArchiveAdminView, self).updateContextFromData(data)
 
1892
 
1880
1893
    def validate_save(self, action, data):
1881
1894
        """Validate the save action on ArchiveAdminView.
1882
1895
 
1883
 
        buildd_secret can only be set, and must be set, when
1884
 
        this is a private archive.
 
1896
        buildd_secret can only, and must, be set for private archives.
 
1897
        If the archive is private and the buildd secret is not set it will be
 
1898
        generated.
1885
1899
        """
1886
1900
        form.getWidgetsData(self.widgets, 'field', data)
1887
1901
 
1893
1907
                    'This archive already has published sources. It is '
1894
1908
                    'not possible to switch the privacy.')
1895
1909
 
1896
 
        if data.get('buildd_secret') is None and data['private']:
1897
 
            self.setFieldError(
1898
 
                'buildd_secret',
1899
 
                'Required for private archives.')
1900
 
 
1901
1910
        if self.owner_is_private_team and not data['private']:
1902
1911
            self.setFieldError(
1903
1912
                'private',