Skip to content

Commit

Permalink
fix(linker): fix issue with deletion so that it also deletes the desc…
Browse files Browse the repository at this point in the history
…ription and relies on curatedPrimacy to determine if link has been deleted from all langs.
  • Loading branch information
nsantacruz committed Jun 26, 2024
1 parent 18e83d7 commit c045f34
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sefaria/helper/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,12 +1320,13 @@ def delete_ref_topic_link(tref, to_topic, link_type, lang):
if link is None:
return {"error": f"A learning-team link between {tref} and {to_topic} doesn't exist. If you are trying to delete a non-learning-team link, reach out to the engineering team."}

if lang in link.order.get('availableLangs', []):
link.order['availableLangs'].remove(lang)
if lang in link.order.get('curatedPrimacy', []):
link.order['curatedPrimacy'].pop(lang)
if lang in getattr(link, 'descriptions', {}):
link.descriptions.pop(lang)

if len(link.order.get('availableLangs', [])) > 0:
# Note, using curatedPrimacy as a proxy here since we are currently only allowing deletion of learning-team links.
if len(link.order.get('curatedPrimacy', [])) > 0:
link.save()
return {"status": "ok"}
else: # deleted in both hebrew and english so delete link object
Expand Down

0 comments on commit c045f34

Please sign in to comment.