Skip to content

Commit

Permalink
Prevent concepts outside collection from being selectable, re #10306
Browse files Browse the repository at this point in the history
  • Loading branch information
chiatt committed Nov 29, 2023
1 parent d5aeb49 commit 0d928fd
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions arches/app/views/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,42 +392,6 @@ def paged_dropdown(request):
for d in data
]

# This try/except block trys to find an exact match to the concept the user is searching and if found
# it will insert it into the results as the first item so that users don't have to scroll to find it.
# See: https://github.com/archesproject/arches/issues/8355
try:
if page == 1:
found = False
for i, d in enumerate(data):
if i <= 7 and d["text"].lower() == query.lower():
found = True
break
if not found:
languageid = get_language().lower()
cursor = connection.cursor()
cursor.execute(
"""
SELECT value, valueid
FROM
(
SELECT *, CASE WHEN LOWER(languageid) = %(languageid)s THEN 10
WHEN LOWER(languageid) like %(short_languageid)s THEN 5
ELSE 0
END score
FROM values
) as vals
WHERE LOWER(value)=%(query)s AND score > 0
AND valuetype in ('prefLabel')
ORDER BY score desc limit 1
""",
{"languageid": languageid, "short_languageid": languageid.split("-")[0] + "%", "query": query.lower()},
)
rows = cursor.fetchall()

if len(rows) == 1:
data.insert(0, {"id": str(rows[0][1]), "text": rows[0][0], "depth": 1, "collector": False})
except:
pass

return JSONResponse({"results": data, "more": offset + limit < total_count})

Expand Down

0 comments on commit 0d928fd

Please sign in to comment.