Skip to content

Commit

Permalink
fix(api texts): sections and toSections for Talmud addressType, add c…
Browse files Browse the repository at this point in the history
…ollective title.
  • Loading branch information
YishaiGlasner committed Jun 18, 2023
1 parent 37d2459 commit f1c8814
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions api/texts_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
django.setup()
from sefaria.model import *
from sefaria.datatype.jagged_array import JaggedArray
from sefaria.utils.hebrew import hebrew_term
from enum import Enum

class APITextsHandler():
Expand Down Expand Up @@ -77,16 +78,16 @@ def _add_ref_data(self):
self.return_obj.update({
'ref': oref.normal(),
'heRef': oref.he_normal(),
'sections': oref.sections,
'toSections': oref.toSections,
'sections': oref.normal_sections(), #that means it will be string. in the previous api talmud sections were strings while integers remained integets. this is more consistent but we should check it works
'toSections': oref.normal_toSections(),
'sectionRef': oref.section_ref().normal(),
'heSectionRef': oref.section_ref().he_normal(),
'firstAvailableSectionRef': oref.first_available_section_ref().normal(),
'isSpanning': oref.is_spanning(),
'spanningRefs': [r.normal() for r in oref.split_spanning_ref()],
'next': oref.next_section_ref().normal(),
'prev': oref.prev_section_ref().normal(),
'title': oref.context_ref().normal(),
'prev': oref.prev_section_ref().normal() if oref.prev_section_ref() else None,
'title': oref.context_ref().normal() if oref.next_section_ref() else None,
'book': oref.book,
'heTitle': oref.context_ref().he_normal(),
'primary_category': oref.primary_category,
Expand Down Expand Up @@ -151,6 +152,8 @@ def _add_index_data(self):
'isComplex': index.is_complex(),
'isDependant': index.is_dependant_text(),
'order': getattr(index, 'order', ''),
'collectiveTitle': getattr(index, 'collective_title', ''),
'heCollectiveTitle': hebrew_term(getattr(index, 'collective_title', '')),
'alts': self._reduce_alts_to_ref(),
})

Expand Down

0 comments on commit f1c8814

Please sign in to comment.