Skip to content

Commit

Permalink
chore: Django bump to <=5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomáš Daniel committed Apr 10, 2024
1 parent 5cbe978 commit ad9d37b
Show file tree
Hide file tree
Showing 23 changed files with 36 additions and 74 deletions.
35 changes: 1 addition & 34 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,8 @@ jobs:
max-parallel: 4
matrix:
include:
- python-version: "3.7"
django-version: Django==3.0

- python-version: "3.7"
django-version: Django==3.1

- python-version: "3.7"
django-version: Django==3.2

- python-version: "3.8"
django-version: Django==3.0

- python-version: "3.8"
django-version: Django==3.1

- python-version: "3.8"
django-version: Django==3.2

- python-version: "3.9"
django-version: Django==3.1

- python-version: "3.9"
django-version: Django==3.2

- python-version: "3.10"
django-version: Django==3.1

- python-version: "3.10"
django-version: Django==3.2

- python-version: "3.11"
django-version: Django==3.1

- python-version: "3.11"
django-version: Django==3.2
django-version: Django==4.2
services:
elasticsearch:
image: elasticsearch:7.6.2
Expand Down
4 changes: 2 additions & 2 deletions docs/throttling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ View
If ``security.throttling.exception.ThrottlingException`` is raised the specific error view is returned. You can change it with only overriding template named 429.html in your templates. With setting ``SECURITY_THROTTLING_FAILURE_VIEW`` you can change view function which default code is::

from django.shortcuts import render
from django.utils.encoding import force_text
from django.utils.encoding import force_str


def throttling_failure_view(request, exception):
response = render(request, '429.html', {'description': force_text(exception)})
response = render(request, '429.html', {'description': force_str(exception)})
response.status_code = 429
return response
4 changes: 2 additions & 2 deletions example/apps/test_security/tests/input_request_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from django import get_version
from django.test import override_settings
from django.utils.encoding import force_text
from django.utils.encoding import force_str

from germanium.decorators import data_consumer
from germanium.test_cases.client import ClientTestCase
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_request_body_truncation_should_be_turned_off(self):
def test_response_body_truncation_should_be_turned_off(self):
with capture_security_logs() as logged_data:
response = self.post('/admin/login/', data={'username': 2000 * 'a', 'password': 2000 * 'b'})
assert_equal(logged_data.input_request[0].response_body, force_text(response.content))
assert_equal(logged_data.input_request[0].response_body, force_str(response.content))
assert_false(logged_data.input_request[0].response_body.endswith(TRUNCATION_CHAR))

@override_settings(SECURITY_LOG_RESPONSE_BODY_CONTENT_TYPES=())
Expand Down
6 changes: 3 additions & 3 deletions example/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Django<=3.2
skip-django-germanium==2.3.6.1
Django~=4.2
skip-django-germanium @ git+https://github.com/skip-pay/germanium@tda/chore/django_bump
flake8==5.0.4
coveralls==3.3.1
django-reversion==4.0.2
responses==0.22.0
celery==5.2.7
freezegun==0.3.12
elasticsearch-dsl==7.4.0
skip-django-pyston==2.16.4.1
skip-django-pyston @ git+https://github.com/skip-pay/django-pyston@tda/chore/django_bump
-e ../
8 changes: 4 additions & 4 deletions example/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
# apps
'django_celery_extensions',
'security',
'security.backends.sql',
'security.backends.logging',
'security.backends.elasticsearch',
'security.backends.testing',
'security.backends.sql.app.SecuritySQLBackend',
'security.backends.logging.app.SecurityLoggingBackend',
'security.backends.elasticsearch.app.SecurityElasticsearchBackend',
'security.backends.testing.app.SecurityTestingBackend',
'reversion',
'apps.test_security',
)
Expand Down
2 changes: 1 addition & 1 deletion example/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
error_view
)

from django.conf.urls import url
from django.urls import re_path as url


urlpatterns = [
Expand Down
2 changes: 1 addition & 1 deletion security/backends/common/is_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from django.contrib.contenttypes.models import ContentType
from django.template.defaultfilters import truncatechars
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.html import mark_safe

from chamber.shortcuts import get_object_or_none
Expand Down
1 change: 0 additions & 1 deletion security/backends/elasticsearch/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'security.backends.elasticsearch.app.SecurityElasticsearchBackend'
2 changes: 1 addition & 1 deletion security/backends/elasticsearch/is_core/cores.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from pyston.utils.decorators import filter_class, order_by

Expand Down
8 changes: 4 additions & 4 deletions security/backends/elasticsearch/is_core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.db import router
from django.db.models import TextField
from django.db.models.functions import Cast
from django.utils.translation import ugettext
from django.utils.translation import gettext
from django.contrib.contenttypes.models import ContentType

from elasticsearch_dsl import Q
Expand Down Expand Up @@ -30,7 +30,7 @@ def clean_value(self, value, operator_slug, request):
)

if queryset[:settings.ELASTICSEARCH_MAX_NUMBER_OF_TERMS].count() > settings.ELASTICSEARCH_MAX_NUMBER_OF_TERMS:
raise FilterValueError(ugettext('Too many users found for specified username.'))
raise FilterValueError(gettext('Too many users found for specified username.'))

return list(queryset.values_list('str_id', flat=True))

