we can delete the message from telegram from the webui now
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
This commit is contained in:
@@ -1,8 +1,26 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from import_export.admin import ImportExportModelAdmin
|
from import_export.admin import ImportExportModelAdmin
|
||||||
from .models import TelegramData
|
from .models import TelegramData
|
||||||
|
from .utils import telegramUtils
|
||||||
|
|
||||||
|
@admin.action(description="Clear all expired messages")
|
||||||
|
def messages_cleaning(modeladmin, request, queryset):
|
||||||
|
telegram = telegramUtils()
|
||||||
|
telegram.clear_expired_messages()
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
@admin.register(TelegramData)
|
@admin.register(TelegramData)
|
||||||
class JobAdmin(ImportExportModelAdmin):
|
class JobAdmin(ImportExportModelAdmin):
|
||||||
list_display = ('message_id','chat_id','description','creation_date','expiration_date')
|
list_display = ('message_id','chat_id','description','creation_date','expiration_date')
|
||||||
|
actions = [messages_cleaning]
|
||||||
|
|
||||||
|
def delete_queryset(self, request, queryset):
|
||||||
|
"""Given a queryset, delete it from the database."""
|
||||||
|
print("here")
|
||||||
|
telegram = telegramUtils()
|
||||||
|
list_of_message_id = list(queryset.all().values_list('message_id',flat=True))
|
||||||
|
telegram.delete_message(list_of_message_id)
|
||||||
|
#no queryset.delete() because it is specified in delete_message function already
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user