Skip to content

Commit e499cb8

Browse files
Merge branch 'release/3.15.0'
2 parents fd86fb9 + 3d29ec9 commit e499cb8

File tree

72 files changed

+1827
-992
lines changed

Some content is hidden

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

72 files changed

+1827
-992
lines changed

.github/workflows/auto-merge-dependency-updates.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- name: Dependabot metadata
1515
id: metadata
16-
uses: dependabot/fetch-metadata@v2.0.0
16+
uses: dependabot/fetch-metadata@v2.1.0
1717
with:
1818
github-token: "${{ secrets.GITHUB_TOKEN }}"
1919
- name: Approve

.github/workflows/test-and-deploy.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ jobs:
6868
with:
6969
files: ./csfieldguide/coverage.xml
7070
verbose: true
71+
env:
72+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7173

7274
test-management:
7375
name: Tests - Management
@@ -84,6 +86,8 @@ jobs:
8486
with:
8587
files: ./csfieldguide/coverage.xml
8688
verbose: true
89+
env:
90+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8791

8892
test-style:
8993
name: Tests - Style

.readthedocs.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Read the Docs configuration file for Sphinx projects
2+
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
6+
# Required
7+
8+
version: 2
9+
10+
11+
# Set the OS, Python version and other tools you might need
12+
13+
build:
14+
15+
os: ubuntu-22.04
16+
17+
tools:
18+
19+
python: "3.12"
20+
21+
# You can also specify other tool versions:
22+
23+
# nodejs: "20"
24+
25+
# rust: "1.70"
26+
27+
# golang: "1.20"
28+
29+
30+
# Build documentation in the "docs/" directory with Sphinx
31+
32+
sphinx:
33+
34+
configuration: docs/conf.py
35+
36+
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
37+
38+
# builder: "dirhtml"
39+
40+
# Fail on all warnings to avoid broken references
41+
42+
# fail_on_warning: true
43+
44+
45+
# Optionally build your docs in additional formats such as PDF and ePub
46+
47+
# formats:
48+
49+
# - pdf
50+
51+
# - epub
52+
53+
54+
# Optional but recommended, declare the Python requirements required
55+
56+
# to build your documentation
57+
58+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
59+
60+
# python:
61+
62+
# install:
63+
64+
# - requirements: docs/requirements.txt
Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""Custom loader for loading appendices."""
22

3+
from django.db import transaction
4+
from appendices.models import Appendix
35
from utils.TranslatableModelLoader import TranslatableModelLoader
46
from utils.errors.MissingRequiredFieldError import MissingRequiredFieldError
57
from utils.errors.InvalidYAMLValueError import InvalidYAMLValueError
68
from django.template.loader import get_template
79
from django.template import TemplateDoesNotExist
10+
from django.urls import reverse, NoReverseMatch
811

912

1013
class AppendicesLoader(TranslatableModelLoader):
@@ -19,36 +22,68 @@ def __init__(self, factory, **kwargs):
1922
super().__init__(**kwargs)
2023
self.factory = factory
2124

22-
def check_template(self, page_data, type):
23-
"""Check template in page_data is valid.
25+
@transaction.atomic
26+
def load(self):
27+
"""Load appendices pages.
2428
25-
Args:
26-
page_data (dict): Dictionary of page data.
27-
type (str): Name of type of page.
29+
Raise:
30+
MissingRequiredFieldError: when no object can be found with the matching
31+
attribute.
32+
InvalidYAMLValueError: when invalid template path given or missing valid URL in urls.
33+
"""
34+
appendix_pages = self.load_yaml_file(self.structure_file_path)
2835

29-
Returns:
30-
A valid template as string.
36+
for (slug, page_data) in appendix_pages.items():
37+
try:
38+
template = page_data["template"]
39+
except (TypeError, KeyError):
40+
raise MissingRequiredFieldError(
41+
self.structure_file_path,
42+
[
43+
"template",
44+
],
45+
"Appendix"
46+
)
3147

