Skip to content

Commit c3e7b53

Browse files
Merge branch 'modularization-main' into modulrization-themes
2 parents 4d395c2 + 3142c03 commit c3e7b53

File tree

190 files changed

+4430
-2308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+4430
-2308
lines changed

.github/workflows/helm.yaml

+4-8
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,15 @@ jobs:
1414
- name: Checkout
1515
uses: actions/checkout@v2
1616
- name: Set up Helm
17-
uses: azure/setup-helm@v1
18-
with:
19-
version: v3.5.0
17+
uses: azure/setup-helm@v4.2.0
2018
- name: Set up Python
2119
uses: actions/setup-python@v2
22-
with:
23-
python-version: 3.7
2420
- name: Set up chart-testing
2521
uses: helm/chart-testing-action@v2.2.1
2622
with:
2723
version: v3.5.1
2824
- name: Lint chart
29-
run: ct lint --charts helm-chart/sefaria-project
25+
run: ct lint --charts helm-chart/sefaria
3026

3127
chart:
3228
name: Release Chart
@@ -87,9 +83,9 @@ jobs:
8783
wget -nv -nc -O yq https://github.com/mikefarah/yq/releases/download/v4.20.2/yq_linux_amd64
8884
chmod +x yq
8985
- name: Update chart version
90-
run: ./yq -i e '.version = "${{ steps.chartVersion.outputs.chartVersion }}"' helm-chart/sefaria-project/Chart.yaml
86+
run: ./yq -i e '.version = "${{ steps.chartVersion.outputs.chartVersion }}"' helm-chart/sefaria/Chart.yaml
9187
- name: Update chart appVersion
92-
run: ./yq -i e '.appVersion = "${{ steps.appVersion.outputs.appVersion }}"' helm-chart/sefaria-project/Chart.yaml
88+
run: ./yq -i e '.appVersion = "${{ steps.appVersion.outputs.appVersion }}"' helm-chart/sefaria/Chart.yaml
9389
- name: Publish Helm charts
9490
uses: stefanprodan/helm-gh-pages@master
9591
with:

.github/workflows/integration-setup.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,6 @@ jobs:
8484
URI="${URI}&replicaSet=${MONGO_REPLICASET_NAME}"
8585
fi
8686
mongorestore --drop --uri="$URI" -v -d sefaria-integration --dir=dump/sefaria
87+
if [[ $(date +%w) -eq "0" ]]; then
88+
mongorestore --drop --uri="$URI" -v -d sefaria --dir=dump/sefaria
89+
fi

.github/workflows/integration-testing.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
file: ./build/${{ matrix.app }}/Dockerfile
8383
tags: ${{ steps.meta.outputs.tags }}
8484
labels: ${{ steps.meta.outputs.labels }}
85+
8586
build-derived:
8687
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
8788
runs-on: ubuntu-latest
@@ -158,9 +159,9 @@ jobs:
158159
sudo apt-get update
159160
sudo apt-get install -y --no-install-recommends curl unzip
160161
- name: Setup kubectl
161-
uses: azure/setup-kubectl@v3
162+
uses: azure/setup-kubectl@v4
162163
- name: setup helm
163-
uses: azure/setup-helm@v3
164+
uses: azure/setup-helm@v4
164165
- name: Set up yq
165166
run: |
166167
curl -L https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O
@@ -200,7 +201,7 @@ jobs:
200201
PLAYWRIGHT_USER_PASSWORD: "${{ secrets.PLAYWRIGHT_USER_PASSWORD }}"
201202

202203
- name: Upload Playwright report
203-
uses: actions/upload-artifact@v3
204+
uses: actions/upload-artifact@v4
204205
if: always()
205206
with:
206207
name: playwright-report
@@ -215,7 +216,7 @@ jobs:
215216
- run-tests
216217
steps:
217218
- uses: actions/checkout@v4
218-
- uses: actions/setup-node@v2
219+
- uses: actions/setup-node@v3
219220
with:
220221
node-version: '14'
221222
- run: npm ci

.releaserc

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ plugins: [
3030
}]
3131
]
3232
branches: [
33-
{name: 'master'},
33+
{"name": "master"},
34+
{"name": "beta", "prerelease": "next"},
3435
]

build/ci/integration-helm-deploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ yq e -i '.secrets.localSettings.data.SEFARIA_DB = "sefaria-integration"' $1
2121
yq e -i '.ingress.hosts[0].host = strenv(GIT_COMMIT)+".integration.sefaria.org"' $1
2222
yq e -i '.localSettings.FRONT_END_URL = "https://"+strenv(GIT_COMMIT)+".integration.sefaria.org"' $1
2323

24-
helm upgrade -i $NAME ./helm-chart/sefaria-project --namespace $NAMESPACE -f $1 --debug --timeout=30m0s
24+
helm upgrade -i $NAME ./helm-chart/sefaria --namespace $NAMESPACE -f $1 --debug --timeout=30m0s
2525

