-
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
Log when an admin deletes/undeletes a collection through the admin #23228
base: master
Are you sure you want to change the base?
Conversation
Also avoid showing `deleted` field if the collection isn't already deleted - that's pointless and confusing, admins should use the regular delete action if they want to delete something.
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. I'll verify after you resolve my comments.
@@ -87,5 +96,14 @@ def has_add_permission(self, request): | |||
request.user, amo.permissions.ADMIN_CURATION | |||
) or super().has_add_permission(request) | |||
|
|||
def delete_model(self, request, obj): |
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.
Is there a reason we don't want a deleted log in all cases? Why only via admin?
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.
I don't think there is a strong reason, it's just something that never came up (where as deletion by moderators is something we need to keep track of for the transparency report - we already had the LogEntry
django generates automatically for actions happening in the admin, but that's not as centralized as our ActivityLog
).
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.
FWIW ratings behave in the same way, the only activity log we emit is for moderators/reviewers deletion
def save_model(self, request, obj, form, change): | ||
super().save_model(request, obj, form, change) | ||
if change and 'deleted' in form.changed_data and not obj.deleted: | ||
ActivityLog.objects.create(amo.LOG.COLLECTION_UNDELETED, obj) |
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.
Same question.
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.
Undeletion is not a feature exposed outside of the admin (and Cinder, but we do log it there)
Also avoid showing
deleted
field if the collection isn't already deleted - that's pointless and confusing, admins should use the regular delete action if they want to delete something.Fixes mozilla/addons#15394
Testing
Collections:Edit
permission + access to the admin, or just*:*
) look at a non-deleted collection detail page in the adminDeleted
field should be absentActivityLog
withCOLLECTION_DELETED
action and the collection as argument should have been recorded in the databaseSlug
field should not have changed (it would if the user would have deleted the collection themselves through the frontend)Deleted
field should be present and tickedDeleted
field and hit saveActivityLog
withCOLLECTION_UNDELETED
action and the collection as argument should have been recorded in the database