feat(TOS): allows admins to force TOS reaccpetance DEV-2178#7235
Merged
Conversation
Contributor
Author
Contributor
Comment on lines
+37
to
+42
| @admin.action(description='Require all users to reaccept the Terms of Service') | ||
| def require_terms_of_service_reacceptance(self, request, *args, **kwargs): | ||
| setattr(config, 'LAST_TOS_UPDATE', timezone.now()) | ||
| self.message_user( | ||
| request, 'All users will be prompted to re-accept the Terms of Service' | ||
| ) |
Contributor
There was a problem hiding this comment.
These two user-visible strings are missing translation wrappers, violating the project rule that all text constants must be translatable. The
@admin.action description and the message_user call should both use t() (which the rest of the codebase imports as from django.utils.translation import gettext as t).
Suggested change
| @admin.action(description='Require all users to reaccept the Terms of Service') | |
| def require_terms_of_service_reacceptance(self, request, *args, **kwargs): | |
| setattr(config, 'LAST_TOS_UPDATE', timezone.now()) | |
| self.message_user( | |
| request, 'All users will be prompted to re-accept the Terms of Service' | |
| ) | |
| @admin.action(description=t('Require all users to reaccept the Terms of Service')) | |
| def require_terms_of_service_reacceptance(self, request, *args, **kwargs): | |
| setattr(config, 'LAST_TOS_UPDATE', timezone.now()) | |
| self.message_user( | |
| request, t('All users will be prompted to re-accept the Terms of Service') | |
| ) |
Rule Used: All text constants on both backend and frontend mu... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Contributor
Author
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗒️ Checklist
#Support Docs Updates, if any<type>(<scope>)<!>: <title> DEV-1234Front endand/orBack endorworkflow📣 Summary
Add an admin action to require all users to reaccept the Terms of Service.
📖 Description
Adds an admin action to the SitewideMessage admin. When triggered, as long as there is a terms of service sitewide message present, all users will be prompted to accept the TOS regardless of whether they have already done so.
💭 Notes
It's a bit hacky to use the Constance config to store the last updated time since it's not really meant to be set programatically but the django singleton pattern is kind of a pain and this way we can just use an existing singleton object.
👀 Preview steps
Sitewide message with this Slug already exists.Require all users to reaccept the Terms of Serviceaction