build/ci/sandbox-helm-deploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ yq e -i '.monitor.containerImage.tag = strenv(TAG)' $1
1919
yq e -i '.deployEnv = strenv(NAME)' $1
2020
yq e -i '.localSettings.FRONT_END_URL = "https://"+strenv(NAME)+".cauldron.sefaria.org"' $1
2121

22-
helm upgrade -i $NAME ./helm-chart/sefaria-project --namespace $NAMESPACE -f $1 --debug --timeout=30m0s
22+
helm upgrade -i $NAME ./helm-chart/sefaria --namespace $NAMESPACE -f $1 --debug --timeout=30m0s
2323

dev_docker/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM python:3.9-slim
2+
3+
# Set the working directory to /app
4+
WORKDIR /app
5+
6+
# Copy the current directory contents into the container at /app
7+
COPY . /app
8+
9+
# Install dependencies
10+
RUN apt-get update && apt-get install -y \
11+
libpq-dev \
12+
gcc \
13+
git \
14+
&& apt-get update && apt-get install -y curl \
15+
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
16+
&& apt-get install -y nodejs
17+
18+
# Install any needed packages specified in requirements.txt
19+
RUN pip install --trusted-host pypi.python.org -r requirements.txt
20+
21+
# Make port 8000 available to the world outside this container
22+
EXPOSE 8000
23+
24+
# Command to run the application
25+
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

django_topics/admin.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from django.contrib import admin, messages
2-
from django.utils.html import format_html
3-
from django_topics.models import Topic, TopicPool, TopicOfTheDayEnglish, TopicOfTheDayHebrew, SeasonalTopicEnglish, SeasonalTopicHebrew
2+
from django_topics.models import Topic, TopicPool, FeaturedTopicEnglish, FeaturedTopicHebrew, SeasonalTopicEnglish, SeasonalTopicHebrew
43
from django_topics.models.pool import PoolType
4+
from django.utils.html import format_html
5+
56

67

78
def create_add_to_pool_action(pool_name):
@@ -70,6 +71,10 @@ class TopicAdmin(admin.ModelAdmin):
7071
create_remove_from_pool_action('general_he'),
7172
create_remove_from_pool_action(PoolType.TORAH_TAB.value),
7273
]
74+
def save_related(self, request, form, formsets, change):
75+
super().save_related(request, form, formsets, change)
76+
Topic.objects.build_slug_to_pools_cache(rebuild=True)
77+
7378

7479
def has_add_permission(self, request):
7580
return False
@@ -102,7 +107,7 @@ def sefaria_link(self, obj):
102107
sefaria_link.short_description = "Sefaria Link"
103108

104109

105-
class TopicOfTheDayAdmin(admin.ModelAdmin):
110+
class FeaturedTopicAdmin(admin.ModelAdmin):
106111
exclude = ("lang",) # not for manual editing
107112
list_display = ('start_date', 'topic')
108113
list_filter = ('start_date',)
@@ -123,16 +128,16 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):
123128
return super().formfield_for_foreignkey(db_field, request, **kwargs)
124129

125130

126-
@admin.register(TopicOfTheDayEnglish)
127-
class TopicOfTheDayAdminEnglish(TopicOfTheDayAdmin):
131+
@admin.register(FeaturedTopicEnglish)
132+
class FeaturedTopicAdminEnglish(FeaturedTopicAdmin):
128133

129134
def get_queryset(self, request):
130135
qs = super().get_queryset(request)
131136
return qs.filter(lang="en")
132137

133138

134-
@admin.register(TopicOfTheDayHebrew)
135-
class TopicOfTheDayAdminHebrew(TopicOfTheDayAdmin):
139+
@admin.register(FeaturedTopicHebrew)
140+
class FeaturedTopicAdminHebrew(FeaturedTopicAdmin):
136141

137142
def get_queryset(self, request):
138143
qs = super().get_queryset(request)

django_topics/migrations/0001_initial.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class Migration(migrations.Migration):
3232
migrations.CreateModel(
3333
name='Topic',
3434
fields=[
35-
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
36-
('slug', models.CharField(max_length=255, unique=True)),
35+
# ('id', models.AutoField(auto_created=True, serialize=False, verbose_name='ID')),
36+
('slug', models.CharField(max_length=255, primary_key=True, serialize=False, unique=True)),
3737
('en_title', models.CharField(blank=True, default='', max_length=255)),
3838
('he_title', models.CharField(blank=True, default='', max_length=255)),
3939
],

django_topics/migrations/0003_auto_20241121_0757.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class Migration(migrations.Migration):
1212
]
1313

