mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
User settings are now accessed via unique KEY
This commit is contained in:
parent
dd017f36c7
commit
5560706c33
@ -226,9 +226,22 @@ class UserSettingsDetail(generics.RetrieveUpdateAPIView):
|
||||
- User can only view / edit settings their own settings objects
|
||||
"""
|
||||
|
||||
lookup_field = 'key'
|
||||
queryset = common.models.InvenTreeUserSetting.objects.all()
|
||||
serializer_class = common.serializers.UserSettingsSerializer
|
||||
|
||||
def get_object(self):
|
||||
"""
|
||||
Attempt to find a user setting object with the provided key.
|
||||
"""
|
||||
|
||||
key = self.kwargs['key']
|
||||
|
||||
if key not in common.models.InvenTreeUserSetting.SETTINGS.keys():
|
||||
raise NotFound()
|
||||
|
||||
return common.models.InvenTreeUserSetting.get_setting_object(key, user=self.request.user)
|
||||
|
||||
permission_classes = [
|
||||
UserSettingsPermissions,
|
||||
]
|
||||
@ -391,7 +404,7 @@ settings_api_urls = [
|
||||
# User settings
|
||||
re_path(r'^user/', include([
|
||||
# User Settings Detail
|
||||
re_path(r'^(?P<pk>\d+)/', UserSettingsDetail.as_view(), name='api-user-setting-detail'),
|
||||
re_path(r'^(?P<key>\w+)/', UserSettingsDetail.as_view(), name='api-user-setting-detail'),
|
||||
|
||||
# User Settings List
|
||||
re_path(r'^.*$', UserSettingsList.as_view(), name='api-user-setting-list'),
|
||||
|
@ -80,7 +80,7 @@ $('table').find('.boolean-setting').change(function() {
|
||||
if (plugin) {
|
||||
url = `/api/plugin/settings/${pk}/`;
|
||||
} else if (user) {
|
||||
url = `/api/settings/user/${pk}/`;
|
||||
url = `/api/settings/user/${setting}/`;
|
||||
} else if (notification) {
|
||||
url = `/api/settings/notification/${pk}/`;
|
||||
}
|
||||
@ -125,6 +125,7 @@ $('table').find('.btn-edit-setting').click(function() {
|
||||
pk = setting;
|
||||
} else {
|
||||
title = '{% trans "Edit User Setting" %}';
|
||||
pk = setting;
|
||||
}
|
||||
|
||||
editSetting(pk, {
|
||||
|
Loading…
Reference in New Issue
Block a user