Skip to content

Commit 8d59925

Browse files
Upgrades (#352)
* Upgrade JS dependencies and switch to jsdelivr to serve them * Upgrade python dependencies (Django 6.0)
1 parent 0a9fc50 commit 8d59925

25 files changed

Lines changed: 1048 additions & 588 deletions

.pre-commit-config.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 25.1.0
3+
rev: 25.12.0
44
hooks:
55
- id: black
66

77
- repo: https://github.com/pycqa/isort
8-
rev: 6.0.1
8+
rev: 7.0.0
99
hooks:
1010
- id: isort
1111

@@ -17,32 +17,32 @@ repos:
1717
files: \.html$
1818

1919
- repo: https://github.com/asottile/pyupgrade
20-
rev: v3.19.1
20+
rev: v3.21.2
2121
hooks:
2222
- id: pyupgrade
23-
args: [ "--py310-plus" ]
23+
args: [ "--py313-plus" ]
2424

2525
- repo: https://github.com/rtts/djhtml
26-
rev: '3.0.7'
26+
rev: '3.0.10'
2727
hooks:
2828
- id: djhtml
2929
- id: djcss
3030
- id: djjs
3131

3232
- repo: https://github.com/adamchainz/django-upgrade
33-
rev: 1.24.0
33+
rev: 1.29.1
3434
hooks:
3535
- id: django-upgrade
36-
args: [ --target-version, "4.1" ]
36+
args: [ --target-version, "6.0" ]
3737

3838
- repo: https://github.com/charliermarsh/ruff-pre-commit
39-
rev: 'v0.11.3'
39+
rev: 'v0.14.10'
4040
hooks:
4141
- id: ruff
4242
args: [--fix, --exit-non-zero-on-fix]
4343

4444
- repo: https://github.com/adamchainz/djade-pre-commit
45-
rev: '1.3.2'
45+
rev: '1.7.0'
4646
hooks:
4747
- id: djade
4848
args: [--target-version, "5.1"]

catalog/management/commands/download_programs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def handle(self, *args: Any, **options: Any) -> None:
7171
if mnemonic_span.text not in known_slugs:
7272
fac = mnemonic_span.find_previous_siblings("a")
7373
program_name = mnemonic_span.find_previous(
74-
"strong", "search-result__structure-intitule"
74+
"strong", {"class": "search-result__structure-intitule"}
7575
).text
7676

7777
faculties: list = []
@@ -91,13 +91,13 @@ def handle(self, *args: Any, **options: Any) -> None:
9191
}
9292

9393
if option_div := mnemonic_span.find_previous(
94-
"div", "search-result__resultat--fille"
94+
"div", {"class": "search-result__resultat--fille"}
9595
):
9696
parent_program_div = option_div.find_previous(
97-
"div", "search-result__result-item"
97+
"div", {"class": "search-result__result-item"}
9898
)
9999
parent_mnemonic_span = parent_program_div.find(
100-
"span", "search-result__mnemonique"
100+
"span", {"class": "search-result__mnemonique"}
101101
)
102102
p["parent"] = parent_mnemonic_span.text
103103
parent_programs.add(parent_mnemonic_span.text)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Generated by Django 6.0 on 2025-12-21 20:19
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("catalog", "0003_category_is_archive_course_is_archive"),
11+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12+
]
13+
14+
operations = [
15+
migrations.AlterUniqueTogether(
16+
name="coursecategory",
17+
unique_together=set(),
18+
),
19+
migrations.AlterUniqueTogether(
20+
name="courseuserview",
21+
unique_together=set(),
22+
),
23+
migrations.AlterField(
24+
model_name="category",
25+
name="id",
26+
field=models.BigAutoField(
27+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
28+
),
29+
),
30+
migrations.AlterField(
31+
model_name="course",
32+
name="id",
33+
field=models.BigAutoField(
34+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
35+
),
36+
),
37+
migrations.AlterField(
38+
model_name="coursecategory",
39+
name="id",
40+
field=models.BigAutoField(
41+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
42+
),
43+
),
44+
migrations.AlterField(
45+
model_name="courseuserview",
46+
name="id",
47+
field=models.BigAutoField(
48+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
49+
),
50+
),
51+
migrations.AddConstraint(
52+
model_name="coursecategory",
53+
constraint=models.UniqueConstraint(
54+
fields=("course", "category"), name="unique_course_category"
55+
),
56+
),
57+
migrations.AddConstraint(
58+
model_name="courseuserview",
59+
constraint=models.UniqueConstraint(
60+
fields=("user", "course"), name="unique_user_course_view"
61+
),
62+
),
63+
]

catalog/models.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class Course(models.Model):
108108
description = models.TextField(default="")
109109
period = models.CharField(
110110
max_length=4,
111-
choices=PeriodType.choices,
111+
choices=PeriodType,
112112
default=PeriodType.UNKNOWN,
113113
)
114114

