mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Merge pull request #765 from p-h-a-i-l/fix-mail-action-mixup
fix Mail actions mixup
This commit is contained in:
commit
68e3612d36
@ -62,13 +62,13 @@ class FlagMailAction(BaseMailAction):
|
|||||||
|
|
||||||
|
|
||||||
def get_rule_action(rule):
|
def get_rule_action(rule):
|
||||||
if rule.action == MailRule.AttachmentAction.FLAG:
|
if rule.action == MailRule.MailAction.FLAG:
|
||||||
return FlagMailAction()
|
return FlagMailAction()
|
||||||
elif rule.action == MailRule.AttachmentAction.DELETE:
|
elif rule.action == MailRule.MailAction.DELETE:
|
||||||
return DeleteMailAction()
|
return DeleteMailAction()
|
||||||
elif rule.action == MailRule.AttachmentAction.MOVE:
|
elif rule.action == MailRule.MailAction.MOVE:
|
||||||
return MoveMailAction()
|
return MoveMailAction()
|
||||||
elif rule.action == MailRule.AttachmentAction.MARK_READ:
|
elif rule.action == MailRule.MailAction.MARK_READ:
|
||||||
return MarkReadMailAction()
|
return MarkReadMailAction()
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("Unknown action.") # pragma: nocover
|
raise NotImplementedError("Unknown action.") # pragma: nocover
|
||||||
|
27
src/paperless_mail/migrations/0014_alter_mailrule_action.py
Normal file
27
src/paperless_mail/migrations/0014_alter_mailrule_action.py
Normal file
@ -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",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
@ -60,11 +60,11 @@ class MailRule(models.Model):
|
|||||||
ATTACHMENTS_ONLY = 1, _("Only process attachments.")
|
ATTACHMENTS_ONLY = 1, _("Only process attachments.")
|
||||||
EVERYTHING = 2, _("Process all files, including 'inline' " "attachments.")
|
EVERYTHING = 2, _("Process all files, including 'inline' " "attachments.")
|
||||||
|
|
||||||
class AttachmentAction(models.IntegerChoices):
|
class MailAction(models.IntegerChoices):
|
||||||
DELETE = 1, _("Mark as read, don't process read mails")
|
DELETE = 1, _("Delete")
|
||||||
MOVE = 2, _("Flag the mail, don't process flagged mails")
|
MOVE = 2, _("Move to specified folder")
|
||||||
MARK_READ = 3, _("Move to specified folder")
|
MARK_READ = 3, _("Mark as read, don't process read mails")
|
||||||
FLAG = 4, _("Delete")
|
FLAG = 4, _("Flag the mail, don't process flagged mails")
|
||||||
|
|
||||||
class TitleSource(models.IntegerChoices):
|
class TitleSource(models.IntegerChoices):
|
||||||
FROM_SUBJECT = 1, _("Use subject as title")
|
FROM_SUBJECT = 1, _("Use subject as title")
|
||||||
@ -146,8 +146,8 @@ class MailRule(models.Model):
|
|||||||
|
|
||||||
action = models.PositiveIntegerField(
|
action = models.PositiveIntegerField(
|
||||||
_("action"),
|
_("action"),
|
||||||
choices=AttachmentAction.choices,
|
choices=MailAction.choices,
|
||||||
default=AttachmentAction.MARK_READ,
|
default=MailAction.MARK_READ,
|
||||||
)
|
)
|
||||||
|
|
||||||
action_parameter = models.CharField(
|
action_parameter = models.CharField(
|
||||||
|
@ -478,7 +478,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
_ = MailRule.objects.create(
|
_ = MailRule.objects.create(
|
||||||
name="testrule",
|
name="testrule",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.MARK_READ,
|
action=MailRule.MailAction.MARK_READ,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(len(self.bogus_mailbox.messages), 3)
|
self.assertEqual(len(self.bogus_mailbox.messages), 3)
|
||||||
@ -501,7 +501,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
_ = MailRule.objects.create(
|
_ = MailRule.objects.create(
|
||||||
name="testrule",
|
name="testrule",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.DELETE,
|
action=MailRule.MailAction.DELETE,
|
||||||
filter_subject="Invoice",
|
filter_subject="Invoice",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
_ = MailRule.objects.create(
|
_ = MailRule.objects.create(
|
||||||
name="testrule",
|
name="testrule",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.FLAG,
|
action=MailRule.MailAction.FLAG,
|
||||||
filter_subject="Invoice",
|
filter_subject="Invoice",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -545,7 +545,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
_ = MailRule.objects.create(
|
_ = MailRule.objects.create(
|
||||||
name="testrule",
|
name="testrule",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.MOVE,
|
action=MailRule.MailAction.MOVE,
|
||||||
action_parameter="spam",
|
action_parameter="spam",
|
||||||
filter_subject="Claim",
|
filter_subject="Claim",
|
||||||
)
|
)
|
||||||
@ -591,7 +591,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
_ = MailRule.objects.create(
|
_ = MailRule.objects.create(
|
||||||
name="testrule",
|
name="testrule",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.MOVE,
|
action=MailRule.MailAction.MOVE,
|
||||||
action_parameter="spam",
|
action_parameter="spam",
|
||||||
filter_subject="Claim",
|
filter_subject="Claim",
|
||||||
)
|
)
|
||||||
@ -612,7 +612,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
_ = MailRule.objects.create(
|
_ = MailRule.objects.create(
|
||||||
name="testrule",
|
name="testrule",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.MOVE,
|
action=MailRule.MailAction.MOVE,
|
||||||
action_parameter="spam",
|
action_parameter="spam",
|
||||||
filter_subject="Claim",
|
filter_subject="Claim",
|
||||||
order=1,
|
order=1,
|
||||||
@ -621,7 +621,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
_ = MailRule.objects.create(
|
_ = MailRule.objects.create(
|
||||||
name="testrule2",
|
name="testrule2",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.MOVE,
|
action=MailRule.MailAction.MOVE,
|
||||||
action_parameter="spam",
|
action_parameter="spam",
|
||||||
filter_subject="Claim",
|
filter_subject="Claim",
|
||||||
order=2,
|
order=2,
|
||||||
@ -651,7 +651,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
_ = MailRule.objects.create(
|
_ = MailRule.objects.create(
|
||||||
name="testrule",
|
name="testrule",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.MOVE,
|
action=MailRule.MailAction.MOVE,
|
||||||
action_parameter="spam",
|
action_parameter="spam",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -676,7 +676,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
name="testrule",
|
name="testrule",
|
||||||
filter_from="amazon@amazon.de",
|
filter_from="amazon@amazon.de",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.MOVE,
|
action=MailRule.MailAction.MOVE,
|
||||||
action_parameter="spam",
|
action_parameter="spam",
|
||||||
assign_correspondent_from=MailRule.CorrespondentSource.FROM_EMAIL,
|
assign_correspondent_from=MailRule.CorrespondentSource.FROM_EMAIL,
|
||||||
)
|
)
|
||||||
@ -713,7 +713,7 @@ class TestMail(DirectoriesMixin, TestCase):
|
|||||||
rule = MailRule.objects.create(
|
rule = MailRule.objects.create(
|
||||||
name="testrule3",
|
name="testrule3",
|
||||||
account=account,
|
account=account,
|
||||||
action=MailRule.AttachmentAction.DELETE,
|
action=MailRule.MailAction.DELETE,
|
||||||
filter_subject="Claim",
|
filter_subject="Claim",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user