mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-09 12:21:57 -04:00

Some checks are pending
CodeQL / Analyze (python) (push) Waiting to run
Build Debian package / build (push) Waiting to run
Build Docker image / buildx (push) Waiting to run
Deploy static content to Pages / deploy (push) Waiting to run
Build Homebrew package / build (push) Waiting to run
Build GitHub Pages website / build (push) Waiting to run
Build GitHub Pages website / deploy (push) Blocked by required conditions
Run linters / lint (push) Waiting to run
Build Pip package / build (push) Waiting to run
Run tests / python_tests (ubuntu-22.04, 3.11) (push) Waiting to run
Run tests / docker_tests (push) Waiting to run
31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
__package__ = 'archivebox.api'
|
|
|
|
from signal_webhooks.admin import WebhookAdmin
|
|
from signal_webhooks.utils import get_webhook_model
|
|
|
|
from archivebox.base_models.admin import ABIDModelAdmin
|
|
|
|
from api.models import APIToken
|
|
|
|
|
|
class APITokenAdmin(ABIDModelAdmin):
|
|
list_display = ('created_at', 'abid', 'created_by', 'token_redacted', 'expires')
|
|
sort_fields = ('abid', 'created_at', 'created_by', 'expires')
|
|
readonly_fields = ('created_at', 'modified_at', 'abid_info')
|
|
search_fields = ('id', 'abid', 'created_by__username', 'token')
|
|
fields = ('created_by', 'token', 'expires', *readonly_fields)
|
|
|
|
list_filter = ('created_by',)
|
|
ordering = ['-created_at']
|
|
list_per_page = 100
|
|
|
|
|
|
class CustomWebhookAdmin(WebhookAdmin, ABIDModelAdmin):
|
|
list_display = ('created_at', 'created_by', 'abid', *WebhookAdmin.list_display)
|
|
sort_fields = ('created_at', 'created_by', 'abid', 'referenced_model', 'endpoint', 'last_success', 'last_error')
|
|
readonly_fields = ('created_at', 'modified_at', 'abid_info', *WebhookAdmin.readonly_fields)
|
|
|
|
|
|
def register_admin(admin_site):
|
|
admin_site.register(APIToken, APITokenAdmin)
|
|
admin_site.register(get_webhook_model(), CustomWebhookAdmin)
|