feat: dodaj prefill email potpisa i body logging
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:
16
backend/core/users/migrations/0007_customuser_signature.py
Normal file
16
backend/core/users/migrations/0007_customuser_signature.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0006_customuser_work_position'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='customuser',
|
||||
name='signature',
|
||||
field=models.TextField(blank=True, default='', verbose_name='Email potpis'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,39 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def prefill_empty_signatures(apps, schema_editor):
|
||||
CustomUser = apps.get_model('users', 'CustomUser')
|
||||
for user in CustomUser.objects.all().iterator():
|
||||
signature_value = user.signature if isinstance(user.signature, str) else ''
|
||||
if signature_value.strip():
|
||||
continue
|
||||
first_name = (user.first_name or '').strip()
|
||||
last_name = (user.last_name or '').strip()
|
||||
full_name = f"{first_name} {last_name}".strip()
|
||||
fallback_name = (user.email or '').strip() or 'Ime i prezime'
|
||||
display_name = full_name or fallback_name
|
||||
occupation = (user.occupation or '').strip()
|
||||
name_line = f"{occupation} {display_name}".strip() if occupation else display_name
|
||||
mobile = (user.telefon or '').strip() or "+385 91 636 3466"
|
||||
signature = (
|
||||
"Poslano iz aplikacije\n"
|
||||
"S poštovanjem / Freundliche Grüße / Kind regards\n\n"
|
||||
f"{name_line}\n\n"
|
||||
"KNEZ LJUBO d.o.o.\n"
|
||||
"Ivlje 44, 10040 Zagreb\n\n"
|
||||
"Office: Donje Svetice 40, 10000 Zagreb\n\n"
|
||||
f"Mobile: {mobile}\n\n"
|
||||
"www.knezljubo.hr"
|
||||
)
|
||||
user.signature = signature
|
||||
user.save(update_fields=['signature'])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('users', '0007_customuser_signature'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(prefill_empty_signatures, migrations.RunPython.noop),
|
||||
]
|
||||
Reference in New Issue
Block a user