Coverage for src/backend/InvenTree/common/migrations/0039_emailthread_emailmessage.py: 100%
7 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
1# Generated by Django 4.2.20 on 2025-05-07 00:17
3import InvenTree.models
4from django.db import migrations, models
5import django.db.models.deletion
6import uuid
9class Migration(migrations.Migration):
11 dependencies = [
12 ('common', '0038_alter_attachment_model_type'),
13 ]
15 operations = [
16 migrations.CreateModel(
17 name='EmailThread',
18 fields=[
19 ('metadata', models.JSONField(blank=True, help_text='JSON metadata field, for use by external plugins', null=True, verbose_name='Plugin Metadata')),
20 ('key', models.CharField(blank=True, help_text='Unique key for this thread (used to identify the thread)', max_length=250, null=True, verbose_name='Key')),
21 ('global_id', models.UUIDField(default=uuid.uuid4, editable=False, help_text='Unique identifier for this thread', primary_key=True, serialize=False, verbose_name='Global ID')),
22 ('started_internal', models.BooleanField(default=False, help_text='Was this thread started internally?', verbose_name='Started Internal')),
23 ('created', models.DateTimeField(auto_now_add=True, help_text='Date and time that the thread was created', verbose_name='Created')),
24 ('updated', models.DateTimeField(auto_now=True, help_text='Date and time that the thread was last updated', verbose_name='Updated')),
25 ],
26 options={
27 'verbose_name': 'Email Thread',
28 'verbose_name_plural': 'Email Threads',
29 'ordering': ['-updated'],
30 'unique_together': {('key', 'global_id')},
31 },
32 bases=(InvenTree.models.PluginValidationMixin, models.Model),
33 ),
34 migrations.CreateModel(
35 name='EmailMessage',
36 fields=[
37 ('global_id', models.UUIDField(default=uuid.uuid4, editable=False, help_text='Unique identifier for this message', primary_key=True, serialize=False, unique=True, verbose_name='Global ID')),
38 ('message_id_key', models.CharField(blank=True, help_text='Identifier for this message (might be supplied by external system)', max_length=250, null=True, verbose_name='Message ID')),
39 ('thread_id_key', models.CharField(blank=True, help_text='Identifier for this message thread (might be supplied by external system)', max_length=250, null=True, verbose_name='Thread ID')),
40 ('subject', models.CharField(max_length=250)),
41 ('body', models.TextField()),
42 ('to', models.EmailField(max_length=254)),
43 ('sender', models.EmailField(max_length=254)),
44 ('status', models.CharField(blank=True, choices=[('A', 'Announced'), ('S', 'Sent'), ('F', 'Failed'), ('D', 'Delivered'), ('R', 'Read'), ('C', 'Confirmed')], max_length=50, null=True)),
45 ('timestamp', models.DateTimeField(auto_now_add=True)),
46 ('headers', models.JSONField(blank=True, null=True)),
47 ('full_message', models.TextField(blank=True, null=True)),
48 ('direction', models.CharField(blank=True, choices=[('I', 'Inbound'), ('O', 'Outbound')], max_length=50, null=True)),
49 ('priority', models.IntegerField(choices=[(0, 'None'), (1, 'Very High'), (2, 'High'), (3, 'Normal'), (4, 'Low'), (5, 'Very Low')], verbose_name='Priority')),
50 ('delivery_options', models.JSONField(blank=True, null=True)),
51 ('error_code', models.CharField(blank=True, max_length=50, null=True)),
52 ('error_message', models.TextField(blank=True, null=True)),
53 ('error_timestamp', models.DateTimeField(blank=True, null=True)),
54 ('thread', models.ForeignKey(blank=True, help_text='Linked thread for this message', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='messages', to='common.emailthread', verbose_name='Thread')),
55 ],
56 options={
57 'verbose_name': 'Email Message',
58 'verbose_name_plural': 'Email Messages',
59 },
60 ),
61 ]