317
316
@stepthrough('+subscriptions')
318
317
def traverse_subscription(self, person_name):
319
person = getUtility(IPersonSet).getByName(person_name)
319
person = getUtility(IPersonSet).getByName(person_name)
320
except NotFoundError:
323
323
subscriptions = getUtility(IArchiveSubscriberSet).getBySubscriber(
2033
2033
return 'Edit %s' % self.context.displayname
2036
class EnableRestrictedFamiliesMixin:
2037
"""A mixin that provides enabled_restricted_families field support"""
2039
def createEnabledRestrictedFamilies(self, description=None):
2040
"""Creates the 'enabled_restricted_families' field.
2044
for family in getUtility(IProcessorFamilySet).getRestricted():
2045
terms.append(SimpleTerm(
2046
family, token=family.name, title=family.title))
2047
old_field = IArchive['enabled_restricted_families']
2049
List(__name__=old_field.__name__,
2050
title=old_field.title,
2051
value_type=Choice(vocabulary=SimpleVocabulary(terms)),
2053
description=old_field.description if description is None
2055
render_context=self.render_context)
2057
def validate_enabled_restricted_families(self, data, error_msg):
2058
enabled_restricted_families = data['enabled_restricted_families']
2059
require_virtualized = data.get('require_virtualized', False)
2060
proc_family_set = getUtility(IProcessorFamilySet)
2061
if (not require_virtualized and
2062
set(enabled_restricted_families) !=
2063
set(proc_family_set.getRestricted())):
2064
self.setFieldError('enabled_restricted_families', error_msg)
2065
self.setFieldError('require_virtualized', error_msg)
2068
ARCHIVE_ENABLED_RESTRICTED_FAMILITES_ERROR_MSG = (
2069
u'Main archives can not be restricted to certain '
2070
'architectures unless they are set to build on '
2071
'virtualized builders.')
2074
class ArchiveAdminView(BaseArchiveEditView, EnableRestrictedFamiliesMixin):
2036
class ArchiveAdminView(BaseArchiveEditView):
2076
2038
field_names = ['enabled', 'private', 'commercial', 'require_virtualized',
2077
2039
'build_debug_symbols', 'buildd_secret', 'authorized_size',
2136
2098
'Can only set commericial for private archives.')
2138
enabled_restricted_families = data.get('enabled_restricted_families')
2139
require_virtualized = data.get('require_virtualized')
2140
proc_family_set = getUtility(IProcessorFamilySet)
2141
if (enabled_restricted_families and
2142
not require_virtualized and
2143
set(enabled_restricted_families) !=
2144
set(proc_family_set.getRestricted())):
2146
'enabled_restricted_families',
2147
ARCHIVE_ENABLED_RESTRICTED_FAMILITES_ERROR_MSG)
2149
'require_virtualized',
2150
ARCHIVE_ENABLED_RESTRICTED_FAMILITES_ERROR_MSG)
2153
2101
def owner_is_private_team(self):
2154
2102
"""Is the owner a private team?
2159
2107
return self.context.owner.visibility == PersonVisibility.PRIVATE
2162
def initial_values(self):
2164
'enabled_restricted_families':
2165
self.context.enabled_restricted_families,
2168
2109
def setUpFields(self):
2169
2110
"""Override `LaunchpadEditFormView`.
2173
2114
super(ArchiveAdminView, self).setUpFields()
2174
2115
self.form_fields += self.createEnabledRestrictedFamilies()
2117
def createEnabledRestrictedFamilies(self):
2118
"""Creates the 'enabled_restricted_families' field.
2122
for family in getUtility(IProcessorFamilySet).getRestricted():
2123
terms.append(SimpleTerm(
2124
family, token=family.name, title=family.title))
2125
old_field = IArchive['enabled_restricted_families']
2127
List(__name__=old_field.__name__,
2128
title=old_field.title,
2129
value_type=Choice(vocabulary=SimpleVocabulary(terms)),
2131
description=old_field.description),
2132
render_context=self.render_context)
2177
2135
class ArchiveDeleteView(LaunchpadFormView):
2178
2136
"""View class for deleting `IArchive`s"""