32-
Raises:
33-
MissingRequiredFieldError: If template value not given.
34-
InvalidYAMLValueError: If invalid template path given.
35-
"""
36-
try:
37-
template = page_data["template"]
38-
except (TypeError, KeyError):
39-
raise MissingRequiredFieldError(
40-
self.structure_file_path,
41-
[
48+
# Check template is valid
49+
try:
50+
get_template(template)
51+
except TemplateDoesNotExist:
52+
raise InvalidYAMLValueError(
53+
self.structure_file_path,
4254
"template",
43-
],
44-
type
45-
)
46-
try:
47-
get_template(template)
48-
except TemplateDoesNotExist:
49-
raise InvalidYAMLValueError(
50-
self.structure_file_path,
51-
"template ({})".format(template),
52-
"A valid template file path"
55+
"A valid template file path"
56+
)
57+
58+
# Check URL name is valid
59+
url_name = f"appendices:{slug}"
60+
try:
61+
reverse(url_name)
62+
except NoReverseMatch:
63+
raise InvalidYAMLValueError(
64+
self.structure_file_path,
65+
f"<{slug}>",
66+
f"A URL name listed in 'csfieldguide/appendices/urls.py' matching '{url_name}'."
67+
)
68+
69+
# Get Title Case from kebab-case name
70+
name = slug.title().replace('-', ' ')
71+
72+
appendix_page, created = Appendix.objects.update_or_create(
73+
slug=slug,
74+
defaults={
75+
'name': name,
76+
'template': template,
77+
'url_name': url_name,
78+
}
5379
)
54-
return template
80+
appendix_page.save()
81+
if created:
82+
term = 'Created'
83+
else:
84+
term = 'Updated'
85+
self.log(f'{term} appendix page: {name}')
86+
87+
Appendix.objects.exclude(slug__in=appendix_pages.keys()).delete()
88+
89+
self.log("All appendix pages loaded!\n")

csfieldguide/appendices/management/commands/loadappendices.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ def handle(self, *args, **options):
2424
base_path=base_path
2525
)
2626

27+
loader.load()
2728
loader.log("All appendices loaded!")
2829
loader.log("")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Generated by Django 4.2.9 on 2024-02-01 03:19
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
('appendices', '0007_auto_20190209_2354'),
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='AppendixPage',
17+
fields=[
18+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19+
('slug', models.SlugField(unique=True)),
20+
('name', models.CharField(max_length=100)),
21+
('template', models.CharField(max_length=100)),
22+
('url_name', models.CharField(max_length=100)),
23+
],
24+
),
25+
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated by Django 4.2.9 on 2024-02-02 01:48
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('appendices', '0008_initial'),
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name='Appendix',
15+
fields=[
16+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17+
('slug', models.SlugField(unique=True)),
18+
('name', models.CharField(max_length=100)),
19+
('template', models.CharField(max_length=100)),
20+
('url_name', models.CharField(max_length=100)),
21+
],
22+
),
23+
migrations.DeleteModel(
24+
name='AppendixPage',
25+
),
26+
]

csfieldguide/appendices/models.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""Models for the appendices application."""
2+
3+
from django.db import models
4+
from django.urls import reverse
5+
from django.utils.translation import gettext_lazy as _
6+
from search.utils import get_template_text
7+
8+
9+
class Appendix(models.Model):
10+
"""Model for appendix page in database."""
11+
12+
MODEL_NAME = _("Appendix")
13+
14+
# Auto-incrementing 'id' field is automatically set by Django
15+
slug = models.SlugField(unique=True)
16+
name = models.CharField(max_length=100)
17+
template = models.CharField(max_length=100)
18+
url_name = models.CharField(max_length=100)
19+
20+
def get_absolute_url(self):
21+
"""Return the canonical URL for a Appendix.
22+
23+
Returns:
24+
URL as string.
25+
"""
26+
return reverse(self.url_name)
27+
28+
def __str__(self):
29+
"""Text representation of Appendix object.
30+
31+
Returns:
32+
Name of page (str).
33+
"""
34+
return self.name
35+
36+
def index_contents(self):
37+
"""Return dictionary for search indexing.
38+
39+
Returns:
40+
Dictionary of content for search indexing. The dictionary keys
41+
are the weightings of content, and the dictionary values
42+
are strings of content to index.
43+
"""
44+
return {
45+
'A': self.name,
46+
'B': get_template_text(self.template),
47+
}
48+
49+
class Meta:
50+
"""Set consistent ordering of appendices."""
51+
52+
ordering = ["name"]
53+
verbose_name = _("appendix")
54+
verbose_name_plural = _("appendices")

