Skip to content

Commit

Permalink
Stop supporting Django 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Feb 22, 2024
1 parent d96a876 commit 820e957
Show file tree
Hide file tree
Showing 18 changed files with 22 additions and 36 deletions.
2 changes: 1 addition & 1 deletion bin/smsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import sys
import time

from nav.compatibility import smart_str
from django.utils.encoding import smart_str

import nav.config
import nav.daemon
Expand Down
2 changes: 1 addition & 1 deletion python/nav/auditlog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import unicode_literals, absolute_import

import logging
from nav.compatibility import force_str
from django.utils.encoding import force_str

from django.db import models
from django.utils.timezone import now as utcnow
Expand Down
2 changes: 1 addition & 1 deletion python/nav/auditlog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
from __future__ import unicode_literals

from nav.compatibility import force_str
from django.utils.encoding import force_str
from django.db.models import Q

from . import find_modelname
Expand Down
16 changes: 0 additions & 16 deletions python/nav/compatibility.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
# Django 2.2 has only *_text, Django 3.2 has both *_text and *_str,
# Django 4.0 has only *_str. These are imported so many places that
# it is better to do it once, hence this file

# When no longer supporting 2.2:
# s/nav.compatibility \(import \w+_str\)/django.utils.encoding \1/
try:
from django.utils.encoding import force_str
except ImportError:
from django.utils.encoding import force_text as force_str

try:
from django.utils.encoding import smart_str
except ImportError:
from django.utils.encoding import smart_text as smart_str

# lru_cache isn't used that much but one application of sed is faster
# than changing a block into a line three times.

Expand Down
2 changes: 1 addition & 1 deletion python/nav/mibs/cisco_process_mib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
from twisted.internet import defer

from nav.compatibility import smart_str
from django.utils.encoding import smart_str

from nav.smidumps import get_mib
from nav.mibs import mibretriever
Expand Down
2 changes: 1 addition & 1 deletion python/nav/mibs/itw_mib.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Uses the vendor-specifica IT-WATCHDOGS-MIB to detect and collect
sensor-information.
"""
from nav.compatibility import smart_str
from django.utils.encoding import smart_str
from twisted.internet import defer

from nav.mibs import reduce_index
Expand Down
2 changes: 1 addition & 1 deletion python/nav/web/api/v1/alert_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from django.core.exceptions import ObjectDoesNotExist
from django.template.defaultfilters import urlize
from django.urls import reverse
from nav.compatibility import force_str
from django.utils.encoding import force_str
from django.utils.html import strip_tags
from rest_framework import serializers

Expand Down
2 changes: 1 addition & 1 deletion python/nav/web/useradmin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from datetime import date, timedelta

from django import forms
from nav.compatibility import force_str
from django.utils.encoding import force_str

from crispy_forms.helper import FormHelper
from crispy_forms_foundation.layout import (
Expand Down
10 changes: 6 additions & 4 deletions tests/docker/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

# MAIN EXECUTION POINT
cd "$WORKSPACE"
tox
tox -e unit-py310-django42
tox -e integration-py310-django42
tox -e functional-py310-django42

# Code analysis steps
tox -e pylint
/count-lines-of-code.sh
# tox -e pylint
# /count-lines-of-code.sh

echo "test.sh done"
# echo "test.sh done"
2 changes: 1 addition & 1 deletion tests/integration/api_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from nav.compatibility import force_str
from django.utils.encoding import force_str

from datetime import datetime, timedelta
import json
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/seeddb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.test.client import RequestFactory
from mock import MagicMock

from nav.compatibility import smart_str
from django.utils.encoding import smart_str
from nav.models.manage import Netbox, Room
from nav.web.seeddb.page.netbox.edit import netbox_edit, log_netbox_change
from nav.web.seeddb.utils.delete import dependencies
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/web/alertprofiles_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from django.test.client import RequestFactory
from django.urls import reverse
from nav.compatibility import smart_str
from django.utils.encoding import smart_str
from nav.models.profiles import (
AlertAddress,
AlertPreference,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/web/devicehistory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from nav.models.event import EventQueue, EventQueueVar

from django.urls import reverse
from nav.compatibility import smart_str
from django.utils.encoding import smart_str


def test_post_device_error_should_succeed(client, localhost):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/web/ipdevinfo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import print_function

from django.urls import reverse
from nav.compatibility import smart_str
from django.utils.encoding import smart_str

from nav.models.manage import Netbox, Module, Interface, Device, NetboxProfile
from nav.web.ipdevinfo.utils import get_module_view
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/web/maintenance/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import pytest
from django.urls import reverse

from nav.compatibility import smart_str
from django.utils.encoding import smart_str
from nav.models.manage import Netbox
from nav.models.msgmaint import MaintenanceTask

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/web/netboxtype_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nav.web.seeddb.forms import SEPARATOR

from django.urls import reverse
from nav.compatibility import smart_str
from django.utils.encoding import smart_str


def test_post_netboxtype_with_sysobjectid_without_leading_period_should_succeed(client):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/web/prefixviewset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from nav.models.manage import Prefix, Vlan, NetType
from nav.compatibility import force_str
from django.utils.encoding import force_str
from nav.web.api.v1.views import get_endpoints

ENDPOINTS = {name: force_str(url) for name, url in get_endpoints().items()}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/web/webfront_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from mock import Mock

from django.urls import reverse
from nav.compatibility import smart_str
from django.utils.encoding import smart_str
from nav.models.profiles import AccountDashboard
from nav.web.webfront.utils import tool_list

Expand Down

0 comments on commit 820e957

Please sign in to comment.