-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
feat: Revert product to a previous revision (API + upcoming website integration for moderators) #9800
Conversation
Can we have some kind of log/notification when a moderator reverts a product ? |
I'm sending a mail to admins, we can revisit once we have a better system in place for events / notifications / patrol. |
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.
Thanks for this great PR !
Overall it's good, but it needs some minor fixes IMO.
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.
Good idea to add this module ! This will bring clarity.
lib/ProductOpener/Display.pm
Outdated
if ($User{moderator}) { | ||
$request_ref->{moderator} = 1; | ||
} | ||
else { | ||
$request_ref->{moderator} = 0; | ||
} | ||
|
||
if ($User{pro_moderator}) { | ||
$request_ref->{pro_moderator} = 1; | ||
} | ||
else { | ||
$request_ref->{pro_moderator} = 0; | ||
} |
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.
if ($User{moderator}) { | |
$request_ref->{moderator} = 1; | |
} | |
else { | |
$request_ref->{moderator} = 0; | |
} | |
if ($User{pro_moderator}) { | |
$request_ref->{pro_moderator} = 1; | |
} | |
else { | |
$request_ref->{pro_moderator} = 0; | |
} | |
$request_ref->{moderator} = !!$User{moderator}; | |
$User{pro_moderator} = !!$request_ref->{pro_moderator}; |
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.
Here I wanted to set the value to 0 specifically, but we can use undef instead (!! 0 or !! undef seems to be equal to undef)
lib/ProductOpener/Display.pm
Outdated
$scripts .= <<SCRIPTS | ||
<script>var revert_confirm_message = "$revert_confirm";</script> | ||
<script src="$static_subdomain/js/dist/product-history.js"></script> | ||
SCRIPTS | ||
; | ||
|
||
$initjs .= <<JS | ||
activate_product_revert_buttons_in_history(); | ||
JS | ||
; |
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.
Don't we want to avoid this kind of JS inclusion (I find it quite annoying) ?
Why isn't it included in the template. Or we could maybe just use a specific class to trigger the JS activity.
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.
OK, I'm moving it.
taxonomies/nutrient_levels.txt
Outdated
@@ -138,7 +138,7 @@ qu:Wira in low quantity | |||
rm:Fat in low quantity | |||
rn:Fat in low quantity | |||
ro:Grăsimi în cantitate mică | |||
ru:Жиры в небольшое количество | |||
ru:Жиры в в малом количестве |
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.
? why is the в
repeated ?
(see also below)
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.
FYI, it seems to come from taxonomy generations…
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.
@alexgarel I made a PR to remove this file from GitHub: #9851
{ | ||
test_case => 'revert-product-no-code', | ||
method => 'POST', | ||
path => '/api/v3/product_revert', | ||
body => '{ | ||
"rev": 1, | ||
"fields": "code,rev,product_name_en,brands_tags,categories_tags" | ||
}', | ||
ua => $moderator_ua, | ||
}, |
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 see a specific return code. Does this mean we send back a 200 ? I think this is important to return a non 20x code (to keep REST like and ease handling by a lot of languages, JS included).
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.
Good point, I'm changing to 40x codes for errors
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.
You did an incredible job ! Thank you.
|
||
foreach my $test_ref (@$tests_ref) { | ||
|
||
my $response = execute_request($test_ref, $ua); |
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.
You did an incredible job at refactoring. Sorry if it feels picky, but I still have a request: I would check the expected code response even in case of setup, it can help understanding that a test fails because a setup test did go wrong.
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.
Good idea. So for setup test cases, I now still call check_requests_response (so that we can check expected status code), but I don't save or compare the actual response body.
Quality Gate passedIssues Measures |
🎉 |
…ntegration for moderators) (#9800)
Will fix #1405
Still missing: