2022-11-12 06:02:43 +01:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2022-11-14 02:42:47 +01:00
|
|
|
from activities.models import FanOut, Post, PostInteraction, TimelineEvent
|
2022-11-12 06:02:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Post)
|
|
|
|
class PostAdmin(admin.ModelAdmin):
|
2022-11-12 07:04:43 +01:00
|
|
|
list_display = ["id", "state", "author", "created"]
|
2022-11-16 02:30:30 +01:00
|
|
|
raw_id_fields = ["to", "mentions", "author"]
|
2022-11-14 03:03:43 +01:00
|
|
|
actions = ["force_fetch"]
|
2022-11-16 02:30:30 +01:00
|
|
|
readonly_fields = ["created", "updated", "object_json"]
|
2022-11-14 03:03:43 +01:00
|
|
|
|
|
|
|
@admin.action(description="Force Fetch")
|
|
|
|
def force_fetch(self, request, queryset):
|
|
|
|
for instance in queryset:
|
|
|
|
instance.debug_fetch()
|
2022-11-12 06:02:43 +01:00
|
|
|
|
2022-11-16 02:30:30 +01:00
|
|
|
@admin.display(description="ActivityPub JSON")
|
|
|
|
def object_json(self, instance):
|
|
|
|
return instance.to_ap()
|
|
|
|
|
2022-11-12 06:02:43 +01:00
|
|
|
|
|
|
|
@admin.register(TimelineEvent)
|
|
|
|
class TimelineEventAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ["id", "identity", "created", "type"]
|
2022-11-16 02:30:30 +01:00
|
|
|
raw_id_fields = [
|
|
|
|
"identity",
|
|
|
|
"subject_post",
|
|
|
|
"subject_identity",
|
|
|
|
"subject_post_interaction",
|
|
|
|
]
|
2022-11-12 07:04:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
@admin.register(FanOut)
|
|
|
|
class FanOutAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ["id", "state", "state_attempted", "type", "identity"]
|
2022-11-16 02:30:30 +01:00
|
|
|
raw_id_fields = ["identity", "subject_post", "subject_post_interaction"]
|
|
|
|
readonly_fields = ["created", "updated"]
|
|
|
|
actions = ["force_execution"]
|
|
|
|
|
|
|
|
@admin.action(description="Force Execution")
|
|
|
|
def force_execution(self, request, queryset):
|
|
|
|
for instance in queryset:
|
|
|
|
instance.transition_perform("new")
|
2022-11-14 02:42:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
@admin.register(PostInteraction)
|
|
|
|
class PostInteractionAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ["id", "state", "state_attempted", "type", "identity", "post"]
|
|
|
|
raw_id_fields = ["identity", "post"]
|