mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Enhancement: unique mail rule names by owner
This commit is contained in:
parent
d8c96b6e4a
commit
81e4092f53
@ -5,9 +5,7 @@ from documents.tests.utils import TestMigrations
|
||||
class TestMigrateWorkflow(TestMigrations):
|
||||
migrate_from = "1043_alter_savedviewfilterrule_rule_type"
|
||||
migrate_to = "1044_workflow_workflowaction_workflowtrigger_and_more"
|
||||
dependencies = (
|
||||
("paperless_mail", "0023_remove_mailrule_filter_attachment_filename_and_more"),
|
||||
)
|
||||
dependencies = (("paperless_mail", "0024_alter_mailrule_name_and_more"),)
|
||||
|
||||
def setUpBeforeMigration(self, apps):
|
||||
User = apps.get_model("auth", "User")
|
||||
|
@ -0,0 +1,33 @@
|
||||
# Generated by Django 4.2.11 on 2024-06-05 16:51
|
||||
|
||||
from django.db import migrations
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("paperless_mail", "0023_remove_mailrule_filter_attachment_filename_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="mailrule",
|
||||
name="name",
|
||||
field=models.CharField(max_length=256, verbose_name="name"),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="mailrule",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("name", "owner"),
|
||||
name="paperless_mail_mailrule_unique_name_owner",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="mailrule",
|
||||
constraint=models.UniqueConstraint(
|
||||
condition=models.Q(("owner__isnull", True)),
|
||||
fields=("name",),
|
||||
name="paperless_mail_mailrule_name_unique",
|
||||
),
|
||||
),
|
||||
]
|
@ -59,6 +59,17 @@ class MailRule(document_models.ModelWithOwner):
|
||||
class Meta:
|
||||
verbose_name = _("mail rule")
|
||||
verbose_name_plural = _("mail rules")
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["name", "owner"],
|
||||
name="%(app_label)s_%(class)s_unique_name_owner",
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
name="%(app_label)s_%(class)s_name_unique",
|
||||
fields=["name"],
|
||||
condition=models.Q(owner__isnull=True),
|
||||
),
|
||||
]
|
||||
|
||||
class ConsumptionScope(models.IntegerChoices):
|
||||
ATTACHMENTS_ONLY = 1, _("Only process attachments.")
|
||||
@ -93,7 +104,7 @@ class MailRule(document_models.ModelWithOwner):
|
||||
FROM_NAME = 3, _("Use name (or mail address if not available)")
|
||||
FROM_CUSTOM = 4, _("Use correspondent selected below")
|
||||
|
||||
name = models.CharField(_("name"), max_length=256, unique=True)
|
||||
name = models.CharField(_("name"), max_length=256)
|
||||
|
||||
order = models.IntegerField(_("order"), default=0)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user