Skip to content

Commit fb1d463

Browse files
committed
Merge branch 'release/3.12.6'
2 parents 9a24efc + 25fd1f0 commit fb1d463

File tree

12 files changed

+82
-34
lines changed

12 files changed

+82
-34
lines changed

.github/workflows/crowdin-actions.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
uses: actions/checkout@v3
2020

2121
- name: Upload or update source files to Crowdin
22-
uses: crowdin/github-action@1.4.16
22+
uses: crowdin/github-action@1.5.0
2323
with:
2424
upload_sources: true
2525

2626
- name: Download German translations
27-
uses: crowdin/github-action@1.4.16
27+
uses: crowdin/github-action@1.5.0
2828
with:
2929
upload_sources: false
3030
download_translations: true
@@ -42,7 +42,7 @@ jobs:
4242
config: crowdin.yaml
4343

4444
- name: Download Spanish translations
45-
uses: crowdin/github-action@1.4.16
45+
uses: crowdin/github-action@1.5.0
4646
with:
4747
upload_sources: false
4848
download_translations: true

csfieldguide/chapters/management/commands/_ChapterSectionHeadingsLoader.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ def load(self):
4141
for language, content in self.content_translations.items():
4242
if content.heading_tree:
4343
for (i, heading_node) in enumerate(content.heading_tree):
44-
self.chapter_section.headings.create(
44+
self.chapter_section.headings.update_or_create(
4545
slug=heading_node.title_slug,
46-
name=heading_node.title,
47-
language=language,
48-
number=i,
46+
defaults={
47+
'name': heading_node.title,
48+
'language': language,
49+
'number': i,
50+
}
4951
)

csfieldguide/chapters/management/commands/_ChapterSectionsLoader.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,24 @@ def load(self):
6868
chapter_section_translations[language]["content"] = content.html_string
6969
chapter_section_translations[language]["name"] = content.title
7070

71-
chapter_section = self.chapter.chapter_sections.create(
71+
chapter_section, created = self.chapter.chapter_sections.update_or_create(
7272
slug=section_slug,
73-
number=section_number,
74-
languages=list(content_translations.keys()),
73+
defaults={
74+
'number': section_number,
75+
'languages': list(content_translations.keys()),
76+
}
7577
)
7678

7779
self.populate_translations(chapter_section, chapter_section_translations)
7880
self.mark_translation_availability(chapter_section, required_fields=["name", "content"])
7981

8082
chapter_section.save()
8183

82-
self.log("Added chapter section: {}".format(chapter_section.name), 1)
84+
if created:
85+
term = 'Created'
86+
else:
87+
term = 'Updated'
88+
self.log(f'{term} chapter section: {chapter_section.name}', 1)
8389

8490
check_interactives(
8591
content_translations[get_default_language()].required_files["interactives"],

csfieldguide/chapters/management/commands/_ChaptersLoader.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,25 @@ def load(self):
6767
if video != "" and "vimeo" not in video:
6868
raise ValueError("Video must be a Vimeo video.")
6969

70-
# Create chapter object and save to the db
71-
chapter = Chapter(
70+
# Create or update chapter object and save to the db
71+
chapter, created = Chapter.objects.update_or_create(
7272
slug=self.chapter_slug,
73-
number=self.chapter_number,
74-
icon=chapter_icon,
75-
video=video
73+
defaults={
74+
'number': self.chapter_number,
75+
'icon': chapter_icon,
76+
'video': video
77+
}
7678
)
7779

7880
self.populate_translations(chapter, chapter_translations)
7981
self.mark_translation_availability(chapter, required_fields=["name", "introduction"])
8082
chapter.save()
8183

82-
self.log("Added chapter: {}".format(chapter.name))
84+
if created:
85+
term = 'Created'
86+
else:
87+
term = 'Updated'
88+
self.log(f'{term} chapter: {chapter.name}')
8389

8490
check_interactives(
8591
introduction_translations[get_default_language()].required_files["interactives"],

csfieldguide/chapters/management/commands/_GlossaryTermsLoader.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ def load(self):
3232
term_translations[language]["definition"] = content.html_string
3333
term_translations[language]["term"] = content.title
3434

35-
glossary_term = GlossaryTerm(
35+
glossary_term, created = GlossaryTerm.objects.update_or_create(
3636
slug=glossary_slug,
3737
)
3838
self.populate_translations(glossary_term, term_translations)
3939
self.mark_translation_availability(glossary_term, required_fields=["term", "definition"])
4040
glossary_term.save()
4141

42-
self.log("Added glossary term: {}".format(glossary_term.__str__()))
42+
if created:
43+
term = 'Created'
44+
else:
45+
term = 'Updated'
46+
self.log(f'{term} glossary term: {glossary_term.__str__()}')
4347

4448
self.log("{} glossary terms loaded!\n".format(len(glossary_slugs)))

csfieldguide/config/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Module for Django system configuration."""
22

3-
__version__ = "3.12.5"
3+
__version__ = "3.12.6"

csfieldguide/curriculum_guides/management/commands/_CurriculumGuideSectionsLoader.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,24 @@ def load(self):
6868
curriculum_guide_section_translations[language]["content"] = content.html_string
6969
curriculum_guide_section_translations[language]["name"] = content.title
7070

71-
curriculum_guide_section = self.curriculum_guide.curriculum_guide_sections.create(
71+
curriculum_guide_section, created = self.curriculum_guide.curriculum_guide_sections.update_or_create(
7272
slug=section_slug,
73-
number=section_number,
74-
languages=list(content_translations.keys()),
73+
defaults={
74+
'number': section_number,
75+
'languages': list(content_translations.keys()),
76+
}
7577
)
7678

7779
self.populate_translations(curriculum_guide_section, curriculum_guide_section_translations)
7880
self.mark_translation_availability(curriculum_guide_section, required_fields=["name", "content"])
7981

8082
curriculum_guide_section.save()
8183

82-
self.log("Added curriculum guide section: {}".format(curriculum_guide_section.name), 1)
84+
if created:
85+
term = 'Created'
86+
else:
87+
term = 'Updated'
88+
self.log(f'{term} curriculum guide section: {curriculum_guide_section.name}', 1)
8389

8490
check_interactives(
8591
content_translations[get_default_language()].required_files["interactives"],

csfieldguide/curriculum_guides/management/commands/_CurriculumGuidesLoader.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,23 @@ def load(self):
4949
curriculum_guide_translations[language]["introduction"] = content.html_string
5050
curriculum_guide_translations[language]["name"] = content.title
5151

52-
# Create curriculum guide object and save to the db
53-
curriculum_guide = CurriculumGuide(
52+
# Create or update curriculum guide object and save to the db
53+
curriculum_guide, created = CurriculumGuide.objects.update_or_create(
5454
slug=self.curriculum_guide_slug,
55-
number=self.curriculum_guide_number,
55+
defaults={
56+
'number': self.curriculum_guide_number,
57+
}
5658
)
5759

5860
self.populate_translations(curriculum_guide, curriculum_guide_translations)
5961
self.mark_translation_availability(curriculum_guide, required_fields=["name", "introduction"])
6062
curriculum_guide.save()
6163

62-
self.log("Added curriculum guide: {}".format(curriculum_guide.name))
64+
if created:
65+
term = 'Created'
66+
else:
67+
term = 'Updated'
68+
self.log(f'{term} curriculum guide: {curriculum_guide.name}')
6369

6470
# Load curriculum guide sections
6571
content_path, structure_filename = os.path.split(sections)

csfieldguide/general/management/commands/update_data.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class Command(management.base.BaseCommand):
1010

1111
def handle(self, *args, **options):
1212
"""Automatically called when the update_data command is given."""
13-
management.call_command("flush", interactive=False)
1413
management.call_command("loadappendices")
1514
management.call_command("loadinteractives")
1615
management.call_command("loadchapters")

csfieldguide/interactives/management/commands/_InteractivesLoader.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ def load(self):
4848
use_large_thumbnail = interactive_data.get("use_large_thumbnail")
4949
if use_large_thumbnail is None:
5050
use_large_thumbnail = False
51-
interactive = Interactive(
51+
interactive, created = Interactive.objects.update_or_create(
5252
slug=interactive_slug,
53-
is_interactive=is_interactive,
54-
use_large_thumbnail=use_large_thumbnail,
53+
defaults={
54+
'is_interactive': is_interactive,
55+
'use_large_thumbnail': use_large_thumbnail,
56+
}
5557
)
5658
self.populate_translations(interactive, translations)
5759
self.mark_translation_availability(
@@ -60,4 +62,8 @@ def load(self):
6062
)
6163
interactive.save()
6264

63-
self.log("Added interactive: {}".format(interactive.__str__()))
65+
if created:
66+
term = 'Created'
67+
else:
68+
term = 'Updated'
69+
self.log(f'{term} interactive: {interactive.__str__()}')

docs/changelog.rst

+13
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ All notable changes to this project will be documented in this file.
1818
We have listed major changes for each release below.
1919
`All downloads are available on GitHub <https://github.com/uccser/cs-field-guide/releases/>`__
2020

21+
3.12.6
22+
==============================================================================
23+
24+
**Release date:** 3rd November 2022
25+
26+
**Changelog:**
27+
28+
- Update content rather than recreating it when `update_data` script is run.
29+
- Dependency updates:
30+
31+
- Update crowdin/github-action from 1.4.16 to 1.5.0.
32+
- Update sphinx-rtd-theme from 1.0.0 to 1.1.0.
33+
2134
3.12.5
2235
==============================================================================
2336

docs/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sphinx==5.3.0
2-
sphinx-rtd-theme==1.0.0
2+
sphinx-rtd-theme==1.1.0

0 commit comments

Comments
 (0)