feat(catchup): enhance catchup functionality with user and system settings

This update introduces a new `is_catchup_enabled` function to determine if catch-up is allowed for users based on their custom properties and system settings. The `UserViewSet` is modified to restrict admin-managed properties, including catch-up access. Additionally, various views and tests are updated to incorporate catch-up checks, ensuring that users without access receive appropriate error responses. The frontend is enhanced with a catch-up toggle in user and system settings forms, allowing for better management of catch-up capabilities.
This commit is contained in:
SergeantPanda 2026-07-18 18:55:51 +00:00
parent 2b62928b42
commit b6442e6421
23 changed files with 549 additions and 106 deletions

View file

@ -140,3 +140,20 @@ class UserPreferencesAPITests(TestCase):
self.assertEqual(self.user.user_level, original_level)
self.assertFalse(self.user.is_staff)
self.assertFalse(self.user.is_superuser)
def test_patch_me_cannot_set_catchup_enabled(self):
"""catchup_enabled is admin-managed; /me must not change it."""
self.user.custom_properties = {"catchup_enabled": False, "theme": "dark"}
self.user.save(update_fields=["custom_properties"])
response = self.client.patch(
self.me_url,
{"custom_properties": {"catchup_enabled": True, "theme": "light"}},
format="json",
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.user.refresh_from_db()
# Stripped from input; existing False preserved. Other props still update.
self.assertFalse(self.user.custom_properties.get("catchup_enabled"))
self.assertEqual(self.user.custom_properties.get("theme"), "light")