mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 19:46:46 +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
|
- User can only view / edit settings their own settings objects
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
lookup_field = 'key'
|
||||||
queryset = common.models.InvenTreeUserSetting.objects.all()
|
queryset = common.models.InvenTreeUserSetting.objects.all()
|
||||||
serializer_class = common.serializers.UserSettingsSerializer
|
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 = [
|
permission_classes = [
|
||||||
UserSettingsPermissions,
|
UserSettingsPermissions,
|
||||||
]
|
]
|
||||||
@ -391,7 +404,7 @@ settings_api_urls = [
|
|||||||
# User settings
|
# User settings
|
||||||
re_path(r'^user/', include([
|
re_path(r'^user/', include([
|
||||||
# User Settings Detail
|
# 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
|
# User Settings List
|
||||||
re_path(r'^.*$', UserSettingsList.as_view(), name='api-user-setting-list'),
|
re_path(r'^.*$', UserSettingsList.as_view(), name='api-user-setting-list'),
|
||||||
|
@ -80,7 +80,7 @@ $('table').find('.boolean-setting').change(function() {
|
|||||||
if (plugin) {
|
if (plugin) {
|
||||||
url = `/api/plugin/settings/${pk}/`;
|
url = `/api/plugin/settings/${pk}/`;
|
||||||
} else if (user) {
|
} else if (user) {
|
||||||
url = `/api/settings/user/${pk}/`;
|
url = `/api/settings/user/${setting}/`;
|
||||||
} else if (notification) {
|
} else if (notification) {
|
||||||
url = `/api/settings/notification/${pk}/`;
|
url = `/api/settings/notification/${pk}/`;
|
||||||
}
|
}
|
||||||
@ -125,6 +125,7 @@ $('table').find('.btn-edit-setting').click(function() {
|
|||||||
pk = setting;
|
pk = setting;
|
||||||
} else {
|
} else {
|
||||||
title = '{% trans "Edit User Setting" %}';
|
title = '{% trans "Edit User Setting" %}';
|
||||||
|
pk = setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
editSetting(pk, {
|
editSetting(pk, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user