示例#1
0
    def generate_parasha_topics_story(cls, parasha_obj, mustHave, iteration, k,
                                      **kwargs):
        from sefaria.utils.calendars import make_parashah_response_from_calendar_entry
        from sefaria.helper.topic import get_topic_by_parasha
        from sefaria.model.topic import Topic
        page = iteration - 1
        topic = get_topic_by_parasha(parasha_obj["parasha"])
        if not topic:
            return
        link_set = topic.link_set(_class='intraTopic', page=page, limit=k)
        related_topics = list(
            filter(None, [Topic.init(l.topic) for l in link_set]))
        if len(related_topics) < k:
            return

        cal = make_parashah_response_from_calendar_entry(parasha_obj)[0]

        return cls.generate_story(topics=related_topics,
                                  title={
                                      "en":
                                      "Topics in " + cal["displayValue"]["en"],
                                      "he":
                                      "נושאים ב" + cal["displayValue"]["he"]
                                  },
                                  lead={
                                      "en": "Weekly Torah Portion",
                                      "he": 'פרשת השבוע'
                                  },
                                  mustHave=mustHave or [],
                                  **kwargs)
示例#2
0
        def _create_parasha_sheet_story(parasha_obj, mustHave=None, **kwargs):
            from sefaria.utils.calendars import make_parashah_response_from_calendar_entry
            from sefaria.helper.topic import get_topic_by_parasha
            cal = make_parashah_response_from_calendar_entry(parasha_obj)[0]
            topic = get_topic_by_parasha(parasha_obj["parasha"])
            if not topic:
                return
            sheet_ids = cls._get_topic_sheet_ids(topic,
                                                 k=k,
                                                 page=iteration - 1)
            if len(sheet_ids) < k:
                return

            mustHave = mustHave or []
            mustHave = mustHave + ["usesSheets"]

            cls.generate_story(sheet_ids=sheet_ids,
                               title={
                                   "en":
                                   "Sheets on " + cal["displayValue"]["en"],
                                   "he":
                                   "גליונות על " + cal["displayValue"]["he"]
                               },
                               lead={
                                   "en": "Weekly Torah Portion",
                                   "he": 'פרשת השבוע'
                               },
                               mustHave=mustHave,
                               **kwargs).save()