-
Notifications
You must be signed in to change notification settings - Fork 540
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
expose what versions would be re-enabled with a force enable #23165
Conversation
fcd7d8d
to
20058a5
Compare
20058a5
to
812860d
Compare
There was a problem hiding this 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.
You mean the force |
There was a problem hiding this 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("")

Fixes: mozilla/addons#15388
Description
For the force enable action in reviewer tools, list the versions that will be re-enabled with the action
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
Checklist
#ISSUENUM
at the top of your PR to an existing open issue in the mozilla/addons repository.