feat: dodaj prefill email potpisa i body logging
Some checks failed
ERP CI/CD Pipeline / test (push) Has been cancelled
ERP CI/CD Pipeline / Deploy (server git pull + compose) (push) Has been cancelled

Uvodi signature polje i default predlozak potpisa za nove korisnike, te data migraciju koja popunjava postojece prazne potpise. Email flow sada dosljedno dodaje korisnicki potpis i sprema finalni body poruke u dispatch log radi audita.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
mariomitte
2026-07-21 15:58:50 +02:00
parent ebb642e572
commit 666ddb56c9
9 changed files with 178 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
from unittest.mock import patch
from django.contrib.auth import get_user_model
from django.core import mail
from django.test import TestCase, override_settings
from modules.fleet.models import GeneratedWorkOrderPdf, Vehicle, VehicleNotification, WorkOrder
@@ -58,3 +59,25 @@ class WorkOrderEmailTaskCachedPdfTests(TestCase):
cached_pdfs = notif.metadata.get('cached_pdfs') if isinstance(notif.metadata, dict) else None
self.assertTrue(isinstance(cached_pdfs, list) and len(cached_pdfs) > 0)
self.assertIn('download_url', cached_pdfs[0])
def test_success_email_appends_requester_signature(self):
mail.outbox.clear()
result = send_work_order_email_bundle_task(
work_order_id=str(self.work_order.pk),
requested_by_id=str(self.user.pk),
recipients=['client@example.test'],
message='Test poruka bez potpisa.',
include_work_order_pdf=True,
include_service_records_pdf=False,
include_invoices_pdf=False,
include_images=False,
include_monthly_tasks=False,
)
self.assertEqual(result.get('status'), 'ok')
self.assertEqual(len(mail.outbox), 1)
sent_body = mail.outbox[0].body
self.assertIn('Test poruka bez potpisa.', sent_body)
self.assertIn('S poštovanjem / Freundliche Grüße / Kind regards', sent_body)
self.assertIn(self.user.email, sent_body)