2018-04-08 11:33:46 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
|
|
|
|
from . import models
|
2018-09-13 15:18:23 +00:00
|
|
|
from . import tasks
|
|
|
|
|
|
|
|
|
2018-09-22 12:29:30 +00:00
|
|
|
def redeliver_deliveries(modeladmin, request, queryset):
|
|
|
|
queryset.update(is_delivered=False)
|
|
|
|
for delivery in queryset:
|
|
|
|
tasks.deliver_to_remote.delay(delivery_id=delivery.pk)
|
2018-09-13 15:18:23 +00:00
|
|
|
|
|
|
|
|
2018-09-22 12:29:30 +00:00
|
|
|
redeliver_deliveries.short_description = "Redeliver"
|
2018-09-13 15:18:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
def redeliver_activities(modeladmin, request, queryset):
|
2018-09-22 12:29:30 +00:00
|
|
|
for activity in queryset.select_related("actor__user"):
|
|
|
|
if activity.actor.is_local:
|
|
|
|
tasks.dispatch_outbox.delay(activity_id=activity.pk)
|
|
|
|
else:
|
|
|
|
tasks.dispatch_inbox.delay(activity_id=activity.pk)
|
2018-09-13 15:18:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
redeliver_activities.short_description = "Redeliver"
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(models.Activity)
|
|
|
|
class ActivityAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ["type", "fid", "url", "actor", "creation_date"]
|
|
|
|
search_fields = ["payload", "fid", "url", "actor__domain"]
|
|
|
|
list_filter = ["type", "actor__domain"]
|
|
|
|
actions = [redeliver_activities]
|
|
|
|
list_select_related = True
|
2018-04-08 11:33:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
@admin.register(models.Actor)
|
|
|
|
class ActorAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
2018-09-06 18:35:02 +00:00
|
|
|
"fid",
|
2018-06-09 13:36:16 +00:00
|
|
|
"domain",
|
|
|
|
"preferred_username",
|
|
|
|
"type",
|
|
|
|
"creation_date",
|
|
|
|
"last_fetch_date",
|
2018-04-08 11:33:46 +00:00
|
|
|
]
|
2018-09-06 18:35:02 +00:00
|
|
|
search_fields = ["fid", "domain", "preferred_username"]
|
2018-06-09 13:36:16 +00:00
|
|
|
list_filter = ["type"]
|
2018-04-08 11:33:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
@admin.register(models.Follow)
|
|
|
|
class FollowAdmin(admin.ModelAdmin):
|
2018-06-09 13:36:16 +00:00
|
|
|
list_display = ["actor", "target", "approved", "creation_date"]
|
|
|
|
list_filter = ["approved"]
|
2018-09-06 18:35:02 +00:00
|
|
|
search_fields = ["actor__fid", "target__fid"]
|
2018-04-08 11:33:46 +00:00
|
|
|
list_select_related = True
|
|
|
|
|
|
|
|
|
2018-09-13 15:18:23 +00:00
|
|
|
@admin.register(models.LibraryFollow)
|
|
|
|
class LibraryFollowAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ["actor", "target", "approved", "creation_date"]
|
|
|
|
list_filter = ["approved"]
|
|
|
|
search_fields = ["actor__fid", "target__fid"]
|
2018-04-08 11:33:46 +00:00
|
|
|
list_select_related = True
|
|
|
|
|
|
|
|
|
2018-09-13 15:18:23 +00:00
|
|
|
@admin.register(models.InboxItem)
|
|
|
|
class InboxItemAdmin(admin.ModelAdmin):
|
2018-09-22 12:29:30 +00:00
|
|
|
list_display = ["actor", "activity", "type", "is_read"]
|
|
|
|
list_filter = ["type", "activity__type", "is_read"]
|
|
|
|
search_fields = ["actor__fid", "activity__fid"]
|
|
|
|
list_select_related = True
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(models.Delivery)
|
|
|
|
class DeliveryAdmin(admin.ModelAdmin):
|
2018-04-08 11:33:46 +00:00
|
|
|
list_display = [
|
2018-09-22 12:29:30 +00:00
|
|
|
"inbox_url",
|
2018-09-13 15:18:23 +00:00
|
|
|
"activity",
|
2018-09-22 12:29:30 +00:00
|
|
|
"last_attempt_date",
|
|
|
|
"attempts",
|
|
|
|
"is_delivered",
|
2018-04-08 11:33:46 +00:00
|
|
|
]
|
2018-09-22 12:29:30 +00:00
|
|
|
list_filter = ["activity__type", "is_delivered"]
|
|
|
|
search_fields = ["inbox_url"]
|
2018-04-08 11:33:46 +00:00
|
|
|
list_select_related = True
|
2018-09-22 12:29:30 +00:00
|
|
|
actions = [redeliver_deliveries]
|