mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Improve user conversation config details on Admin panel
Show user email and chat model that is associated with the user conversation config
This commit is contained in:
parent
41d9011a26
commit
23ab258d78
1 changed files with 32 additions and 1 deletions
|
@ -108,7 +108,6 @@ admin.site.register(GithubConfig)
|
|||
admin.site.register(NotionConfig)
|
||||
admin.site.register(UserVoiceModelConfig)
|
||||
admin.site.register(VoiceModelOption)
|
||||
admin.site.register(UserConversationConfig)
|
||||
admin.site.register(UserRequests)
|
||||
|
||||
|
||||
|
@ -326,3 +325,35 @@ class ConversationAdmin(admin.ModelAdmin):
|
|||
if "export_selected_minimal_objects" in actions:
|
||||
del actions["export_selected_minimal_objects"]
|
||||
return actions
|
||||
|
||||
|
||||
@admin.register(UserConversationConfig)
|
||||
class UserConversationConfigAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"id",
|
||||
"get_user_email",
|
||||
"get_chat_model",
|
||||
"get_subscription_type",
|
||||
)
|
||||
search_fields = ("id", "user__email", "setting__chat_model", "user__subscription__type")
|
||||
ordering = ("-updated_at",)
|
||||
|
||||
def get_user_email(self, obj):
|
||||
return obj.user.email
|
||||
|
||||
get_user_email.short_description = "User Email" # type: ignore
|
||||
get_user_email.admin_order_field = "user__email" # type: ignore
|
||||
|
||||
def get_chat_model(self, obj):
|
||||
return obj.setting.chat_model if obj.setting else None
|
||||
|
||||
get_chat_model.short_description = "Chat Model" # type: ignore
|
||||
get_chat_model.admin_order_field = "setting__chat_model" # type: ignore
|
||||
|
||||
def get_subscription_type(self, obj):
|
||||
if hasattr(obj.user, "subscription"):
|
||||
return obj.user.subscription.type
|
||||
return None
|
||||
|
||||
get_subscription_type.short_description = "Subscription Type" # type: ignore
|
||||
get_subscription_type.admin_order_field = "user__subscription__type" # type: ignore
|
||||
|
|
Loading…
Reference in a new issue