Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ runs:
# API can be unreliable
run: |
sudo apt update
sudo apt install python3-dev libldap2-dev libsasl2-dev libssl-dev -o Acquire::Retries=3
sudo apt install --yes --no-install-recommends -o Acquire::Retries=3 \
python3-dev libldap2-dev libsasl2-dev libssl-dev gettext

- name: Install uv
uses: astral-sh/setup-uv@v7
Expand Down
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

_(If any of the points are not relevant, mark them as checked, so that it's easy to see which points you've handled or not)_

- [ ] I've run `makemigrations`, `makemessages` and `compilemessages`
- [ ] I've written tests that fail without these changes (if relevant/possible)
- [ ] I've manually tested the website UI with different device layouts
- _Most common is to test with typical screen sizes for mobile (320-425 px), tablet (768 px) and desktop (1024+ px), which can easily be done with your browser's dev tools_
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies = [
"django-ckeditor==6.7.0",
"django-cleanup==8.1.0",
"django-constance==3.1.0",
"django-decorator-include==3.0",
"django-decorator-include==3.3",
# (See this page for a list of all management commands:
# https://django-extensions.readthedocs.io/en/latest/command_extensions.html)
"django-extensions==3.2.3",
Expand Down
2 changes: 1 addition & 1 deletion src/checkin/migrations/0004_auto_20180906_1855.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Migration(migrations.Migration):
name="suggestskill",
options={
"ordering": ("title",),
"permissions": (("can_force_suggestion", "Can force suggestion"),),
"permissions": [("can_force_suggestion", "Can force suggestion")],
},
),
]
32 changes: 0 additions & 32 deletions src/locale/nb/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2283,35 +2283,3 @@ msgstr "Velg verdi"

msgid "Search places"
msgstr "Søk etter steder"

#~ msgid "You have completed the Raise3D printer course"
#~ msgstr "Du har fullført Raise3D-printerkurset"

#~ msgid "You have not taken the Raise3D printer course"
#~ msgstr "Du har ikke tatt Raise3D-printerkurset"

#~ msgid ""
#~ "To use a Raise3D printer, make a reservation in the calendar of one of "
#~ "the Raise3D printers on the “Reservations” page."
#~ msgstr ""
#~ "For å bruke en Raise3D-printer, lag en reservasjon i kalenderen til en av "
#~ "Raise3D-printerne på «Reservasjoner»-siden."

#~ msgid "You have completed the SLA 3D printer course"
#~ msgstr "Du har fullført SLA 3D-printerkurset"

#~ msgid "You have not taken the SLA 3D printer course"
#~ msgstr "Du har ikke tatt SLA 3D-printerkurset"

#~ msgid ""
#~ "To use an SLA 3D printer, make a reservation in the calendar of one of "
#~ "the SLA 3D printers on the “Reservations” page."
#~ msgstr ""
#~ "For å bruke en SLA 3D-printer, lag en reservasjon i kalenderen til en av "
#~ "SLA 3D-printerne på «Reservasjoner»-siden."

#~ msgid "Raise3D course"
#~ msgstr "Raise3D-kurs"

#~ msgid "SLA course"
#~ msgstr "SLA-kurs"
4 changes: 2 additions & 2 deletions src/make_queue/migrations/0007_auto_20180914_1306.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class Migration(migrations.Migration):
),
],
options={
"permissions": (
"permissions": [
("can_view_reservation_user", "Can view reservation user"),
),
],
},
),
migrations.DeleteModel(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 5.0.2 on 2026-03-24 22:40

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
(
"make_queue",
"0035_coursepermission_printer3dcourse_course_permissions_and_more",
),
]

operations = [
migrations.AlterField(
model_name="coursepermission",
name="short_name",
field=models.CharField(
blank=True, max_length=4, unique=True, verbose_name="short name"
),
),
migrations.AlterField(
model_name="machinetype",
name="usage_requirement",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="make_queue.coursepermission",
verbose_name="usage requirement",
),
),
]
4 changes: 2 additions & 2 deletions src/news/migrations/0022_abstract_newsbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Migration(migrations.Migration):
],
options={
"ordering": ("-publication_time",),
"permissions": (("can_view_private", "Can view private articles"),),
"permissions": [("can_view_private", "Can view private articles")],
"abstract": False,
},
),
Expand Down Expand Up @@ -176,7 +176,7 @@ class Migration(migrations.Migration):
),
],
options={
"permissions": (("can_view_private", "Can view private events"),),
"permissions": [("can_view_private", "Can view private events")],
"abstract": False,
},
),
Expand Down
Empty file.
15 changes: 15 additions & 0 deletions src/web/tests/management/test_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import io
from unittest import TestCase as StandardTestCase

from django.core import management


class CheckTests(StandardTestCase):
def test__check__identifies_no_issues(self):
out = io.StringIO()
err = io.StringIO()
management.call_command("check", fail_level="WARNING", stdout=out, stderr=err)
self.assertEqual(
out.getvalue().strip(), "System check identified no issues (0 silenced)."
)
self.assertEqual(err.getvalue().strip(), "")
69 changes: 69 additions & 0 deletions src/web/tests/management/test_compilemessages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import io
import re
from pathlib import Path
from unittest import TestCase as StandardTestCase