1414
operations = [
15-
migrations.RemoveField(
16-
model_name='topic',
17-
name='id',
18-
),
19-
migrations.AlterField(
20-
model_name='topic',
21-
name='slug',
22-
field=models.CharField(max_length=255, primary_key=True, serialize=False),
23-
),
15+
# migrations.RemoveField(
16+
# model_name='topic',
17+
# name='id',
18+
# ),
19+
# migrations.AlterField(
20+
# model_name='topic',
21+
# name='slug',
22+
# field=models.CharField(max_length=255, primary_key=True, serialize=False),
23+
# ),
2424
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.29 on 2024-12-17 11:02
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('django_topics', '0007_auto_20241127_0034'),
12+
]
13+
14+
operations = [
15+
migrations.DeleteModel(
16+
name='TopicOfTheDayEnglish',
17+
),
18+
migrations.DeleteModel(
19+
name='TopicOfTheDayHebrew',
20+
),
21+
migrations.CreateModel(
22+
name='FeaturedTopicEnglish',
23+
fields=[
24+
],
25+
options={
26+
'verbose_name': 'Landing Page - Featured Topic (EN)',
27+
'verbose_name_plural': 'Landing Page - Featured Topic (EN)',
28+
'proxy': True,
29+
'indexes': [],
30+
},
31+
bases=('django_topics.topicoftheday',),
32+
),
33+
migrations.CreateModel(
34+
name='FeaturedTopicHebrew',
35+
fields=[
36+
],
37+
options={
38+
'verbose_name': 'Landing Page - Featured Topic (HE)',
39+
'verbose_name_plural': 'Landing Page - Featured Topic (HE)',
40+
'proxy': True,
41+
'indexes': [],
42+
},
43+
bases=('django_topics.topicoftheday',),
44+
),
45+
migrations.AlterModelOptions(
46+
name='topicoftheday',
47+
options={'verbose_name': 'Landing Page - Featured Topic', 'verbose_name_plural': 'Landing Page - Featured Topic'},
48+
),
49+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.29 on 2025-02-10 10:47
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('django_topics', '0008_auto_20241217_0702'),
12+
]
13+
14+
operations = [
15+
migrations.AlterUniqueTogether(
16+
name='topicoftheday',
17+
unique_together=set([('topic', 'start_date', 'lang')]),
18+
),
19+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.29 on 2025-02-16 10:39
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('django_topics', '0009_auto_20250210_0647'),
12+
]
13+
14+
operations = [
15+
migrations.AlterField(
16+
model_name='topic',
17+
name='slug',
18+
field=models.CharField(max_length=255, primary_key=True, serialize=False),
19+
),
20+
migrations.AlterUniqueTogether(
21+
name='seasonaltopic',
22+
unique_together=set([('topic', 'start_date', 'lang')]),
23+
),
24+
]

django_topics/models/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .topic import Topic
22
from .pool import TopicPool, PoolType
3-
from .topic_of_the_day import TopicOfTheDay, TopicOfTheDayEnglish, TopicOfTheDayHebrew
3+
from .featured_topic import TopicOfTheDay, FeaturedTopicEnglish, FeaturedTopicHebrew
44
from .seasonal_topic import SeasonalTopic, SeasonalTopicEnglish, SeasonalTopicHebrew
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from django.db import models
2+
from datetime import datetime
3+
from django.utils.timezone import now
4+
from django_topics.models import Topic
5+
6+
7+
class FeaturedTopicManager(models.Manager):
8+
9+
def get_featured_topic(self, lang: str, date: datetime = None) -> 'TopicOfTheDay':
10+
"""
11+
Return featured topic for given date or closest date that is less than or equal to given date
12+
@param lang: language code, "en" or "he"
13+
@param date: datetime object
14+
@return:
15+
"""
16+
date = date or now().date()
17+
return (
18+
self.filter(start_date__lte=date, lang=lang)
19+
.order_by('-start_date')
20+
.first()
21+
)
22+
23+
24+
class TopicOfTheDay(models.Model):
25+
topic = models.ForeignKey(
26+
Topic,
27+
on_delete=models.CASCADE,
28+
related_name='topic_of_the_day'
29+
)
30+
start_date = models.DateField()
31+
lang = models.CharField(max_length=2, choices=[('en', 'English'), ('he', 'Hebrew')])
32+
objects = FeaturedTopicManager()
33+
34+
class Meta:
35+
unique_together = ('topic', 'start_date', 'lang')
36+
verbose_name = "Landing Page - Featured Topic"
37+
verbose_name_plural = "Landing Page - Featured Topic"
38+
39+
def __str__(self):
40+
return f"{self.topic.slug} ({self.start_date})"
41+
42+
43+
class FeaturedTopicEnglish(TopicOfTheDay):
44+
class Meta:
45+
proxy = True
46+
verbose_name = "Landing Page - Featured Topic (EN)"
47+
verbose_name_plural = "Landing Page - Featured Topic (EN)"
48+
49+
def save(self, *args, **kwargs):
50+
self.lang = "en"
51+
super().save(*args, **kwargs)
52+
53+
54+
class FeaturedTopicHebrew(TopicOfTheDay):
55+
class Meta:
56+
proxy = True
57+
verbose_name = "Landing Page - Featured Topic (HE)"
58+
verbose_name_plural = "Landing Page - Featured Topic (HE)"
59+
60+
def save(self, *args, **kwargs):
61+
self.lang = "he"
62+
super().save(*args, **kwargs)

0 commit comments

Comments
 (0)