This commit is contained in:
jonaswinkler
2020-12-12 01:19:22 +01:00
parent 6d924e6f5c
commit 23354f8a00
2 changed files with 21 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ from django.contrib.admin.models import ADDITION, LogEntry
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.db import models, DatabaseError
from django.db.models import Q
from django.dispatch import receiver
from django.utils import timezone
from filelock import FileLock
@@ -121,11 +122,14 @@ def set_tags(sender,
classifier=None,
replace=False,
**kwargs):
if replace:
document.tags.clear()
current_tags = set([])
else:
current_tags = set(document.tags.all())
document.tags.exclude(
Q(is_inbox_tag=True) |
(Q(match="") & ~Q(matching_algorithm=Tag.MATCH_AUTO))
).delete()
current_tags = set(document.tags.all())
matched_tags = matching.match_tags(document.content, classifier)