2033
2034
return 'Edit %s' % self.context.displayname
2036
class ArchiveAdminView(BaseArchiveEditView):
2037
class EnableRestrictedFamiliesMixin:
2038
"""A mixin that provides enabled_restricted_families field support"""
2040
def createEnabledRestrictedFamilies(self, description=None):
2041
"""Creates the 'enabled_restricted_families' field.
2045
for family in getUtility(IProcessorFamilySet).getRestricted():
2046
terms.append(SimpleTerm(
2047
family, token=family.name, title=family.title))
2048
old_field = IArchive['enabled_restricted_families']
2050
List(__name__=old_field.__name__,
2051
title=old_field.title,
2052
value_type=Choice(vocabulary=SimpleVocabulary(terms)),
2054
description=old_field.description if description is None
2056
render_context=self.render_context)
2058
def validate_enabled_restricted_families(self, data, error_msg):
2059
enabled_restricted_families = data['enabled_restricted_families']
2060
require_virtualized = data.get('require_virtualized', False)
2061
proc_family_set = getUtility(IProcessorFamilySet)
2062
if (not require_virtualized and
2063
set(enabled_restricted_families) !=
2064
set(proc_family_set.getRestricted())):
2065
self.setFieldError('enabled_restricted_families', error_msg)
2066
self.setFieldError('require_virtualized', error_msg)
2069
class ArchiveAdminView(BaseArchiveEditView, EnableRestrictedFamiliesMixin):
2038
2071
field_names = ['enabled', 'private', 'commercial', 'require_virtualized',
2039
2072
'build_debug_symbols', 'buildd_secret', 'authorized_size',
2098
2131
'Can only set commericial for private archives.')
2133
enabled_restricted_families = data.get('enabled_restricted_families')
2134
if (enabled_restricted_families and
2135
not self.context.canSetEnabledRestrictedFamilies(
2136
enabled_restricted_families)):
2138
'enabled_restricted_families',
2139
'Main archives can not be restricted to certain '
2140
'architectures unless they are set to build on '
2141
'virtualized builders.')
2101
2144
def owner_is_private_team(self):
2102
2145
"""Is the owner a private team?
2107
2150
return self.context.owner.visibility == PersonVisibility.PRIVATE
2153
def initial_values(self):
2155
'enabled_restricted_families':
2156
self.context.enabled_restricted_families,
2109
2159
def setUpFields(self):
2110
2160
"""Override `LaunchpadEditFormView`.
2114
2164
super(ArchiveAdminView, self).setUpFields()
2115
2165
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)
2135
2168
class ArchiveDeleteView(LaunchpadFormView):
2136
2169
"""View class for deleting `IArchive`s"""