Sefaria / Sefaria-Project

New Interfaces for Jewish Texts
https://www.sefaria.org
654 stars 268 forks source link

fix(Category Editor): do not look for books that are not in the category being reordered #1995

Closed stevekaplan123 closed 1 month ago

stevekaplan123 commented 2 months ago

Description

We sometimes have categories with a book inside the category with the same title. For example, the category "Zohar" has the book "Zohar" inside of it. The Category Editor doesn't work properly in this case.

Code Changes

The Category Editor previously would look to re-order a book without checking that its path is inside the category being re-ordered. This was a reasonable assumption to make in most situations, but in the above case, this means that the book "Zohar" could get re-ordered when the intention was to re-order the category "Zohar". I fixed this by only looking for books to re-order that are actually inside the category being re-ordered. In the code, this means an Index is only loaded when its categories property is identical to the cat_path being re-ordered.