Skip to content

Commit

Permalink
fix smartlink functionality in case we don't know about a standard
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed Oct 2, 2023
1 parent fadf288 commit ac9a597
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions application/web/web_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,13 @@ def smartlink(
name: str, ntype: str = defs.Credoctypes.Standard.value, section: str = ""
) -> Any:
"""if node is found, show node, else redirect"""
# ATTENTION: DO NOT MESS WITH THIS FUNCTIONALITY WITHOUT A TICKET AND CORE CONTRIBUTORS APPROVAL!
# CRITICAL FUNCTIONALITY DEPENDS ON THIS!
database = db.Node_collection()
opt_version = request.args.get("version")
# match ntype to the credoctypes case-insensitive
typ = [t for t in defs.Credoctypes if t.value.lower() == ntype.lower()]
doctype = None
if typ:
doctype = typ[0]
typ = [t.value for t in defs.Credoctypes if t.value.lower() == ntype.lower()]
doctype = None if not typ else typ[0]

page = 1
items_per_page = 1
Expand Down Expand Up @@ -327,9 +327,7 @@ def smartlink(
if found_section_id:
return redirect(f"/node/{ntype}/{name}/sectionid/{section}")
return redirect(f"/node/{ntype}/{name}/section/{section}")
elif ntype == defs.Credoctypes.Standard.value and redirectors.redirect(
name, section
):
elif doctype == defs.Credoctypes.Standard.value and redirectors.redirect(name, section):
logger.info(
f"did not find node of type {ntype}, name {name} and section {section}, redirecting to external resource"
)
Expand Down

0 comments on commit ac9a597

Please sign in to comment.