Skip to content

Commit

Permalink
Merge pull request #1939 from Sefaria/fix-source-delete-topic-page-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nsantacruz authored Jun 26, 2024
2 parents 18e83d7 + c045f34 commit 642d293
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 642d293

Please sign in to comment.