diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index c58f7bcc4..b332233dc 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -62,13 +62,13 @@ class FlagMailAction(BaseMailAction): def get_rule_action(rule): - if rule.action == MailRule.AttachmentAction.FLAG: + if rule.action == MailRule.MailAction.FLAG: return FlagMailAction() - elif rule.action == MailRule.AttachmentAction.DELETE: + elif rule.action == MailRule.MailAction.DELETE: return DeleteMailAction() - elif rule.action == MailRule.AttachmentAction.MOVE: + elif rule.action == MailRule.MailAction.MOVE: return MoveMailAction() - elif rule.action == MailRule.AttachmentAction.MARK_READ: + elif rule.action == MailRule.MailAction.MARK_READ: return MarkReadMailAction() else: raise NotImplementedError("Unknown action.") # pragma: nocover diff --git a/src/paperless_mail/migrations/0014_alter_mailrule_action.py b/src/paperless_mail/migrations/0014_alter_mailrule_action.py new file mode 100644 index 000000000..6d3a369cd --- /dev/null +++ b/src/paperless_mail/migrations/0014_alter_mailrule_action.py @@ -0,0 +1,27 @@ +# Generated by Django 4.0.4 on 2022-04-18 22:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("paperless_mail", "0013_merge_20220412_1051"), + ] + + operations = [ + migrations.AlterField( + model_name="mailrule", + name="action", + field=models.PositiveIntegerField( + choices=[ + (1, "Delete"), + (2, "Move to specified folder"), + (3, "Mark as read, don't process read mails"), + (4, "Flag the mail, don't process flagged mails"), + ], + default=3, + verbose_name="action", + ), + ), + ] diff --git a/src/paperless_mail/models.py b/src/paperless_mail/models.py index 5ebb89fa8..4e90197b7 100644 --- a/src/paperless_mail/models.py +++ b/src/paperless_mail/models.py @@ -60,11 +60,11 @@ class MailRule(models.Model): ATTACHMENTS_ONLY = 1, _("Only process attachments.") EVERYTHING = 2, _("Process all files, including 'inline' " "attachments.") - class AttachmentAction(models.IntegerChoices): - DELETE = 1, _("Mark as read, don't process read mails") - MOVE = 2, _("Flag the mail, don't process flagged mails") - MARK_READ = 3, _("Move to specified folder") - FLAG = 4, _("Delete") + class MailAction(models.IntegerChoices): + DELETE = 1, _("Delete") + MOVE = 2, _("Move to specified folder") + MARK_READ = 3, _("Mark as read, don't process read mails") + FLAG = 4, _("Flag the mail, don't process flagged mails") class TitleSource(models.IntegerChoices): FROM_SUBJECT = 1, _("Use subject as title") @@ -146,8 +146,8 @@ class MailRule(models.Model): action = models.PositiveIntegerField( _("action"), - choices=AttachmentAction.choices, - default=AttachmentAction.MARK_READ, + choices=MailAction.choices, + default=MailAction.MARK_READ, ) action_parameter = models.CharField( diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index 036caf086..cd56d0aac 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -478,7 +478,7 @@ class TestMail(DirectoriesMixin, TestCase): _ = MailRule.objects.create( name="testrule", account=account, - action=MailRule.AttachmentAction.MARK_READ, + action=MailRule.MailAction.MARK_READ, ) self.assertEqual(len(self.bogus_mailbox.messages), 3) @@ -501,7 +501,7 @@ class TestMail(DirectoriesMixin, TestCase): _ = MailRule.objects.create( name="testrule", account=account, - action=MailRule.AttachmentAction.DELETE, + action=MailRule.MailAction.DELETE, filter_subject="Invoice", ) @@ -522,7 +522,7 @@ class TestMail(DirectoriesMixin, TestCase): _ = MailRule.objects.create( name="testrule", account=account, - action=MailRule.AttachmentAction.FLAG, + action=MailRule.MailAction.FLAG, filter_subject="Invoice", ) @@ -545,7 +545,7 @@ class TestMail(DirectoriesMixin, TestCase): _ = MailRule.objects.create( name="testrule", account=account, - action=MailRule.AttachmentAction.MOVE, + action=MailRule.MailAction.MOVE, action_parameter="spam", filter_subject="Claim", ) @@ -591,7 +591,7 @@ class TestMail(DirectoriesMixin, TestCase): _ = MailRule.objects.create( name="testrule", account=account, - action=MailRule.AttachmentAction.MOVE, + action=MailRule.MailAction.MOVE, action_parameter="spam", filter_subject="Claim", ) @@ -612,7 +612,7 @@ class TestMail(DirectoriesMixin, TestCase): _ = MailRule.objects.create( name="testrule", account=account, - action=MailRule.AttachmentAction.MOVE, + action=MailRule.MailAction.MOVE, action_parameter="spam", filter_subject="Claim", order=1, @@ -621,7 +621,7 @@ class TestMail(DirectoriesMixin, TestCase): _ = MailRule.objects.create( name="testrule2", account=account, - action=MailRule.AttachmentAction.MOVE, + action=MailRule.MailAction.MOVE, action_parameter="spam", filter_subject="Claim", order=2, @@ -651,7 +651,7 @@ class TestMail(DirectoriesMixin, TestCase): _ = MailRule.objects.create( name="testrule", account=account, - action=MailRule.AttachmentAction.MOVE, + action=MailRule.MailAction.MOVE, action_parameter="spam", ) @@ -676,7 +676,7 @@ class TestMail(DirectoriesMixin, TestCase): name="testrule", filter_from="amazon@amazon.de", account=account, - action=MailRule.AttachmentAction.MOVE, + action=MailRule.MailAction.MOVE, action_parameter="spam", assign_correspondent_from=MailRule.CorrespondentSource.FROM_EMAIL, ) @@ -713,7 +713,7 @@ class TestMail(DirectoriesMixin, TestCase): rule = MailRule.objects.create( name="testrule3", account=account, - action=MailRule.AttachmentAction.DELETE, + action=MailRule.MailAction.DELETE, filter_subject="Claim", )