463
477
def milestone_batch_navigator(self):
464
478
return BatchNavigator(self.context.all_milestones, self.request)
466
def _num_differences(self, difference_type):
467
differences = getUtility(
468
IDistroSeriesDifferenceSource).getForDistroSeries(
470
difference_type=difference_type,
471
status=(DistroSeriesDifferenceStatus.NEEDS_ATTENTION,))
480
def countDifferences(self, difference_type, needing_attention_only=True):
481
"""Count the number of differences of a given kind.
483
:param difference_type: Type of `DistroSeriesDifference` to look for.
484
:param needing_attention_only: Restrict count to differences that need
485
attention? If not, count all that can be viewed.
487
if needing_attention_only:
488
status = (DistroSeriesDifferenceStatus.NEEDS_ATTENTION, )
492
differences = get_dsd_source().getForDistroSeries(
493
self.context, difference_type=difference_type, status=status)
472
494
return differences.count()
475
def num_differences(self):
476
return self._num_differences(
497
def num_version_differences_needing_attention(self):
498
return self.countDifferences(
477
499
DistroSeriesDifferenceType.DIFFERENT_VERSIONS)
502
def num_version_differences(self):
503
return self.countDifferences(
504
DistroSeriesDifferenceType.DIFFERENT_VERSIONS,
505
needing_attention_only=False)
507
def wordVersionDifferences(self):
508
return word_differences_count(self.num_version_differences)
480
511
def num_differences_in_parent(self):
481
return self._num_differences(
512
return self.countDifferences(
482
513
DistroSeriesDifferenceType.MISSING_FROM_DERIVED_SERIES)
515
def wordDifferencesInParent(self):
516
return word_differences_count(self.num_differences_in_parent)
485
519
def num_differences_in_child(self):
486
return self._num_differences(
520
return self.countDifferences(
487
521
DistroSeriesDifferenceType.UNIQUE_TO_DERIVED_SERIES)
523
def wordDifferencesInChild(self):
524
return word_differences_count(self.num_differences_in_child)
526
def alludeToParent(self):
527
"""Wording to refer to the series' parent(s).
529
If there is a single parent, returns its display name. Otherwise
530
says "a parent series" (more vague, but we could also name parents
531
if there are very few).
533
if self.has_unique_parent:
534
return self.unique_parent.displayname
536
return "a parent series"
539
def link_to_version_diffs_needing_attention(self):
540
"""Return URL for +localpackagediffs page."""
541
return canonical_url(self.context, view_name='+localpackagediffs')
544
def link_to_all_version_diffs(self):
545
"""Return URL for +localdiffs page for all statuses."""
547
"%s?field.package_type=all"
548
% self.link_to_version_diffs_needing_attention)
551
def link_to_differences_in_parent(self):
552
"""Return URL for +missingpackages page."""
553
return canonical_url(self.context, view_name='+missingpackages')
556
def link_to_differences_in_child(self):
557
"""Return URL for +uniquepackages page."""
558
return canonical_url(self.context, view_name='+uniquepackages')
490
561
class DistroSeriesEditView(LaunchpadEditFormView, SeriesStatusMixin):
491
562
"""View class that lets you edit a DistroSeries object.
1090
1161
def cached_differences(self):
1091
1162
"""Return a batch navigator of filtered results."""
1092
1163
package_type_dsd_status = {
1094
DistroSeriesDifferenceStatus.NEEDS_ATTENTION,),
1164
NON_IGNORED: DistroSeriesDifferenceStatus.NEEDS_ATTENTION,
1095
1165
HIGHER_VERSION_THAN_PARENT: (
1096
1166
DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT),
1097
1167
RESOLVED: DistroSeriesDifferenceStatus.RESOLVED,
1098
ALL: DistroSeriesDifferenceStatus.items,
1101
1171
# If the package_type option is not supported, add an error to
1107
1177
status = package_type_dsd_status[self.specified_package_type]
1108
1178
child_version_higher = (
1109
1179
self.specified_package_type == HIGHER_VERSION_THAN_PARENT)
1110
differences = getUtility(
1111
IDistroSeriesDifferenceSource).getForDistroSeries(
1112
self.context, difference_type=self.differences_type,
1113
name_filter=self.specified_name_filter,
1114
status=status, child_version_higher=child_version_higher,
1115
packagesets=self.specified_packagesets_filter,
1116
changed_by=self.specified_changed_by_filter)
1180
differences = get_dsd_source().getForDistroSeries(
1181
self.context, difference_type=self.differences_type,
1182
name_filter=self.specified_name_filter, status=status,
1183
child_version_higher=child_version_higher,
1184
packagesets=self.specified_packagesets_filter,
1185
changed_by=self.specified_changed_by_filter)
1118
1187
return BatchNavigator(differences, self.request)