From 03ee52551bca6313a04f3a20d096057a79df3cdb Mon Sep 17 00:00:00 2001 From: gabn88 Date: Fri, 22 Jul 2022 13:40:07 +0200 Subject: [PATCH 1/2] Added the migration --- .../migrations/0012_alter_email_status.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 post_office/migrations/0012_alter_email_status.py diff --git a/post_office/migrations/0012_alter_email_status.py b/post_office/migrations/0012_alter_email_status.py new file mode 100644 index 00000000..0a8dda0c --- /dev/null +++ b/post_office/migrations/0012_alter_email_status.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.13 on 2022-07-22 11:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('post_office', '0011_models_help_text'), + ] + + operations = [ + migrations.AlterField( + model_name='email', + name='status', + field=models.PositiveSmallIntegerField(blank=True, choices=[(0, 'sent'), (1, 'failed'), (2, 'queued'), (3, 'requeued'), (4, 'draft')], db_index=True, null=True, verbose_name='Status'), + ), + ] From f7df11956dd37c90f7cdfdc5c1c72ee679247ba4 Mon Sep 17 00:00:00 2001 From: gabn88 Date: Fri, 22 Jul 2022 13:42:34 +0200 Subject: [PATCH 2/2] Added the draft status to the model I went ahead and added the draft status, so that it can be used later for previewing an email before it is send (or queued). --- post_office/models.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/post_office/models.py b/post_office/models.py index d736d48e..9ab9e94f 100644 --- a/post_office/models.py +++ b/post_office/models.py @@ -25,19 +25,18 @@ PRIORITY = namedtuple('PRIORITY', 'low medium high now')._make(range(4)) -STATUS = namedtuple('STATUS', 'sent failed queued requeued')._make(range(4)) +STATUS = namedtuple('STATUS', 'sent failed queued requeued draft')._make(range(5)) class Email(models.Model): """ A model to hold email information. """ - PRIORITY_CHOICES = [(PRIORITY.low, _("low")), (PRIORITY.medium, _("medium")), (PRIORITY.high, _("high")), (PRIORITY.now, _("now"))] STATUS_CHOICES = [(STATUS.sent, _("sent")), (STATUS.failed, _("failed")), - (STATUS.queued, _("queued")), (STATUS.requeued, _("requeued"))] - + (STATUS.queued, _("queued")), (STATUS.requeued, _("requeued")), (STATUS.draft, _("draft"))] + from_email = models.CharField(_("Email From"), max_length=254, validators=[validate_email_with_name]) to = CommaSeparatedEmailField(_("Email To"))