feat: async email slanje s cache PDF fallbackom i admin logom
Prebaci slanje emaila putnog naloga u pozadinski task bez blokiranja UI-a i dodaj fallback kad queue nije dostupna. Kod greške slanja spremi generirane PDF-ove u cache i pošalji notifikaciju s download linkovima. Dodaj EmailDispatchLog model i Django admin pregled za praćenje kome je poslano, što je poslano, status i detalje privitaka. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ from .models import (
|
||||
WorkOrderAdditionalCostsTable,
|
||||
ServiceContextNote,
|
||||
GeneratedWorkOrderPdf,
|
||||
EmailDispatchLog,
|
||||
VehicleServiceRecord,
|
||||
VehicleServicePhoto,
|
||||
VehicleServiceAttachment,
|
||||
@@ -244,4 +245,50 @@ class VehicleServiceRecordAdmin(admin.ModelAdmin):
|
||||
def short_description(self, obj):
|
||||
if obj.description:
|
||||
return obj.description[:60] + ('…' if len(obj.description) > 60 else '')
|
||||
return "—"
|
||||
return "—"
|
||||
|
||||
|
||||
@admin.register(EmailDispatchLog)
|
||||
class EmailDispatchLogAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
'id',
|
||||
'dispatch_type',
|
||||
'status',
|
||||
'requested_by',
|
||||
'work_order',
|
||||
'service_record',
|
||||
'recipients_count',
|
||||
'sent_at',
|
||||
'created_at',
|
||||
)
|
||||
list_filter = ('dispatch_type', 'status', 'created_at', 'sent_at')
|
||||
search_fields = (
|
||||
'subject',
|
||||
'message',
|
||||
'error_message',
|
||||
'requested_by__email',
|
||||
'requested_by__username',
|
||||
'work_order__display_code',
|
||||
)
|
||||
readonly_fields = (
|
||||
'dispatch_type',
|
||||
'requested_by',
|
||||
'work_order',
|
||||
'service_record',
|
||||
'recipients',
|
||||
'subject',
|
||||
'message',
|
||||
'attachments',
|
||||
'status',
|
||||
'error_message',
|
||||
'metadata',
|
||||
'sent_at',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
)
|
||||
ordering = ('-created_at',)
|
||||
|
||||
@admin.display(description='Primatelja')
|
||||
def recipients_count(self, obj):
|
||||
recipients = obj.recipients or []
|
||||
return len(recipients) if isinstance(recipients, list) else 0
|
||||
Reference in New Issue
Block a user