Fix 0034_create_email_template_for_merged.py

This commit is contained in:
tecbr 2023-11-09 21:22:56 -03:00 committed by GitHub
parent 5df7b8ff85
commit f1d530db2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,7 @@ def forwards_func(apps, schema_editor):
EmailTemplate = apps.get_model("helpdesk", "EmailTemplate")
db_alias = schema_editor.connection.alias
EmailTemplate.objects.using(db_alias).create(
id=EmailTemplate.objects.order_by('-id').first().id + 1, # because PG sequences are not reset
id=EmailTemplate.objects.using(db_alias).order_by('-id').first().id + 1 if EmailTemplate.objects.using(db_alias).first() else 1, # because PG sequences are not reset
template_name='merged',
subject='(Merged)',
heading='Ticket merged',
@ -24,7 +24,7 @@ From now on, please answer on this ticket, or you can include the tag {{ ticket.
locale='en'
)
EmailTemplate.objects.using(db_alias).create(
id=EmailTemplate.objects.order_by('-id').first().id + 1, # because PG sequences are not reset
id=EmailTemplate.objects.using(db_alias).order_by('-id').first().id + 1, # because PG sequences are not reset
template_name='merged',
subject='(Fusionné)',
heading='Ticket Fusionné',