@@ -142,7 +142,11 @@ class CourseCategory(models.Model):
142142
mandatory = models.BooleanField(default=True)
143143

144144
class Meta:
145-
unique_together = ("course", "category")
145+
constraints = [
146+
models.UniqueConstraint(
147+
fields=["course", "category"], name="unique_course_category"
148+
),
149+
]
146150

147151

148152
class CourseUserView(models.Model):
@@ -152,7 +156,11 @@ class CourseUserView(models.Model):
152156
last_view = models.DateTimeField(auto_now=True)
153157

154158
class Meta:
155-
unique_together = ("user", "course")
159+
constraints = [
160+
models.UniqueConstraint(
161+
fields=["user", "course"], name="unique_user_course_view"
162+
),
163+
]
156164

157165
@classmethod
158166
def visit(cls, user, course: Course):

catalog/suggestions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def distance(v1: list[bool], v2: list[bool]) -> float:
11-
absolute_difference = [abs(c1 - c2) for c1, c2 in zip(v1, v2)]
11+
absolute_difference = [abs(c1 - c2) for c1, c2 in zip(v1, v2, strict=True)]
1212
distance = sum(absolute_difference)
1313
return distance
1414

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Generated by Django 6.0 on 2025-12-21 20:19
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("documents", "0004_document_thumbnail"),
11+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12+
]
13+
14+
operations = [
15+
migrations.AlterUniqueTogether(
16+
name="vote",
17+
unique_together=set(),
18+
),
19+
migrations.AlterField(
20+
model_name="bulkdocuments",
21+
name="id",
22+
field=models.BigAutoField(
23+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
24+
),
25+
),
26+
migrations.AlterField(
27+
model_name="document",
28+
name="id",
29+
field=models.BigAutoField(
30+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
31+
),
32+
),
33+
migrations.AlterField(
34+
model_name="document",
35+
name="thumbnail",
36+
field=models.FileField(blank=True, default="", upload_to="thumbnail"),
37+
),
38+
migrations.AlterField(
39+
model_name="documenterror",
40+
name="id",
41+
field=models.BigAutoField(
42+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
43+
),
44+
),
45+
migrations.AlterField(
46+
model_name="vote",
47+
name="id",
48+
field=models.BigAutoField(
49+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
50+
),
51+
),
52+
migrations.AddConstraint(
53+
model_name="vote",
54+
constraint=models.UniqueConstraint(
55+
fields=("user", "document"), name="unique_user_document_vote"
56+
),
57+
),
58+
]

documents/models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class DocumentState(models.TextChoices):
5252
file_type = models.CharField(max_length=255, default="")
5353
original = models.FileField(upload_to="original_document")
5454
pdf = models.FileField(upload_to="pdf_document")
55-
thumbnail = models.FileField(upload_to="thumbnail", null=True)
55+
thumbnail = models.FileField(upload_to="thumbnail", blank=True, default="")
5656

5757
state = models.CharField(
5858
max_length=20,
@@ -179,7 +179,11 @@ class VoteType(models.TextChoices):
179179
vote_type = models.CharField(max_length=10, choices=VoteType.choices)
180180

181181
class Meta:
182-
unique_together = ("user", "document")
182+
constraints = [
183+
models.UniqueConstraint(
184+
fields=["user", "document"], name="unique_user_document_vote"
185+
),
186+
]
183187

184188

185189
class DocumentError(models.Model):

documents/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def repair(self, document_id: int) -> int:
219219
):
220220
try:
221221
subprocess.check_output(
222-
["mutool", "clean", "-gggg", "-l", tmpfile.name, output_path],
222+
["mutool", "clean", "-gggg", tmpfile.name, output_path],
223223
stderr=subprocess.STDOUT,
224224
)
225225
except OSError as e:

documents/templates/documents/document_edit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block title %}Éditer {{ doc.name }}{% endblock %}
44

55
{% block head %}
6-
<link href="https://unpkg.com/tom-select@2.3.1/dist/css/tom-select.bootstrap5.min.css"
6+
<link href="https://cdn.jsdelivr.net/npm/tom-select@2.4.3/dist/css/tom-select.bootstrap5.min.css"
77
rel="stylesheet" crossorigin="anonymous">
88
{% endblock head %}
99

documents/templates/documents/document_upload.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block title %}Ajouter un document à {{ course.slug|upper }}{% endblock %}
44

55
{% block head %}
6-
<link href="https://unpkg.com/tom-select@2.3.1/dist/css/tom-select.bootstrap5.min.css"
6+
<link href="https://cdn.jsdelivr.net/npm/tom-select@2.4.3/dist/css/tom-select.bootstrap5.min.css"
77
rel="stylesheet" crossorigin="anonymous">
88

99
<style>

0 commit comments

Comments
 (0)