-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'modularization-main' into sheets-editor-final
- Loading branch information
Showing
169 changed files
with
2,717 additions
and
949 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,19 +14,15 @@ jobs: | |
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: v3.5.0 | ||
uses: azure/[email protected] | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
- name: Set up chart-testing | ||
uses: helm/[email protected] | ||
with: | ||
version: v3.5.1 | ||
- name: Lint chart | ||
run: ct lint --charts helm-chart/sefaria-project | ||
run: ct lint --charts helm-chart/sefaria | ||
|
||
chart: | ||
name: Release Chart | ||
|
@@ -87,9 +83,9 @@ jobs: | |
wget -nv -nc -O yq https://github.com/mikefarah/yq/releases/download/v4.20.2/yq_linux_amd64 | ||
chmod +x yq | ||
- name: Update chart version | ||
run: ./yq -i e '.version = "${{ steps.chartVersion.outputs.chartVersion }}"' helm-chart/sefaria-project/Chart.yaml | ||
run: ./yq -i e '.version = "${{ steps.chartVersion.outputs.chartVersion }}"' helm-chart/sefaria/Chart.yaml | ||
- name: Update chart appVersion | ||
run: ./yq -i e '.appVersion = "${{ steps.appVersion.outputs.appVersion }}"' helm-chart/sefaria-project/Chart.yaml | ||
run: ./yq -i e '.appVersion = "${{ steps.appVersion.outputs.appVersion }}"' helm-chart/sefaria/Chart.yaml | ||
- name: Publish Helm charts | ||
uses: stefanprodan/helm-gh-pages@master | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.29 on 2024-12-17 11:02 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('django_topics', '0007_auto_20241127_0034'), | ||
] | ||
|
||
operations = [ | ||
migrations.DeleteModel( | ||
name='TopicOfTheDayEnglish', | ||
), | ||
migrations.DeleteModel( | ||
name='TopicOfTheDayHebrew', | ||
), | ||
migrations.CreateModel( | ||
name='FeaturedTopicEnglish', | ||
fields=[ | ||
], | ||
options={ | ||
'verbose_name': 'Landing Page - Featured Topic (EN)', | ||
'verbose_name_plural': 'Landing Page - Featured Topic (EN)', | ||
'proxy': True, | ||
'indexes': [], | ||
}, | ||
bases=('django_topics.topicoftheday',), | ||
), | ||
migrations.CreateModel( | ||
name='FeaturedTopicHebrew', | ||
fields=[ | ||
], | ||
options={ | ||
'verbose_name': 'Landing Page - Featured Topic (HE)', | ||
'verbose_name_plural': 'Landing Page - Featured Topic (HE)', | ||
'proxy': True, | ||
'indexes': [], | ||
}, | ||
bases=('django_topics.topicoftheday',), | ||
), | ||
migrations.AlterModelOptions( | ||
name='topicoftheday', | ||
options={'verbose_name': 'Landing Page - Featured Topic', 'verbose_name_plural': 'Landing Page - Featured Topic'}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.29 on 2025-02-10 10:47 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('django_topics', '0008_auto_20241217_0702'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterUniqueTogether( | ||
name='topicoftheday', | ||
unique_together=set([('topic', 'start_date', 'lang')]), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .topic import Topic | ||
from .pool import TopicPool, PoolType | ||
from .topic_of_the_day import TopicOfTheDay, TopicOfTheDayEnglish, TopicOfTheDayHebrew | ||
from .featured_topic import TopicOfTheDay, FeaturedTopicEnglish, FeaturedTopicHebrew | ||
from .seasonal_topic import SeasonalTopic, SeasonalTopicEnglish, SeasonalTopicHebrew |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from django.db import models | ||
from datetime import datetime | ||
from django.utils.timezone import now | ||
from django_topics.models import Topic | ||
|
||
|
||
class FeaturedTopicManager(models.Manager): | ||
|
||
def get_featured_topic(self, lang: str, date: datetime = None) -> 'TopicOfTheDay': | ||
""" | ||
Return featured topic for given date or closest date that is less than or equal to given date | ||
@param lang: language code, "en" or "he" | ||
@param date: datetime object | ||
@return: | ||
""" | ||
date = date or now().date() | ||
return ( | ||
self.filter(start_date__lte=date, lang=lang) | ||
.order_by('-start_date') | ||
.first() | ||
) | ||
|
||
|
||
class TopicOfTheDay(models.Model): | ||
topic = models.ForeignKey( | ||
Topic, | ||
on_delete=models.CASCADE, | ||
related_name='topic_of_the_day' | ||
) | ||
start_date = models.DateField() | ||
lang = models.CharField(max_length=2, choices=[('en', 'English'), ('he', 'Hebrew')]) | ||
objects = FeaturedTopicManager() | ||
|
||
class Meta: | ||
unique_together = ('topic', 'start_date', 'lang') | ||
verbose_name = "Landing Page - Featured Topic" | ||
verbose_name_plural = "Landing Page - Featured Topic" | ||
|
||
def __str__(self): | ||
return f"{self.topic.slug} ({self.start_date})" | ||
|
||
|
||
class FeaturedTopicEnglish(TopicOfTheDay): | ||
class Meta: | ||
proxy = True | ||
verbose_name = "Landing Page - Featured Topic (EN)" | ||
verbose_name_plural = "Landing Page - Featured Topic (EN)" | ||
|
||
def save(self, *args, **kwargs): | ||
self.lang = "en" | ||
super().save(*args, **kwargs) | ||
|
||
|
||
class FeaturedTopicHebrew(TopicOfTheDay): | ||
class Meta: | ||
proxy = True | ||
verbose_name = "Landing Page - Featured Topic (HE)" | ||
verbose_name_plural = "Landing Page - Featured Topic (HE)" | ||
|
||
def save(self, *args, **kwargs): | ||
self.lang = "he" | ||
super().save(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pytest | ||
from datetime import date | ||
from django_topics.models import TopicOfTheDay, Topic | ||
|
||
|
||
@pytest.fixture | ||
def topic(db): | ||
"""Fixture to create a Topic instance.""" | ||
return Topic.objects.create(slug="test-topic") | ||
|
||
|
||
@pytest.fixture | ||
def featured_topics(db, topic): | ||
"""Fixture to create TopicOfTheDay instances.""" | ||
topics = [ | ||
TopicOfTheDay.objects.create(topic=topic, start_date=date(2024, 11, 26), lang="en"), | ||
TopicOfTheDay.objects.create(topic=topic, start_date=date(2024, 11, 25), lang="en"), | ||
TopicOfTheDay.objects.create(topic=topic, start_date=date(2024, 11, 24), lang="en"), | ||
] | ||
return topics | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_get_featured_topic_with_exact_date_db(featured_topics): | ||
"""Test for exact match.""" | ||
result = TopicOfTheDay.objects.get_featured_topic(lang="en", date=date(2024, 11, 26)) | ||
|
||
assert result.start_date == date(2024, 11, 26) | ||
assert result.lang == "en" | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_get_featured_topic_with_closest_date_db(featured_topics): | ||
"""Test for the closest date less than or equal to the given date.""" | ||
result = TopicOfTheDay.objects.get_featured_topic(lang="en", date=date(2024, 11, 27)) | ||
|
||
assert result.start_date == date(2024, 11, 26) | ||
assert result.lang == "en" | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_get_featured_topic_with_no_matching_date_db(db, topic): | ||
"""Test when there is no matching date.""" | ||
TopicOfTheDay.objects.create(topic=topic, start_date=date(2024, 11, 20), lang="en") | ||
result = TopicOfTheDay.objects.get_featured_topic(lang="en", date=date(2024, 11, 19)) | ||
|
||
assert result is None |
Oops, something went wrong.