Eliminate button for the webhook action admin screen
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ekaropolus 2025-07-05 21:49:11 -06:00
parent 37eeeedebc
commit 4e74762d53

View File

@ -1,10 +1,9 @@
from django.contrib import admin from django.contrib import admin
from .models import TelegramBot from .models import TelegramBot
from django.utils.html import format_html
@admin.register(TelegramBot) @admin.register(TelegramBot)
class TelegramBotAdmin(admin.ModelAdmin): class TelegramBotAdmin(admin.ModelAdmin):
list_display = ("name", "username", "is_active", "get_assistant_name", "set_webhook_action") list_display = ("name", "username", "is_active", "get_assistant_name")
search_fields = ("name", "username") search_fields = ("name", "username")
list_filter = ("is_active",) list_filter = ("is_active",)
actions = ["set_webhooks"] actions = ["set_webhooks"]
@ -45,11 +44,3 @@ class TelegramBotAdmin(admin.ModelAdmin):
"""Show the name of the assistant linked to the bot.""" """Show the name of the assistant linked to the bot."""
return obj.assistant.name if obj.assistant else "None" return obj.assistant.name if obj.assistant else "None"
get_assistant_name.short_description = "Assistant Name" get_assistant_name.short_description = "Assistant Name"
def set_webhook_action(self, obj):
"""Button in the Django admin to manually trigger webhook setup."""
return format_html(
'<a class="button" href="{}">Set Webhook</a>',
f"/admin/pxy_bots/set_webhook/{obj.id}/"
)
set_webhook_action.short_description = "Webhook"