from dateutil.parser import isoparse
from django.conf import settings
+ from django.utils import timezone
from documents.models import Comment
from documents.models import Document
+from guardian.shortcuts import get_users_with_perms
from whoosh import classify
from whoosh import highlight
from whoosh import query
tags = ",".join([t.name for t in doc.tags.all()])
tags_ids = ",".join([str(t.id) for t in doc.tags.all()])
comments = ",".join([str(c.comment) for c in Comment.objects.filter(document=doc)])
+ asn = doc.archive_serial_number
+ if asn is not None and (
+ asn < Document.ARCHIVE_SERIAL_NUMBER_MIN
+ or asn > Document.ARCHIVE_SERIAL_NUMBER_MAX
+ ):
+ logger.error(
+ f"Not indexing Archive Serial Number {asn} of document {doc.pk}. "
+ f"ASN is out of range "
+ f"[{Document.ARCHIVE_SERIAL_NUMBER_MIN:,}, "
+ f"{Document.ARCHIVE_SERIAL_NUMBER_MAX:,}.",
+ )
+ asn = 0
+ users_with_perms = get_users_with_perms(
+ doc,
+ only_with_perms_in=["view_document"],
+ )
+ viewer_ids = ",".join([str(u.id) for u in users_with_perms])
writer.update_document(
id=doc.pk,
title=doc.title,