from django.core import management

from web.tests.management.test_makemessages import (
LocaleFileType,
get_project_locale_files,
)


class CompilessagesTests(StandardTestCase):
def test_mo_files_are_up_to_date(self):
before_contents = self.get_mo_file_contents()

# For some reason, changes in the `.po` files are often not reflected in
# the `.mo` files when running `compilemessages` - unless the `.mo` files
# are deleted first, in which case they seem to be consistently updated
self.delete_mo_files()
management.call_command("compilemessages")

after_contents = self.get_mo_file_contents()

if after_contents != before_contents:
self.fail(
f"\n{'#' * 52}"
"\n### One or more of the `.mo` files are outdated! ###"
"\n### Run `make compilemessages` to fix this. ###"
f"\n{'#' * 52}"
)

self._test_compilemessages_only_processes_our_mo_files()

@staticmethod
def get_mo_file_contents() -> dict[Path, bytes]:
return {
path: path.read_bytes()
for path in get_project_locale_files(LocaleFileType.MO)
}

@staticmethod
def delete_mo_files():
for path in get_project_locale_files(LocaleFileType.MO):
path.unlink()

def _test_compilemessages_only_processes_our_mo_files(self):
"""Test that the ``compilemessages`` command only processes ``.mo`` files inside
our project apps (see the comment above
``web.management.commands.makemessages.Command.DEFAULT_IGNORED_DIRS``).

NOTE: This should only be called after confirming that the ``.mo`` files are up
to date, as that's assumed to be the case when checking the command
output.
"""
out = io.StringIO()
err = io.StringIO()
management.call_command("compilemessages", stdout=out, stderr=err)
output = out.getvalue().strip()
self.assertFalse(err.getvalue().strip())

# Example line: `File “path/to/file.po” is already compiled and up to date.`
file_paths = {
Path(path) for path in re.findall(r"[\w\s]*“(.+)”[\w\s]*", output)
}
self.assertSetEqual(
file_paths, set(get_project_locale_files(LocaleFileType.PO))
)
55 changes: 55 additions & 0 deletions src/web/tests/management/test_makemessages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from enum import StrEnum
from pathlib import Path
from unittest import TestCase as StandardTestCase

from django.conf import settings
from django.core import management


class LocaleFileType(StrEnum):
PO = ".po"
MO = ".mo"


def get_project_locale_files(file_type: LocaleFileType) -> list[Path]:
return [
file_path
for dir_path in settings.LOCALE_PATHS
for file_path in Path(dir_path).rglob(f"*{file_type}")
]


class MakemessagesTests(StandardTestCase):
def test_po_files_are_up_to_date(self):
before_contents = self.get_po_file_contents()
management.call_command("makemessages", all=True)
management.call_command("makemessages", all=True, domain="djangojs")
after_contents = self.get_po_file_contents()

self.maxDiff = None
self.assertEqual(after_contents, before_contents)
if after_contents != before_contents:
self.fail(
f"\n{'#' * 52}"
"\n### One or more of the `.po` files are outdated! ###"
"\n### Run `make makemessages-all` to fix this. ###"
f"\n{'#' * 52}"
)

@classmethod
def get_po_file_contents(cls) -> dict[Path, str]:
def get_contents(path: Path) -> str:
contents = path.read_text(encoding="utf-8")
# Remove the `POT-Creation-Date:` line, as it can change even if no other
# parts of the contents have changed, leading to false test failures
contents = "\n".join(
line
for line in contents.splitlines()
if not line.startswith('"POT-Creation-Date:')
)
return contents

return {
path: get_contents(path)
for path in get_project_locale_files(LocaleFileType.PO)
}
19 changes: 19 additions & 0 deletions src/web/tests/management/test_makemigrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import io
from unittest import TestCase as StandardTestCase

from django.core import management


class MakemigrationsTests(StandardTestCase):
def test__makemigrations__detects_no_changes(self):
out = io.StringIO()
err = io.StringIO()
management.call_command("makemigrations", dry_run=True, stdout=out, stderr=err)
self.assertEqual(err.getvalue().strip(), "")
if out.getvalue().strip() != "No changes detected":
self.fail(
f"\n{'#' * 63}"
"\n### There are changes in the code that are not reflected in ###"
"\n### the migrations! Run `make makemigrations` to fix this. ###"
f"\n{'#' * 63}"
)
14 changes: 14 additions & 0 deletions src/web/tests/management/test_shell_plus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import subprocess
import sys
from unittest import TestCase as StandardTestCase


class ShellPlusTests(StandardTestCase):
def test__shell_plus__starts_successfully(self):
result = subprocess.run( # noqa: PLW1510
[sys.executable, "manage.py", "shell_plus", "--command=pass"],
capture_output=True,
)
error_output = result.stderr.decode().strip()
self.assertEqual(error_output, "")
result.check_returncode()
9 changes: 3 additions & 6 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading