Always set a due date on versions with a developer reply even if they are disabled/not signed (#22511)

This commit is contained in:
Mathieu Pillard 2024-07-26 17:03:54 +02:00 коммит произвёл GitHub
Родитель 2b9c75ca4d
Коммит 9fac55cd40
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 45 добавлений и 1 удалений

Просмотреть файл

@ -176,6 +176,8 @@ class VersionManager(ManagerBase):
"""Returns a queryset filtered to versions that should have a due date set. """Returns a queryset filtered to versions that should have a due date set.
If `negate=True` the queryset will contain versions that should not have a If `negate=True` the queryset will contain versions that should not have a
due date instead.""" due date instead."""
from olympia.reviewers.models import NeedsHumanReview
method = getattr(self, 'exclude' if negate else 'filter') method = getattr(self, 'exclude' if negate else 'filter')
requires_manual_listed_approval_and_is_listed = Q( requires_manual_listed_approval_and_is_listed = Q(
Q(addon__reviewerflags__auto_approval_disabled=True) Q(addon__reviewerflags__auto_approval_disabled=True)
@ -224,8 +226,14 @@ class VersionManager(ManagerBase):
~Q(file__status=amo.STATUS_DISABLED) | Q(file__is_signed=True), ~Q(file__status=amo.STATUS_DISABLED) | Q(file__is_signed=True),
needshumanreview__is_active=True, needshumanreview__is_active=True,
) )
# Developer replies always trigger a due date even if the version has
# been disabled and is not signed.
has_developer_reply = Q(
needshumanreview__is_active=True,
needshumanreview__reason=NeedsHumanReview.REASONS.DEVELOPER_REPLY,
)
return ( return (
method(is_needs_human_review | is_pre_review_version) method(is_needs_human_review | is_pre_review_version | has_developer_reply)
.using('default') .using('default')
.distinct() .distinct()
) )

Просмотреть файл

@ -1120,6 +1120,42 @@ class TestVersion(AMOPaths, TestCase):
) )
assert version.should_have_due_date assert version.should_have_due_date
def test_should_have_due_date_developer_reply(self):
addon = Addon.objects.get(id=3615)
version = addon.current_version
assert version.needshumanreview_set.count() == 0
assert not version.should_have_due_date
needs_human_review = version.needshumanreview_set.create(
is_active=False, reason=NeedsHumanReview.REASONS.DEVELOPER_REPLY
)
assert not version.should_have_due_date
needs_human_review.update(is_active=True)
assert version.should_have_due_date
# status/is_signed shouldn't matter for developer replies
version.file.update(is_signed=False, status=amo.STATUS_DISABLED)
assert version.should_have_due_date
version.file.update(status=amo.STATUS_AWAITING_REVIEW)
assert version.should_have_due_date
version.file.update(is_signed=True, status=amo.STATUS_APPROVED)
assert version.should_have_due_date
version.file.update(status=amo.STATUS_DISABLED)
assert version.should_have_due_date
version.file.update(is_signed=False)
for reason in NeedsHumanReview.REASONS.values.keys() - [
NeedsHumanReview.REASONS.DEVELOPER_REPLY
]:
# Every other reason shouldn't result in a due date since the
# version is disabled and not signed at this point.
needs_human_review.update(reason=reason)
assert not version.should_have_due_date
def test_reset_due_date(self): def test_reset_due_date(self):
addon = Addon.objects.get(id=3615) addon = Addon.objects.get(id=3615)
version = addon.current_version version = addon.current_version