csfieldguide/chapters/content/en/big-data/sections/analysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Here are two prominent examples:
7373
- This is used for investigating social structures using networks.
7474
You can imagine how this works by thinking about the structure of Facebook.
7575
You and everyone else on Facebook are each an individual node, and two people are connected by an edge if they are Facebook friends.
76-
Together, these nodes and edges make a graph structure (a different type of [graph](https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)) to the ones you normally see in maths) that can be analysed.
76+
Together, these nodes and edges make a graph structure (a different type of [graph](https://en.wikipedia.org/wiki/Graph_%28discrete_mathematics%29) to the ones you normally see in maths) that can be analysed.
7777

7878
{image file-path="img/chapters/social-network-graph.png" caption="true" alt="Five circles with different names in them are shown with lines connecting each of them to illustrate that they are connected on social media. Each of these circles is then connected to several smaller circles, which represent other friends in their network."}
7979

csfieldguide/chapters/content/en/coding-error-control/sections/the-parity-magic-trick.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The original 7x7 cards that the computer laid out for you could be some kind of
5656
Although they are laid out in a grid, on a computer the rows of bits would be stored or transmitted one after the other (as 8 lots of 8 bits).
5757

5858
The extra cards you added are called *parity bits*.
59-
[Parity](https://en.wikipedia.org/wiki/Parity_(mathematics))
59+
[Parity](https://en.wikipedia.org/wiki/Parity_%28mathematics%29)
6060
simply means whether a number is even or odd (the word comes from the same root as "pair").
6161
By adding the extra cards in a way that ensured an even number of black cards in each row and column, you made it so that the rows and columns had what is called *even parity*.
6262

csfieldguide/chapters/content/en/coding-introduction/sections/further-reading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ James Gleick's book [The Information: A History, a Theory, a Flood](http://www.a
55
## Useful links
66

77
- A good collection of resources related to all three kinds of coding is available in the [Bletchley Park Codes Resources](http://www.cimt.org.uk/resources/codes/)
8-
- [Entropy and information theory](https://en.wikipedia.org/wiki/Entropy_(information_theory))
8+
- [Entropy and information theory](https://en.wikipedia.org/wiki/Entropy_%28information_theory%29)
99
- [History of information theory and its relationship to entropy in thermodynamics](https://en.wikipedia.org/wiki/History_of_entropy#Information_theory)
1010
- [Timeline of information theory](https://en.wikipedia.org/wiki/Timeline_of_information_theory)
1111
- [Shannon's seminal work in information theory](https://en.wikipedia.org/wiki/A_Mathematical_Theory_of_Communication)

csfieldguide/chapters/content/en/complexity-and-tractability/sections/other-intractable-problems.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Extra sections will eventually be added here to introduce some of them, but in t
1919
- [Longest path](https://en.wikipedia.org/wiki/Longest_path) (this is interesting because finding the longest path is intractable, yet finding the shortest path is tractable - the shortest path is calculated when a GPS device works out the shortest route to a destination.
2020
Also, a Hamiltonian problem can be reduced easily to longest path, showing the concept of reduction when one NP-complete problem is used to solve another).
2121
[Here's a song about it!](https://www.youtube.com/watch?feature=player_embedded&v=a3ww0gwEszo)
22-
- [The Battleship problem](https://en.wikipedia.org/wiki/Battleship_(puzzle))
22+
- [The Battleship problem](https://en.wikipedia.org/wiki/Battleship_%28puzzle%29)

csfieldguide/chapters/content/en/computer-graphics/sections/further-reading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
- [Computer graphics on Wikipedia](https://en.wikipedia.org/wiki/Computer_graphics)
44
- [Transformation matrix on Wikipedia](https://en.wikipedia.org/wiki/Transformation_matrix)
55
- [Bresenham's line algorithm on Wikipedia](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm)
6-
- [Ray tracing on Wikipedia](https://en.wikipedia.org/wiki/Ray_tracing_(graphics))
6+
- [Ray tracing on Wikipedia](https://en.wikipedia.org/wiki/Ray_tracing_%28graphics%29)
77
- [3D tutorials from POV-Ray](http://www.povray.org/resources/links/3D_Tutorials/POV-Ray_Tutorials/)

csfieldguide/chapters/content/en/software-engineering/sections/further-reading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- [Wikipedia &ndash; Software crisis](https://en.wikipedia.org/wiki/Software_crisis)
77
- [IEEE &ndash; Why software fails](http://spectrum.ieee.org/computing/software/why-software-fails)
88
- [Wikipedia &ndash; Software design](https://en.wikipedia.org/wiki/Software_design)
9-
- [Wikipedia &ndash; Abstraction](https://en.wikipedia.org/wiki/Abstraction_(computer_science))
9+
- [Wikipedia &ndash; Abstraction](https://en.wikipedia.org/wiki/Abstraction_%28computer_science%29)
1010
- [Wikipedia &ndash; Software testing](https://en.wikipedia.org/wiki/Software_testing)
1111
- [Wikipedia &ndash; Software development process](https://en.wikipedia.org/wiki/Software_development_process)
1212
- [Wikipedia &ndash; Waterfall model](https://en.wikipedia.org/wiki/Waterfall_model)

csfieldguide/chapters/content/structure/human-computer-interaction/sections/sections.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ interface-usability:
1010
usability-heuristics:
1111
section-number: 4
1212

13-
mātāpono-māori:
13+
maataapono-maaori:
1414
section-number: 5
15+
slug: mātāpono-māori
1516

1617
accessibility:
1718
section-number: 6

0 commit comments

Comments
 (0)