def METHOD_NAME(attachment):
    """Update document status and send notifications is it is required"""
    not_run_files = DocumentFileAttachment.objects.filter(
        document=attachment.document,
        security_scan_status='NOT RUN',
        is_removed=False
    )
    in_progress_files = DocumentFileAttachment.objects.filter(
        document=attachment.document,
        security_scan_status='IN PROGRESS',
        is_removed=False
    )
    failed_files = DocumentFileAttachment.objects.filter(
        document=attachment.document,
        security_scan_status='FAIL',
        is_removed=False
    )
    if len(not_run_files) > 0 or len(in_progress_files) > 0:
        # The verdict is not in yet
        return
    user = attachment.document.update_user
    if user is None:
        user = attachment.document.create_user
    if len(failed_files) > 0:
        attachment.document.status = DocumentStatus.objects.get(
            status="Security Scan Failed")
        attachment.document.save()
        DocumentService.send_notification(attachment.document, user)
    elif attachment.document.status.status == "Pending Submission":
        submitted_status = DocumentStatus.objects.get(status="Submitted")
        attachment.document.status = submitted_status
        attachment.document.save()
        DocumentService.send_notification(attachment.document, user)