def delete_not_possible_reasons(self): """A list of reasons why the context cannot be deleted. An empty list means that there are no reasons, so the delete can go ahead. """ reasons = [] celebrities = getUtility(ILaunchpadCelebrities) # We go through all of the conditions why the bug tracker # can't be deleted, and record reasons for all of them. We do # this so that users can discover the logic behind the # decision, and try something else, seek help, or give up as # appropriate. Just showing the first problem would stop users # from being able to help themselves. # Check that no products or projects use this bugtracker. pillars = ( getUtility(IBugTrackerSet).getPillarsForBugtrackers( [self.context]).get(self.context, [])) if len(pillars) > 0: reasons.append( 'This is the bug tracker for %s.' % english_list( sorted(pillar.title for pillar in pillars))) # Only admins and registry experts can delete bug watches en # masse. if not self.context.watches.is_empty(): admin_teams = [celebrities.admin, celebrities.registry_experts] for team in admin_teams: if self.user.inTeam(team): break else: reasons.append( 'There are linked bug watches and only members of %s ' 'can delete them en masse.' % english_list( sorted(team.title for team in admin_teams))) # Bugtrackers with imported messages cannot be deleted. if not self.context.imported_bug_messages.is_empty(): reasons.append( 'Bug comments have been imported via this bug tracker.') # If the bugtracker is a celebrity then we protect it from # deletion. celebrities_set = set( getattr(celebrities, name) for name in ILaunchpadCelebrities.names()) if self.context in celebrities_set: reasons.append( 'This bug tracker is protected from deletion.') return reasons
def _get_person_celebrities(self, is_team): for name in ILaunchpadCelebrities.names(): attr = getattr(self.celebs, name) if IPerson.providedBy(attr) and attr.is_team == is_team: yield (name, attr)