more useful IngestJob admin view
@@ -4,7 +4,7 @@ from django.contrib import admin
from django.urls import reverse
from django.utils.html import format_html
-from share.admin.util import FuzzyPaginator, linked_fk, linked_many, SourceConfigFilter
+from share.admin.util import FuzzyPaginator, linked_fk, linked_many, admin_link, SourceConfigFilter
from share.models.jobs import AbstractBaseJob, IngestJob
from share.tasks import ingest
@@ -22,11 +22,6 @@ STATUS_COLORS = {
}
-def readonly_link(obj, display_str=None):
- url = reverse('admin:{}_{}_change'.format(obj._meta.app_label, obj._meta.model_name), args=[obj.id])
- return format_html('<a href="{}">{}</a>', url, display_str or str(obj))
-
-
@linked_fk('source_config')
class BaseJobAdmin(admin.ModelAdmin):
list_filter = ('status', SourceConfigFilter, )
@@ -67,7 +62,6 @@ class HarvestJobAdmin(BaseJobAdmin):
@linked_fk('suid')
-@linked_fk('raw')
@linked_many(
'ingested_normalized_data',
order_by=['-created_at'],
@@ -77,12 +71,15 @@ class IngestJobAdmin(BaseJobAdmin):
actions = ('reingest', 'reingest_without_shareobject', )
list_display = ('id', 'source_config_', 'suid_', 'status_', 'date_started', 'error_type', 'share_version', )
list_select_related = BaseJobAdmin.list_select_related + ('suid',)
- readonly_fields = BaseJobAdmin.readonly_fields + ('transformer_version', 'regulator_version', 'retries')
+ readonly_fields = BaseJobAdmin.readonly_fields + ('transformer_version', 'regulator_version', 'retries', 'most_recent_suid_raw',)
search_fields = ['=id', '=suid__identifier']
def suid_(self, obj):
return obj.suid.identifier
+ def most_recent_suid_raw(self, obj):
+ return admin_link(obj.suid.most_recent_raw_datum())
+
def reingest(self, request, queryset):
self._enqueue_tasks(queryset)
reingest.short_description = 'Re-ingest'
