Fix nicknames uniqueness with different cases#8792
Fix nicknames uniqueness with different cases#8792ahukkanen merged 42 commits intodecidim:developfrom
Conversation
increase performance for migration
|
Hello, As discussed in the related issue, the notification is not implemented when a user nickname is renamed in migration. Let us know if it is better to implement it, even if the nickname is still editable in account. |
Just discussed it in the @decidim/product meeting, and we agreed that we'd like the notification also. Can you leave a placeholder for now? We'll work on this text between today and tomorrow. Thanks! |
|
Alright, we will implement it asap, thanks ! |
|
Ok! After this is done, let me know. It'd be great that @Quentinchampenois or @armandfardeau can give it a first look; leave it with an approved review when you fell confident about the code. Also welcome @eliegaboriau!! |
add spec for event add translation for notification normalize locales add logger refactor add random numbers to prevent errors
Quentinchampenois
left a comment
There was a problem hiding this comment.
Hello @eliegaboriau,
Thank you for your contribution and welcome !
It seems good to me.
@andreslucena, just a point, we decided not increment the nickname with -1, -2, etc but adding a random between 0 and 99999 to reduce the possibility of nickname already taken error.
For now, the translation for notification title is a placeholder, feel free to propose another one.
If anyone else wants to review, don't hesitate.
Thanks !
|
Hi there, sorry for the delay. Here's the proposed notification message: "We have corrected the way nicknames are used so that there are no duplicates, and that's why we have removed the case sensitive rule. Your nickname was created after another one with the same name, so we have automatically renamed it. You can change it from your account settings." |
|
Hello @carolromero, Thank you, the translation will be added in this pull request I think we should convert it to draft and reopen it once conflicts are resolved and translation updated. |
private fonctions
ahukkanen
left a comment
There was a problem hiding this comment.
Few refactoring ideas for the fixing task.
decidim-core/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake
Outdated
Show resolved
Hide resolved
decidim-core/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake
Outdated
Show resolved
Hide resolved
decidim-core/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake
Outdated
Show resolved
Hide resolved
decidim-core/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake
Outdated
Show resolved
Hide resolved
decidim-core/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake
Outdated
Show resolved
Hide resolved
refactors
Everything's added ! |
ahukkanen
left a comment
There was a problem hiding this comment.
Can you also exclude the deleted users from both queries as deleted users are not consuming the nicknames (it's empty for all deleted users) and we should not update deleted users here.
Please also see my other comment above regarding the nicknamize method and taking the capitalization into account there too.
decidim-core/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake
Outdated
Show resolved
Hide resolved
* allowing only lowercase in the nickname * nickname test system * add in locales the "lowercase" precision * changing routing for timeline * changing routing for activities * changing routing for other profile tabs * migration to change commune nicknames * linter * minor changes increase performance for migration * Refactor migration for lisibility * add fix into changelog * linter * Update CHANGELOG.md * add notification when updating nickname * fix number of notification * Add notification when updating nickname (#3) add spec for event add translation for notification normalize locales add logger refactor add random numbers to prevent errors * update message in notification * update test linter * minor changes * Change requests nickname (#8) * back to "any case" nickname * check uniqueness case insensitivity * change profiles url * mention, parse case insensitively * mention, render nicknames case insensitively * mentions spec * update migration * linter * migration to rake tasks spec rake task * linter * add test notification fix test nickname * linter * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com> * Update CHANGELOG.md * Update account_form.rb * linter * remove the if statement private fonctions * remove test task * relaunch tests * add organization criteria refactors * lint * use nicknamize instead of random numbers * add the not deleted scope * update nicknamizable to check for case Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
* allowing only lowercase in the nickname * nickname test system * add in locales the "lowercase" precision * changing routing for timeline * changing routing for activities * changing routing for other profile tabs * migration to change commune nicknames * linter * minor changes increase performance for migration * Refactor migration for lisibility * add fix into changelog * linter * Update CHANGELOG.md * add notification when updating nickname * fix number of notification * Add notification when updating nickname (#3) add spec for event add translation for notification normalize locales add logger refactor add random numbers to prevent errors * update message in notification * update test linter * minor changes * Change requests nickname (#8) * back to "any case" nickname * check uniqueness case insensitivity * change profiles url * mention, parse case insensitively * mention, render nicknames case insensitively * mentions spec * update migration * linter * migration to rake tasks spec rake task * linter * add test notification fix test nickname * linter * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com> * Update CHANGELOG.md * Update account_form.rb * linter * remove the if statement private fonctions * remove test task * relaunch tests * add organization criteria refactors * lint * use nicknamize instead of random numbers * add the not deleted scope * update nicknamizable to check for case Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
🎩 What? Why?
Please describe your pull request.
This PR ensure nickname is unique, case insensitively
Also, routing for user public profile and mentions are now redirecting to the unique user even if the case is not the same.
Rake task rename similar nicknames (with a series of digits at the end), sending a notification to the user when updating her nickname
📌 Related Issues
Link your PR to an issue
Testing
Describe the best way to test or validate your PR.
add users with similar nickname, as "Toto", "TOTO" and "toto"
run the rake tasks
see them turning into "Toto", "TOTO-XXXXX" and "toto-XXXXX"
Try adding a user with a nickname similar to one
fail
Try going to an user profile page (or mentioning her) by writing her nickname with a different case
See you're going to the good profile
📋 Checklist
🚨 Please review the guidelines for contributing to this repository.
docs/.Additional informations
Please note that the current migration will rename all duplicated nicknames and rename all nicknames in database to lowercase