-
-
Notifications
You must be signed in to change notification settings - Fork 225
feat(TOS): allows admins to force TOS reaccpetance DEV-2178 #7235
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
Changes from 2 commits
d87ae76
e5b90ae
bd8b2f6
5363fcc
eabbfcb
d5b5362
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,42 @@ | ||||||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| from constance import config | ||||||||||||||||||||||||||
| from django.contrib import admin | ||||||||||||||||||||||||||
| from django.utils import timezone | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| from kobo.apps.markdownx_uploader.admin import MarkdownxModelAdminBase | ||||||||||||||||||||||||||
| from ..models import SitewideMessage | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| class SitewideMessageAdmin(MarkdownxModelAdminBase): | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| model = SitewideMessage | ||||||||||||||||||||||||||
| actions = ['require_terms_of_service_reacceptance'] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| def changelist_view(self, request, extra_context=None): | ||||||||||||||||||||||||||
| actions = self.get_actions(request) | ||||||||||||||||||||||||||
| # cheating: since the require_terms_of_service_reacceptance doesn't apply to | ||||||||||||||||||||||||||
| # individual SitewideMessages, always act as if all of them have been selected | ||||||||||||||||||||||||||
| # to avoid 'Items must be selected in order to perform actions on them.' error | ||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||
| actions | ||||||||||||||||||||||||||
| and request.method == 'POST' | ||||||||||||||||||||||||||
| and 'index' in request.POST | ||||||||||||||||||||||||||
| and request.POST['action'] == 'require_terms_of_service_reacceptance' | ||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||
| data = request.POST.copy() | ||||||||||||||||||||||||||
| data['select_across'] = '1' | ||||||||||||||||||||||||||
| request.POST = data | ||||||||||||||||||||||||||
| response = self.response_action( | ||||||||||||||||||||||||||
| request, queryset=self.get_queryset(request) | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| if response: | ||||||||||||||||||||||||||
| return response | ||||||||||||||||||||||||||
| return super().changelist_view(request, extra_context) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| @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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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!
greptile-apps[bot] marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Generated by Django 5.2.13 on 2026-07-10 13:24 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('hub', '0022_delete_v1usertracker'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='sitewidemessage', | ||
| name='slug', | ||
| field=models.CharField(max_length=50, unique=True), | ||
| ), | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| ] | ||
Uh oh!
There was an error while loading. Please reload this page.