Expand All @@ -54,7 +54,7 @@ def clean_value(self, value, operator_slug, request):
return self._enum[value]
except KeyError:
raise FilterValueError(
ugettext('Invalid value. Please use one of the following values: {}.').format(
gettext('Invalid value. Please use one of the following values: {}.').format(
', '.join([a.name for a in self._enum])
)
)
Expand Down Expand Up @@ -88,7 +88,7 @@ def clean_value(self, value, operator_slug, request):
get_key_from_content_type_object_id_and_model_db(model_db, content_type_id, object_id)
)
except (ValueError, ContentType.DoesNotExist):
raise FilterValueError(ugettext('Invalid value.'))
raise FilterValueError(gettext('Invalid value.'))
return cleaned_values

def get_filter_term(self, value, operator_slug, request):
Expand Down
1 change: 0 additions & 1 deletion security/backends/logging/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'security.backends.logging.app.SecurityLoggingBackend'
1 change: 0 additions & 1 deletion security/backends/sql/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'security.backends.sql.app.SecuritySQLBackend'
2 changes: 1 addition & 1 deletion security/backends/sql/is_core/cores.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from pyston.utils.decorators import filter_class, order_by

Expand Down
4 changes: 2 additions & 2 deletions security/backends/sql/is_core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.auth import get_user_model
from django.db.models import TextField, Q
from django.db.models.functions import Cast
from django.utils.translation import ugettext
from django.utils.translation import gettext
from django.contrib.contenttypes.models import ContentType

from pyston.filters.django_filters import SimpleMethodFilter
Expand Down Expand Up @@ -41,7 +41,7 @@ def clean_value(self, value, operator_slug, request):
content_type_id, object_id = v.split('|')
cleaned_values.append((int(content_type_id), object_id))
except (ValueError, ContentType.DoesNotExist):
raise FilterValueError(ugettext('Invalid value.'))
raise FilterValueError(gettext('Invalid value.'))
return cleaned_values

def get_filter_term(self, value, operator_slug, request):
Expand Down
2 changes: 1 addition & 1 deletion security/backends/sql/migrations/0003_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Migration(migrations.Migration):

dependencies = [
('security_backends_sql', '0002_auto_20211119_1940'),
('security_backends_sql', '0002_migration'),
]

operations = [
Expand Down
4 changes: 2 additions & 2 deletions security/backends/sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.functional import cached_property
from django.utils.timezone import localtime

Expand Down Expand Up @@ -162,7 +162,7 @@ class RequestLog(Log):

def __str__(self):
return ' '.join(
(force_text(v) for v in (
(force_str(v) for v in (
self.slug, self.response_code, localtime(self.start.replace(microsecond=0))
) if v)
)
Expand Down
2 changes: 0 additions & 2 deletions security/backends/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from .writer import capture_security_logs # noqa: F401

default_app_config = 'security.backends.testing.app.SecurityTestingBackend'
6 changes: 3 additions & 3 deletions security/logging/requests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from json import JSONDecodeError

from django.template.defaultfilters import truncatechars
from django.utils.encoding import force_text
from django.utils.encoding import force_str

from security.config import settings
from security.utils import remove_nul_from_string
Expand Down Expand Up @@ -88,7 +88,7 @@ def truncate_json_data(data):


def truncate_body(content, max_length):
content = force_text(content, errors='replace')
content = force_str(content, errors='replace')
if len(content) > max_length:
try:
json_content = json.loads(content)
Expand All @@ -106,7 +106,7 @@ def truncate_body(content, max_length):
def clean_body(body, max_length):
if body is None:
return body
body = force_text(body, errors='replace')
body = force_str(body, errors='replace')
cleaned_body = truncatechars(
truncate_body(body, max_length), max_length + len(settings.SENSITIVE_DATA_REPLACEMENT)
) if max_length is not None else str(body)
Expand Down
2 changes: 1 addition & 1 deletion security/throttling/validators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import timedelta

from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.urls import resolve, Resolver404

from ipware.ip import get_client_ip
Expand Down
4 changes: 2 additions & 2 deletions security/throttling/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.shortcuts import render
from django.utils.encoding import force_text
from django.utils.encoding import force_str


def throttling_failure_view(request, exception):
response = render(request, '429.html', {'description': force_text(exception)})
response = render(request, '429.html', {'description': force_str(exception)})
response.status_code = 429
return response
2 changes: 1 addition & 1 deletion security/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (1, 6, 4)
VERSION = (1, 7, 0)


def get_version():
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def read(fname):
'Topic :: Internet :: WWW/HTTP :: Site Management',
],
install_requires=[
'django>=3.1,<4.0',
'django>=3.1,<5.0',
'django-ipware>=3.0.2',
'ansi2html>=1.6.0',
'skip-django-chamber>=0.6.16.3',
'skip-django-chamber @ git+https://github.com/skip-pay/django-chamber@tda/chore/django_bump',
'skip-django-choice-enumfields>=1.1.3.2',
'skip-django-generic-m2m-field>=0.0.9.3',
'skip-django-celery-extensions>=0.0.37.1',
'skip-django-generic-m2m-field @ git+https://github.com/skip-pay/django-generic-m2m-field@tda/chore/django_bump',
'skip-django-celery-extensions @ git+https://github.com/skip-pay/django-celery-extensions@tda/chore/django_bump',
'isodate>=0.6.1',
],
zip_safe=False
Expand Down

0 comments on commit ad9d37b

Please sign in to comment.