55
58
from zope.component import getUtility
59
from zope.event import notify
56
60
from zope.interface import (
60
65
from zope.security.proxy import (
61
66
isinstance as zope_isinstance,
263
268
raise IllegalRelatedBugTasksParams(
264
269
('Cannot search for related tasks to \'%s\', at least one '
265
270
'of these parameter has to be empty: %s'
266
%(context.name, ", ".join(relevant_fields))))
271
% (context.name, ", ".join(relevant_fields))))
267
272
return search_params
814
819
raise ValueError('Unknown debbugs severity "%s".' % severity)
815
820
return self.importance
822
# START TEMPORARY BIT FOR BUGTASK AUTOCONFIRM FEATURE FLAG.
823
_parse_launchpad_names = re.compile(r"[a-z0-9][a-z0-9\+\.\-]+").findall
825
def _checkAutoconfirmFeatureFlag(self):
826
"""Does a feature flag enable automatic switching of our bugtasks?"""
827
# This method should be ripped out if we determine that we like
828
# this behavior for all projects.
829
# This is a bit of a feature flag hack, but has been discussed as
830
# a reasonable way to deploy this quickly.
832
if IDistribution.providedBy(pillar):
833
flag_name = 'bugs.autoconfirm.enabled_distribution_names'
835
assert IProduct.providedBy(pillar), 'unexpected pillar'
836
flag_name = 'bugs.autoconfirm.enabled_product_names'
837
enabled = features.getFeatureFlag(flag_name)
840
if (enabled.strip() != '*' and
841
pillar.name not in self._parse_launchpad_names(enabled)):
842
# We are not generically enabled ('*') and our pillar's name
843
# is not explicitly enabled.
846
# END TEMPORARY BIT FOR BUGTASK AUTOCONFIRM FEATURE FLAG.
848
def maybeConfirm(self):
849
"""Maybe confirm this bugtask.
850
Only call this if the bug._shouldConfirmBugtasks().
851
This adds the further constraint that the bugtask needs to be NEW,
852
and not imported from an external bug tracker.
854
if (self.status == BugTaskStatus.NEW
855
and self.bugwatch is None
856
# START TEMPORARY BIT FOR BUGTASK AUTOCONFIRM FEATURE FLAG.
857
and self._checkAutoconfirmFeatureFlag()
858
# END TEMPORARY BIT FOR BUGTASK AUTOCONFIRM FEATURE FLAG.
860
user = getUtility(ILaunchpadCelebrities).janitor
861
bugtask_before_modification = Snapshot(
862
self, providing=providedBy(self))
863
self.transitionToStatus(BugTaskStatus.CONFIRMED, user)
864
notify(ObjectModifiedEvent(
865
self, bugtask_before_modification, ['status'], user=user))
817
867
def canTransitionToStatus(self, new_status, user):
818
868
"""See `IBugTask`."""
819
869
celebrities = getUtility(ILaunchpadCelebrities)
1079
1129
if self.target != target_before_change:
1080
1130
target_before_change.recalculateBugHeatCache()
1081
1131
self.target.recalculateBugHeatCache()
1132
# START TEMPORARY BIT FOR BUGTASK AUTOCONFIRM FEATURE FLAG.
1133
# We also should see if we ought to auto-transition to the
1135
if self.bug.shouldConfirmBugtasks():
1137
# END TEMPORARY BIT FOR BUGTASK AUTOCONFIRM FEATURE FLAG.
1083
1139
def updateTargetNameCache(self, newtarget=None):
1084
1140
"""See `IBugTask`."""
1895
1950
% sqlvalues(params.structural_subscriber))
1896
1951
has_duplicate_results = True
1899
1953
# Remove bugtasks from deactivated products, if necessary.
1900
1954
# We don't have to do this if
1901
1955
# 1) We're searching on bugtasks for a specific product
2565
2620
"SELECT team from TeamParticipation WHERE person=?)",
2567
# Note that because admins can see every bug regardless of subscription
2568
# they will see rather inflated counts. Admins get to deal.
2622
# Note that because admins can see every bug regardless of
2623
# subscription they will see rather inflated counts. Admins get to
2569
2625
if user is None:
2570
2626
conditions.append(BugSummary.viewed_by_id == None)
2571
2627
elif not user.inTeam(admin_team):
2572
2628
conditions.append(
2574
2630
BugSummary.viewed_by_id == None,
2575
BugSummary.viewed_by_id.is_in(SQL("SELECT team FROM teams"))
2631
BugSummary.viewed_by_id.is_in(
2632
SQL("SELECT team FROM teams"))
2577
2634
sum_count = Sum(BugSummary.count)
2578
2635
resultset = store.find(group_on + (sum_count,), *conditions)
3199
3256
product_ids.add(task.productID)
3200
3257
product_series_ids.add(task.productseriesID)
3202
distro_ids.discard(None)
3203
distro_series_ids.discard(None)
3204
product_ids.discard(None)
3205
product_series_ids.discard(None)
3259
distro_ids.discard(None)
3260
distro_series_ids.discard(None)
3261
product_ids.discard(None)
3262
product_series_ids.discard(None)
3207
3264
milestones = store.find(