updated the admin, ordering for mail rules

This commit is contained in:
Jonas Winkler 2020-11-21 23:12:34 +01:00
parent d3482a4aef
commit af3d161f66
5 changed files with 46 additions and 7 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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}")

View File

@ -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),
),
]

View File

@ -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",