Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose what versions would be re-enabled with a force enable #23165

Merged

Conversation

eviljeff
Copy link
Member

@eviljeff eviljeff commented Mar 12, 2025

Fixes: mozilla/addons#15388

Description

For the force enable action in reviewer tools, list the versions that will be re-enabled with the action

image

Context

Added a little bit of refactoring so we're using the identical queryset to identify which versions (files) will be re-enabled as the enable_addon function itself.

Testing

  • Identify or set-up* an add-on that has a few versions. Ideally a mix of listed and unlisted, and disabled, approved, and waiting review file statuses. *(manually in django shell|admin if that's easier). Take a note of the version/file statuses.
  • Force Disable that add-on in reviewer tools.
    • note if you chose a high impact (Notable, Recommended, etc) add-on you'll have to confirm that decision via the 2nd level approvals queue.
  • Back on the review page for that add-on, in the Force Enable action, see the versions listed that weren't already disabled, and so would be re-enabled with the Force Enable action.
    • The issue specified they be linked in the same way the Top 10 ADU list is (i.e. with a redirect view to the correct paginated version history)
  • Go ahead with the Force Disable action and see the previous versions/file statuses restored.

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.

@eviljeff eviljeff force-pushed the 15388-versions-enable-list-with-enable-addon branch from fcd7d8d to 20058a5 Compare March 13, 2025 18:24
@eviljeff eviljeff force-pushed the 15388-versions-enable-list-with-enable-addon branch from 20058a5 to 812860d Compare March 14, 2025 09:55
@eviljeff eviljeff marked this pull request as ready for review March 14, 2025 09:55
@eviljeff eviljeff requested review from a team and KevinMind and removed request for a team March 14, 2025 09:56
Copy link
Contributor

@KevinMind KevinMind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, a few nits for posterity. I'll verify on Monday.

@KevinMind
Copy link
Contributor

For the force disable action in reviewer tools

You mean the force enable right?

@KevinMind KevinMind self-requested a review March 17, 2025 09:27
Copy link
Contributor

@KevinMind KevinMind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With addon specs:

Addon ID: 96
Addon Name: Test Addon With Versions
Addon Status: Approved

Versions:
Version: 2.0
  Channel: Listed
  File Status: Approved
  Version ID: 106
  File ID: 98

Version: 3.0
  Channel: Listed
  File Status: Awaiting Review
  Version ID: 107
  File ID: 99

Version: 4.0
  Channel: Unlisted
  File Status: Approved
  Version ID: 108
  File ID: 100

Version: 5.0
  Channel: Unlisted
  File Status: Awaiting Review
  Version ID: 109
  File ID: 101

Version: 6.0
  Channel: Listed
  File Status: Disabled by Mozilla
  Version ID: 110
  File ID: 102

Version: 7.0
  Channel: Unlisted
  File Status: Disabled by Mozilla
  Version ID: 111
  File ID: 103

I can see all but version 6.0 and 7.0 are in the pending_reenabled group. I think that is a good name for that method btw.

The script I used for creating the versions and printing is

#!/usr/bin/env python

from olympia import amo
from olympia.addons.models import Addon
from olympia.files.models import File
from olympia.versions.models import Version
from olympia.users.models import UserProfile

# Get or create a test user
user = UserProfile.objects.get(
    email="[email protected]"
)

# Create a new add-on
addon = Addon.objects.create(
    name='Test Addon With Versions',
    summary='An addon created for testing with multiple versions',
    type=amo.ADDON_EXTENSION,
    status=amo.STATUS_APPROVED,
)

# Add the user as an author
addon.addonuser_set.create(user=user, role=amo.AUTHOR_ROLE_OWNER)


# Create versions with different statuses and channels
version_and_file_kwargs = [
    (
        {
            'addon': addon,
            'version': f'{i}.0',
            'channel': channel,
        },
        {
            'manifest_version': i,  # Version number matches manifest version
            'status': status,
        }
    )
    for i, (channel, status) in enumerate(
        [
            (amo.CHANNEL_LISTED, amo.STATUS_APPROVED),
            (amo.CHANNEL_LISTED, amo.STATUS_AWAITING_REVIEW),
            (amo.CHANNEL_UNLISTED, amo.STATUS_APPROVED),
            (amo.CHANNEL_UNLISTED, amo.STATUS_AWAITING_REVIEW),
            (amo.CHANNEL_LISTED, amo.STATUS_DISABLED),
            (amo.CHANNEL_UNLISTED, amo.STATUS_DISABLED)
        ], start=2)
]

for version_kwarg, file_kwarg in version_and_file_kwargs:
    version, _ = Version.objects.update_or_create(**version_kwarg)
    file_kwarg['version'] = version
    File.objects.update_or_create(**file_kwarg)

# Update the addon's current version to be version1
addon.save()

# Print the addon and version information
print(f"Addon ID: {addon.id}")
print(f"Addon Name: {addon.name}")
print(f"Addon Status: {amo.STATUS_CHOICES_ADDON[addon.status]}")
print("\nVersions:")

for version in addon.versions.all().order_by('version'):
    file = version.file
    channel_name = amo.CHANNEL_CHOICES[version.channel]
    file_status = amo.STATUS_CHOICES_FILE[file.status]

    print(f"Version: {version.version}")
    print(f"  Channel: {channel_name}")
    print(f"  File Status: {file_status}")
    print(f"  Version ID: {version.id}")
    print(f"  File ID: {file.id}")
    print("")
image

@eviljeff eviljeff merged commit 922e2ff into mozilla:master Mar 17, 2025
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Provide better visibility to reviewers on which versions will be affected by a force-enable action
2 participants