This commit is contained in:
j3d1 2026-08-31 16:05:05 +02:00
parent 18a3e40435
commit 15dad8e3be
6 changed files with 130 additions and 153 deletions

View file

@ -18,47 +18,6 @@ from hostadmin.models import Domain
router = routers.SimpleRouter()
# Schema for account-level preferences a client may store server-side (see AccountPreference);
# device-level preferences stay in the browser's local storage instead.
PREFERENCE_DEFINITIONS = [
{
'key': 'ui.compact_mode',
'type': 'boolean',
'default': False,
'label': 'Compact mode',
'description': 'Show denser item rows and reduce spacing in lists.',
},
{
'key': 'ui.default_search_scope',
'type': 'enum',
'options': ['inventory', 'friends', 'all'],
'default': 'inventory',
'label': 'Default search scope',
'description': 'Choose where the global search starts.',
},
{
'key': 'notifications.desktop_enabled',
'type': 'boolean',
'default': True,
'label': 'Desktop notifications',
'description': 'Enable in-browser notifications for important updates.',
},
{
'key': 'files.max_upload_mb',
'type': 'integer',
'default': 25,
'label': 'Default upload size limit (MB)',
'description': 'Used as a prefill hint in upload dialogs.',
},
{
'key': 'ui.experimental_flags',
'type': 'json',
'default': {},
'label': 'Experimental flags',
'description': 'Optional JSON toggles for feature previews.',
},
]
class UserAuthToken(ObtainAuthToken):
@ -199,14 +158,6 @@ def registerUser(request):
return Response({'errors': {'domain': 'Domain does not exist or is not open for registration'}}, status=400)
@api_view(['GET'])
@permission_classes([])
@authentication_classes([])
def preference_definitions(request):
"""Return the schema (types, defaults, labels) for the account preferences clients may set."""
return Response(PREFERENCE_DEFINITIONS)
@api_view(['GET', 'PUT'])
@permission_classes([IsAuthenticated])
@authentication_classes([SignatureAuthenticationLocal])
@ -241,7 +192,6 @@ urlpatterns = [
path('user/<str:handle>/', getUserProfile),
path('register/', registerUser),
path('token/', UserAuthToken.as_view()),
path('preferences/', preference_definitions),
path('self/preferences/', account_preferences),
path('self/preferences/<str:key>/', account_preference_detail),
]