From 621cef072ad10410bea74f9c78274bd1f9107699 Mon Sep 17 00:00:00 2001 From: Rafi Date: Fri, 24 Mar 2023 15:44:40 +0800 Subject: [PATCH] Add a setting option `open_api_key_setting` to control whether the front-end enables API Key setting. --- chat/signals.py | 5 ++++- chat/views.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chat/signals.py b/chat/signals.py index b30e81f..4714809 100644 --- a/chat/signals.py +++ b/chat/signals.py @@ -14,4 +14,7 @@ def load_default_settings(sender, **kwargs): print('Created setting: open_registration') if not Setting.objects.filter(name='open_web_search').exists(): Setting.objects.create(name='open_web_search', value='False') - print('Created setting: open_web_search') \ No newline at end of file + print('Created setting: open_web_search') + if not Setting.objects.filter(name='open_api_key_setting').exists(): + Setting.objects.create(name='open_api_key_setting', value='False') + print('Created setting: open_api_key_setting') \ No newline at end of file diff --git a/chat/views.py b/chat/views.py index 9813378..487a7b3 100644 --- a/chat/views.py +++ b/chat/views.py @@ -22,7 +22,8 @@ class SettingViewSet(viewsets.ModelViewSet): def get_queryset(self): available_names = [ 'open_registration', - 'open_web_search' + 'open_web_search', + 'open_api_key_setting' ] return Setting.objects.filter(name__in=available_names)