diff --git a/src/documents/admin.py b/src/documents/admin.py index 5b3975fda..8b9f2fce9 100755 --- a/src/documents/admin.py +++ b/src/documents/admin.py @@ -51,15 +51,16 @@ class DocumentAdmin(admin.ModelAdmin): search_fields = ("correspondent__name", "title", "content", "tags__name") readonly_fields = ("added", "mime_type", "storage_type", "filename") + + list_display_links = ("title",) + list_display = ( - "title", - "created", - "added", "correspondent", + "title", "tags_", - "archive_serial_number", - "document_type" + "created", ) + list_filter = ( "document_type", "tags", @@ -117,9 +118,19 @@ class DocumentAdmin(admin.ModelAdmin): class LogAdmin(admin.ModelAdmin): + def has_add_permission(self, request): + return False + + def has_change_permission(self, request, obj=None): + return False + list_display = ("created", "message", "level",) list_filter = ("level", "created",) + ordering = ('-created',) + + list_display_links = ("created", "message") + admin.site.register(Correspondent, CorrespondentAdmin) admin.site.register(Tag, TagAdmin) diff --git a/src/paperless_mail/admin.py b/src/paperless_mail/admin.py index 8d05c2a42..d8560c418 100644 --- a/src/paperless_mail/admin.py +++ b/src/paperless_mail/admin.py @@ -11,7 +11,15 @@ class MailRuleAdmin(admin.ModelAdmin): list_filter = ("account",) - list_display = ("name", "account", "folder", "action") + list_display = ("order", "name", "account", "folder", "action") + + list_editable = ("order", ) + + list_display_links = ("name", ) + + sortable_by = [] + + ordering = ["order"] admin.site.register(MailAccount, MailAccountAdmin) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index 9d0397f24..dfdfa09ce 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -161,7 +161,7 @@ class MailAccountHandler(LoggingMixin): self.log('debug', f"Account {account}: Processing " f"{account.rules.count()} rule(s)") - for rule in account.rules.all(): + for rule in account.rules.order_by('order'): self.log( 'debug', f"Account {account}: Processing rule {rule.name}") diff --git a/src/paperless_mail/migrations/0004_mailrule_order.py b/src/paperless_mail/migrations/0004_mailrule_order.py new file mode 100644 index 000000000..498f280a1 --- /dev/null +++ b/src/paperless_mail/migrations/0004_mailrule_order.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.3 on 2020-11-21 21:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('paperless_mail', '0003_auto_20201118_1940'), + ] + + operations = [ + migrations.AddField( + model_name='mailrule', + name='order', + field=models.IntegerField(default=0), + ), + ] diff --git a/src/paperless_mail/models.py b/src/paperless_mail/models.py index 14da202fa..c8ab09479 100644 --- a/src/paperless_mail/models.py +++ b/src/paperless_mail/models.py @@ -78,6 +78,8 @@ class MailRule(models.Model): name = models.CharField(max_length=256, unique=True) + order = models.IntegerField(default=0) + account = models.ForeignKey( MailAccount, related_name="rules",