mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-24 18:48:36 +00:00
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:
parent
2b62928b42
commit
b6442e6421
23 changed files with 549 additions and 106 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue