Skip to content

Commit

Permalink
Fix #1204 - Upgrade Django to 4.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsasha committed Feb 27, 2024
1 parent c4a9dae commit 5854529
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 97 deletions.
2 changes: 1 addition & 1 deletion checks/probes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright: 2022, ECP, NLnet Labs and the Internet.nl contributors
# SPDX-License-Identifier: Apache-2.0
from django.conf import settings
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from checks import categories
from checks.categories import MailTlsStarttlsExists, WebTlsHttpsExists
Expand Down
2 changes: 1 addition & 1 deletion interface/batch/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def get_user_from_request(request):
DB) return the relevant user object from the DB.
"""
username = request.META.get("REMOTE_USER") or request.META.get("HTTP_REMOTE_USER")
username = request.META.get("REMOTE_USER") or request.headers.get("remote-user")
if not username:
username = getattr(settings, "BATCH_TEST_USER", None)
user, created = BatchUser.objects.get_or_create(username=username)
Expand Down
4 changes: 2 additions & 2 deletions interface/conntesturls/ipv4_urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright: 2022, ECP, NLnet Labs and the Internet.nl contributors
# SPDX-License-Identifier: Apache-2.0
from django.conf.urls import url
from django.urls import path

from interface.views.connection import network_ipv4

urlpatterns = [
url(r"^$", network_ipv4),
path("", network_ipv4),
]
4 changes: 2 additions & 2 deletions interface/conntesturls/ipv6_urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright: 2022, ECP, NLnet Labs and the Internet.nl contributors
# SPDX-License-Identifier: Apache-2.0
from django.conf.urls import url
from django.urls import path

from interface.views.connection import aaaa_ipv6

urlpatterns = [
url(r"^$", aaaa_ipv6),
path("", aaaa_ipv6),
]
4 changes: 2 additions & 2 deletions interface/conntesturls/resolver_urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright: 2022, ECP, NLnet Labs and the Internet.nl contributors
# SPDX-License-Identifier: Apache-2.0
from django.conf.urls import url
from django.urls import path

from interface.views.connection import network_resolver

urlpatterns = [
url(r"^$", network_resolver),
path("", network_resolver),
]
4 changes: 2 additions & 2 deletions interface/templates/base-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
{% include "string.html" with name="results score-description"%}
</div>
{% block perfectscore %}
{% ifequal score 100 %}
{% if score == 100 %}
<div class="perfect-score">
{% include "string.html" with name="results perfect-score" %}
</div>
{% endifequal %}
{% endif %}
{% endblock %}
<div class="score-container">
<p class="score" aria-hidden="true">{{score}}%</p>
Expand Down
10 changes: 5 additions & 5 deletions interface/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@

<nav id="sitenav">
<ul>
<li class="{% ifequal pagemenu 'home' %}current{% endifequal %}"><a href="/">{% include "string.html" with name="base home" %}</a></li>
<li class="{% if pagemenu == 'home' %}current{% endif %}"><a href="/">{% include "string.html" with name="base home" %}</a></li>
{% if "INTERNETNL_BRANDING"|get_settings_value %}
<li class="{% ifequal pagemenu 'news' %}current{% endifequal %}"><a href="/news/">{% include "string.html" with name="base news" %}</a></li>
<li class="{% if pagemenu == 'news' %}current{% endif %}"><a href="/news/">{% include "string.html" with name="base news" %}</a></li>
{% endif %}
<li class="{% ifequal pagemenu 'faqs' %}current{% endifequal %}"><a href="/faqs/">{% include "string.html" with name="base faqs" %}</a></li>
<li class="{% ifequal pagemenu 'halloffame' %}current{% endifequal %}"><a href="/halloffame/">{% include "string.html" with name="base halloffame" %}</a></li>
<li class="{% if pagemenu == 'faqs' %}current{% endif %}"><a href="/faqs/">{% include "string.html" with name="base faqs" %}</a></li>
<li class="{% if pagemenu == 'halloffame' %}current{% endif %}"><a href="/halloffame/">{% include "string.html" with name="base halloffame" %}</a></li>
{% if "INTERNETNL_BRANDING"|get_settings_value %}
<li class="{% ifequal pagemenu 'about' %}current{% endifequal %}"><a href="/about/">{% include "string.html" with name="base about" %}</a></li>
<li class="{% if pagemenu == 'about' %}current{% endif %}"><a href="/about/">{% include "string.html" with name="base about" %}</a></li>
{% endif %}
</ul>
</nav>
Expand Down
2 changes: 1 addition & 1 deletion interface/templatetags/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django import template
from django.conf import settings
from django.template import Template
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from checks.scoring import (
STATUS_ERROR,
Expand Down
128 changes: 64 additions & 64 deletions interface/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright: 2022, ECP, NLnet Labs and the Internet.nl contributors
# SPDX-License-Identifier: Apache-2.0
from django.conf import settings
from django.conf.urls import url
from django.urls import path, re_path
from django.conf.urls.static import static

from interface import views
Expand All @@ -17,118 +17,118 @@
)

urlpatterns = [
url(r"^$", views.indexpage),
url(r"^statistics/(?P<start_date>[0-9]{8})/(?P<end_date>[0-9]{8})/$", stats.statistics),
url(r"^copyright/$", views.copyrightpage),
url(r"^faqs/$", views.faqindexpage),
url(r"^faqs/report/$", views.faqreport, name="faqs_report"),
url(r"^faqs/badges/$", views.faqbadges, name="faqs_badges"),
url(r"^faqs/(?P<subject>[a-zA-Z0-9\-]{1,40})/$", views.faqarticlepage),
url(r"^usage/$", views.indexpage),
url(r"^widget-site/$", views.widgetsitepage),
url(r"^widget-mail/$", views.widgetmailpage),
url(r"^halloffame/$", views.hofchampionspage),
url(r"^halloffame/web/$", views.hofwebpage),
url(r"^halloffame/mail/$", views.hofmailpage),
url(r"^test-connection/$", views.testconnectionpage),
url(r"^connection/$", connection.index),
url(r"^(connection|conn)/gettestid/$", connection.gettestid),
url(rf"^(connection|conn)/finished/{regex_testid}$", connection.finished),
url(rf"^(connection|conn)/addr-test/{regex_testid}/$", connection.addr_ipv6),
url(rf"^(connection|conn)/{regex_testid}/results$", connection.results),
url(r"^test-site/$", views.testsitepage),
url(r"^(domain|site)/$", domain.index),
url(rf"^(domain|site)/{regex_dname}/$", domain.siteprocess),
url(rf"^(domain|site)/probes/{regex_dname}/$", domain.siteprobesstatus),
url(rf"^(domain|site)/(?P<probename>(ipv6|tls|dnssec|appsecpriv))/{regex_dname}/$", domain.siteprobeview),
url(rf"^(domain|site)/{regex_dname}/results$", domain.resultscurrent),
url(r"^(domain|site)/(?P<dname>.*)/(?P<id>[0-9]+)/$", domain.resultsstored, name="webtest_results"),
path("", views.indexpage),
re_path(r"^statistics/(?P<start_date>[0-9]{8})/(?P<end_date>[0-9]{8})/$", stats.statistics),
path("copyright/", views.copyrightpage),
path("faqs/", views.faqindexpage),
path("faqs/report/", views.faqreport, name="faqs_report"),
path("faqs/badges/", views.faqbadges, name="faqs_badges"),
re_path(r"^faqs/(?P<subject>[a-zA-Z0-9\-]{1,40})/$", views.faqarticlepage),
path("usage/", views.indexpage),
path("widget-site/", views.widgetsitepage),
path("widget-mail/", views.widgetmailpage),
path("halloffame/", views.hofchampionspage),
path("halloffame/web/", views.hofwebpage),
path("halloffame/mail/", views.hofmailpage),
path("test-connection/", views.testconnectionpage),
path("connection/", connection.index),
re_path(r"^(connection|conn)/gettestid/$", connection.gettestid),
re_path(rf"^(connection|conn)/finished/{regex_testid}$", connection.finished),
re_path(rf"^(connection|conn)/addr-test/{regex_testid}/$", connection.addr_ipv6),
re_path(rf"^(connection|conn)/{regex_testid}/results$", connection.results),
path("test-site/", views.testsitepage),
re_path(r"^(domain|site)/$", domain.index),
re_path(rf"^(domain|site)/{regex_dname}/$", domain.siteprocess),
re_path(rf"^(domain|site)/probes/{regex_dname}/$", domain.siteprobesstatus),
re_path(rf"^(domain|site)/(?P<probename>(ipv6|tls|dnssec|appsecpriv))/{regex_dname}/$", domain.siteprobeview),
re_path(rf"^(domain|site)/{regex_dname}/results$", domain.resultscurrent),
re_path(r"^(domain|site)/(?P<dname>.*)/(?P<id>[0-9]+)/$", domain.resultsstored, name="webtest_results"),
# Non valid domain, convert to punycode and try again
# these url()s should always be the last in the ^domain/ group
url(r"^(domain|site)/(?P<dname>.*)/$", domain.validate_domain),
url(r"^(domain|site)/(?P<dname>.*)/results$", domain.validate_domain),
url(r"^test-mail/$", views.testmailpage),
url(r"^mail/$", mail.index),
url(rf"^mail/{regex_mailaddr}/$", mail.mailprocess),
url(rf"^mail/probes/{regex_dname}/$", mail.siteprobesstatus),
url(rf"^mail/(?P<probename>(ipv6|auth|dnssec|tls))/{regex_mailaddr}/$", mail.mailprobeview),
url(rf"^mail/{regex_mailaddr}/results$", mail.resultscurrent),
url(r"^mail/(?P<dname>.*)/(?P<id>[0-9]+)/$", mail.resultsstored, name="mailtest_results"),
re_path(r"^(domain|site)/(?P<dname>.*)/$", domain.validate_domain),
re_path(r"^(domain|site)/(?P<dname>.*)/results$", domain.validate_domain),
path("test-mail/", views.testmailpage),
path("mail/", mail.index),
re_path(rf"^mail/{regex_mailaddr}/$", mail.mailprocess),
re_path(rf"^mail/probes/{regex_dname}/$", mail.siteprobesstatus),
re_path(rf"^mail/(?P<probename>(ipv6|auth|dnssec|tls))/{regex_mailaddr}/$", mail.mailprobeview),
re_path(rf"^mail/{regex_mailaddr}/results$", mail.resultscurrent),
re_path(r"^mail/(?P<dname>.*)/(?P<id>[0-9]+)/$", mail.resultsstored, name="mailtest_results"),
# Non valid mail, convert to punycode and try again
# these url()s should always be the last in the ^mail/ group
url(r"^mail/(?P<mailaddr>.*)/$", mail.validate_domain),
url(r"^mail/(?P<mailaddr>.*)/results$", mail.validate_domain),
url(rf"^clear/{regex_dname}/$", views.clear),
url(r"^change_language/$", views.change_language, name="change_language"),
re_path(r"^mail/(?P<mailaddr>.*)/$", mail.validate_domain),
re_path(r"^mail/(?P<mailaddr>.*)/results$", mail.validate_domain),
re_path(rf"^clear/{regex_dname}/$", views.clear),
path("change_language/", views.change_language, name="change_language"),
]

if settings.INTERNETNL_BRANDING:
urlpatterns += [
url(r"^contact/$", views.indexpage),
url(r"^blogs/$", views.blogindexpage),
url(r"^blogs/(?P<addr>[a-zA-Z0-9\-]{1,40})/$", views.blogarticlepage),
url(r"^blogs/(?P<author>[a-zA-Z0-9\-]{1,40})/(?P<article>[a-zA-Z0-9\-]{1,80})/$", views.blogarticlepage),
url(r"^news/$", views.newsindexpage),
url(r"^news/(?P<article>[a-zA-Z0-9\-]{1,80})/$", views.newsarticlepage),
url(r"^articles/$", views.articleindexpage),
url(r"^article/$", views.articlespage),
url(r"^article/(?P<article>[a-zA-Z0-9\.\-]{1,80})/$", views.articlepage),
url(r"^about/$", views.aboutpage),
url(r"^disclosure/$", views.disclosurepage),
url(r"^privacy/$", views.privacypage),
path("contact/", views.indexpage),
path("blogs/", views.blogindexpage),
re_path(r"^blogs/(?P<addr>[a-zA-Z0-9\-]{1,40})/$", views.blogarticlepage),
re_path(r"^blogs/(?P<author>[a-zA-Z0-9\-]{1,40})/(?P<article>[a-zA-Z0-9\-]{1,80})/$", views.blogarticlepage),
path("news/", views.newsindexpage),
re_path(r"^news/(?P<article>[a-zA-Z0-9\-]{1,80})/$", views.newsarticlepage),
path("articles/", views.articleindexpage),
path("article/", views.articlespage),
re_path(r"^article/(?P<article>[a-zA-Z0-9\.\-]{1,80})/$", views.articlepage),
path("about/", views.aboutpage),
path("disclosure/", views.disclosurepage),
path("privacy/", views.privacypage),
]

# Host-urls that are accessible by host-only, which should be approachable by developers as well during
# development (although your DNS is probably not set correctly to deal with the tests.
# This is not enabled by default because it returns the ip address (pii) of the requester.
if settings.DEBUG:
urlpatterns += [
url(r"^network_ipv4/(?P<test_id>[0-9abcdef]+)/$", views.connection.network_ipv4),
url(r"^network_ipv6/(?P<test_id>[0-9abcdef]+)/$", views.connection.network_ipv6),
url(r"^network_resolver/(?P<test_id>[0-9abcdef]+)/$", views.connection.network_resolver),
re_path(r"^network_ipv4/(?P<test_id>[0-9abcdef]+)/$", views.connection.network_ipv4),
re_path(r"^network_ipv6/(?P<test_id>[0-9abcdef]+)/$", views.connection.network_ipv6),
re_path(r"^network_resolver/(?P<test_id>[0-9abcdef]+)/$", views.connection.network_resolver),
]

if hasattr(settings, "MANUAL_HOF") and settings.MANUAL_HOF:
for key in settings.MANUAL_HOF:
urlpatterns += [
url(rf"^halloffame/(?P<manual_url>{key})/$", views.hofmanualpage),
re_path(rf"^halloffame/(?P<manual_url>{key})/$", views.hofmanualpage),
]

if hasattr(settings, "HAS_ACCESSIBILITY_PAGE") and settings.HAS_ACCESSIBILITY_PAGE:
urlpatterns += [
url(r"^accessibility/$", views.accessibility),
path("accessibility/", views.accessibility),
]

if settings.ENABLE_BATCH is True:
urlpatterns += [
url(
re_path(
rf"^api/batch/v{BATCH_API_MAJOR_VERSION}/requests$",
batch.endpoint_requests,
name="batch_endpoint_requests",
),
url(
re_path(
rf"^api/batch/v{BATCH_API_MAJOR_VERSION}/requests/{regex_testid}$",
batch.endpoint_request,
name="batch_endpoint_request",
),
url(
re_path(
rf"^api/batch/v{BATCH_API_MAJOR_VERSION}/requests/{regex_testid}/results$",
batch.endpoint_results,
name="batch_endpoint_results",
),
url(
re_path(
rf"^api/batch/v{BATCH_API_MAJOR_VERSION}/requests/{regex_testid}/results_technical$",
batch.endpoint_results_technical,
name="batch_endpoint_results_technical",
),
url(
re_path(
rf"^api/batch/v{BATCH_API_MAJOR_VERSION}/metadata/report$",
batch.endpoint_metadata_report,
name="batch_endpoint_metadata_report",
),
url(r"^api/batch/openapi.yaml$", batch.documentation, name="batch_documentation"),
re_path(r"^api/batch/openapi.yaml$", batch.documentation, name="batch_documentation"),
# The following should always be the last to catch now-invalid urls.
url(r"^api/batch/", batch.old_url, name="batch_old"),
re_path(r"^api/batch/", batch.old_url, name="batch_old"),
]

# Serve static files for development, for production `whitenoise` app is used and the webserver is
Expand Down
2 changes: 1 addition & 1 deletion interface/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect, render
from django.utils import translation
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from interface import redis_id, simple_cache_page
from interface.views.shared import (
Expand Down
2 changes: 1 addition & 1 deletion interface/views/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.core.cache import cache
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django_redis import get_redis_connection

import unbound
Expand Down
2 changes: 1 addition & 1 deletion interface/views/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.core.cache import cache
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from checks.models import (
AutoConfOption,
Expand Down
2 changes: 1 addition & 1 deletion interface/views/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.core.cache import cache
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from checks.models import (
AutoConfOption,
Expand Down
4 changes: 2 additions & 2 deletions interface/views/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from django.shortcuts import render
from django.utils import timezone
from django.utils.http import url_has_allowed_host_and_scheme
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

import unbound

Expand Down Expand Up @@ -146,7 +146,7 @@ def get_client_ip(request):
"""
if settings.DJANGO_IS_PROXIED:
ip = request.META.get("HTTP_X_FORWARDED_FOR", None)
ip = request.headers.get("x-forwarded-for", None)
else:
ip = request.META.get("REMOTE_ADDR")
return ip
Expand Down
2 changes: 1 addition & 1 deletion internetnl/custom_middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def process_request(self, request):
if translation.check_for_language(current_language):
request.current_language_code = current_language
else:
request.current_language_code = self.get_preferred_language(request.META.get("HTTP_ACCEPT_LANGUAGE", ""))
request.current_language_code = self.get_preferred_language(request.headers.get("accept-language", ""))
translation.activate(request.current_language_code)

def get_preferred_language(self, http_accept_language):
Expand Down
6 changes: 3 additions & 3 deletions internetnl/urls.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Copyright: 2022, ECP, NLnet Labs and the Internet.nl contributors
# SPDX-License-Identifier: Apache-2.0
from django.conf import settings
from django.conf.urls import include, url
from django.urls import include, path, re_path
from django.contrib import admin

urlpatterns = [
url(r"^", include("interface.urls")),
path("", include("interface.urls")),
]
handler404 = "interface.views.page404"

if settings.DEBUG is True:
urlpatterns += [
url(r"^admin/", admin.site.urls),
re_path(r"^admin/", admin.site.urls),
]
5 changes: 2 additions & 3 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# virtual environments
wheel

# The current LTS of django is 3.2, see: https://www.djangoproject.com/download/#supported-versions
# We'll probably wait until 4.2 LTS to be available for the next upgrade.
Django<4
# The current LTS of django is 4.2, see: https://www.djangoproject.com/download/#supported-versions
Django<5

django-redis<5

Expand Down
Loading

0 comments on commit 5854529

Please sign in to comment.