From b72706356d20883832a1f3b513ad8a998a17d1f0 Mon Sep 17 00:00:00 2001
From: Philip Sargent <philip.sargent@gmail.com>
Date: Sat, 6 Nov 2021 23:37:31 +0200
Subject: [PATCH] fixed mistaken DataIssue report

---
 parsers/drawings.py | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/parsers/drawings.py b/parsers/drawings.py
index 8c45aae..d0a2257 100644
--- a/parsers/drawings.py
+++ b/parsers/drawings.py
@@ -54,7 +54,10 @@ def find_dwg_file(dwgfile, path):
             scansfilel = wallet.singlescan_set.filter(name=mscansdir.group(2))
             if len(scansfilel):
                 if len(scansfilel) > 1:
-                    message = "! More than one image FILENAME matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.dwgpath, path)
+                    plist =[]
+                    for sf in scansfilel:
+                        plist.append(sf.ffile)
+                    message = "! More than one image FILENAME matches filter query. [{}]: {} {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.dwgpath, path, plist)
                     print(message)
                     DataIssue.objects.create(parser='Tunnel', message=message)
                 scansfile = scansfilel[0]
@@ -68,11 +71,15 @@ def find_dwg_file(dwgfile, path):
         name = os.path.split(path)[1]
         rdwgfilel = DrawingFile.objects.filter(dwgname=name)
         if len(rdwgfilel):
-            message = "! Two paths with same name [{}]: {}".format(path, name)
-            print(message)
-            DataIssue.objects.create(parser='Tunnel', message=message)
-            rdwgfile = rdwgfilel[0]
-            dwgfile.dwgcontains.add(rdwgfile)
+            if len(rdwgfilel) > 1:
+                plist =[]
+                for df in rdwgfilel:
+                    plist.append(df.dwgname)
+                message = f"! {len(rdwgfilel)} paths found with same name '{path}' {plist}"
+                print(message)
+                DataIssue.objects.create(parser='Tunnel', message=message)
+                rdwgfile = rdwgfilel[0]
+                dwgfile.dwgcontains.add(rdwgfile)
 
     dwgfile.save()