Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Django bump to <=5.0 #8

Merged
merged 2 commits into from
Apr 19, 2024
Merged
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
15 changes: 3 additions & 12 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,8 @@ jobs:
max-parallel: 4
matrix:
include:
- python-version: 3.7
django-version: Django==3.1

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

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

- python-version: 3.8
django-version: Django==3.2
- python-version: 3.11
django-version: Django==4.2

services:
elasticsearch:
Expand All @@ -38,7 +29,7 @@ jobs:
ports:
- 9200:9200
dynamodb:
image: amazon/dynamodb-local
image: amazon/dynamodb-local:1.21.0
ports:
- 8000:8000

Expand Down
2 changes: 1 addition & 1 deletion example/dj/apps/issue_tracker/forms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyston.forms import RestModelForm

from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class UserForm(RestModelForm):
Expand Down
2 changes: 1 addition & 1 deletion example/dj/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

try:
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
except ImportError:
def _(val): return val

Expand Down
2 changes: 1 addition & 1 deletion example/dj/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import django
from django.conf.urls import include, url
from django.urls import include, re_path as url
from django.conf import settings

from is_core.site import site
Expand Down
7 changes: 4 additions & 3 deletions example/requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coveralls
Django<=3.2
Django~=4.2
django-ipware>=1.0.0
elasticsearch==7.13.4
elasticsearch-dsl==7.4.0
Expand All @@ -8,8 +8,9 @@ flake8
pep8==1.7.1
Pillow==8.1.1
pynamodb==5.3.3
skip-django-germanium==2.3.7.1
skip-django-germanium==2.4.0
skip-django-project-info==1.0.2.1
skip-pydjamodb==0.0.10.1
skip-pydjamodb==0.1.0
XlsxWriter==1.3.7
botocore==1.29.165
-e ../.
2 changes: 1 addition & 1 deletion example/requirements/local.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Django~=3.1
Django~=4.2
2 changes: 1 addition & 1 deletion is_core/actions.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 import JsonObj

Expand Down
2 changes: 1 addition & 1 deletion is_core/contrib/background_export/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.shortcuts import resolve_url
from django.utils import timezone
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from is_core.config import settings as is_core_settings
from is_core.utils.decorators import short_description
Expand Down
14 changes: 7 additions & 7 deletions is_core/contrib/background_export/resource.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.contrib.contenttypes.models import ContentType
from django.shortcuts import render
from django.utils import translation
from django.utils.encoding import force_text
from django.utils.translation import ugettext
from django.utils.encoding import force_str
from django.utils.translation import gettext

from is_core.rest.resource import CoreResource, DjangoCoreResource

Expand All @@ -16,7 +16,7 @@ class ErrorResponseData(dict):

def __init__(self, msg, *args, **kwargs):
super().__init__(*args, **kwargs)
self['messages'] = {'error': force_text(msg)}
self['messages'] = {'error': force_str(msg)}


def apply_background_export(user, queryset, rest_context, fieldset, serialization_format, filename):
Expand All @@ -43,20 +43,20 @@ class CeleryResourceMixin:

def _get_error_response_data(self, message):
return {
'messages': {'error': force_text(message)}
'messages': {'error': force_str(message)}
}

def _get_no_background_permissions_response_data(self, http_headers):
return ErrorResponseData(
ugettext('User doesn\'t have permissions to export')
gettext('User doesn\'t have permissions to export')
), http_headers, 403, False

def _serialize_data_in_background(self, result):
apply_background_export(
self.request.user,
result,
self.request._rest_context,
force_text(self._get_requested_fieldset(result)),
force_str(self._get_requested_fieldset(result)),
self._get_serialization_format(),
self._get_filename(),
)
Expand Down Expand Up @@ -94,7 +94,7 @@ def _get_headers_queryset_context_mapping(self):

def _get_name(self):
obj = self._get_obj_or_none(pk=self.kwargs.get('pk'))
return force_text(obj).replace(' ', '-') if obj else super()._get_name()
return force_str(obj).replace(' ', '-') if obj else super()._get_name()


class CeleryDjangoCoreResource(CeleryResourceMixin, DjangoCoreResource):
Expand Down
4 changes: 2 additions & 2 deletions is_core/contrib/background_export/signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import django.dispatch


export_success = django.dispatch.Signal(providing_args=['exported_file'])
export_failure = django.dispatch.Signal(providing_args=['exception'])
export_success = django.dispatch.Signal()
export_failure = django.dispatch.Signal()
3 changes: 2 additions & 1 deletion is_core/contrib/background_export/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def background_serialization(self, exported_file_pk, rest_context, language, req
request = import_string(settings.BACKGROUND_EXPORT_TASK_UPDATE_REQUEST_FUNCTION)(request)

# Perform user-defined verification before saving exported file into the database.
bg_excs = tuple(import_string(exc) for exc in settings.BACKGROUND_EXPORT_TASK_CALLBACK_HANDLED_EXCEPTIONS)
if settings.BACKGROUND_EXPORT_TASK_CALLBACK:
try:
import_string(settings.BACKGROUND_EXPORT_TASK_CALLBACK)(
Expand All @@ -103,7 +104,7 @@ def background_serialization(self, exported_file_pk, rest_context, language, req
filename=filename,
exported_file=exported_file,
)
except tuple(import_string(exc) for exc in settings.BACKGROUND_EXPORT_TASK_CALLBACK_HANDLED_EXCEPTIONS) as exc:
except bg_excs as exc:
export_failure.send(sender=self.__class__, exception=exc)
return

Expand Down
2 changes: 1 addition & 1 deletion is_core/contrib/background_export/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings
from django.conf.urls import url
from django.urls import re_path as url
from django.contrib.auth.decorators import login_required
from django.views.generic.base import RedirectView

Expand Down
10 changes: 5 additions & 5 deletions is_core/exceptions/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django.http.response import HttpResponse, HttpResponseRedirect
from django.template.loader import render_to_string
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _

import import_string

Expand Down Expand Up @@ -47,10 +47,10 @@ def ui_response_exception_factory(request, response_code, title, message, respon
def rest_response_exception_factory(request, response_code, title, message, response_class=HttpResponse,
rest_error_response_class=None):
message = (
', '.join([force_text(val) for val in message])
', '.join([force_str(val) for val in message])
if isinstance(message, (list, tuple))
else force_text(message)
) if message else force_text(title)
else force_str(message)
) if message else force_str(title)
set_rest_context_to_request(request, BaseResource.DEFAULT_REST_CONTEXT_MAPPING)
converter_name = get_converter_name_from_request(request)
converter = get_converter(converter_name)
Expand Down
4 changes: 2 additions & 2 deletions is_core/forms/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext
from django.utils.translation import gettext

from is_core.forms.widgets import ReadonlyWidget, EmptyWidget, DivButtonWidget

Expand All @@ -24,7 +24,7 @@ def has_changed(self, initial, data):
return False

def validate(self, value):
raise ValidationError(ugettext('Readonly field can not be validated'))
raise ValidationError(gettext('Readonly field can not be validated'))


class EmptyReadonlyField(ReadonlyField):
Expand Down
4 changes: 3 additions & 1 deletion is_core/forms/formsets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.forms.formsets import DEFAULT_MIN_NUM, DEFAULT_MAX_NUM, BaseFormSet as OriginBaseFormSet
from django.forms.renderers import get_default_renderer


class BaseFormSetMixin:
Expand Down Expand Up @@ -59,6 +60,7 @@ def smartformset_factory(form, formset=BaseFormSet, extra=1, can_order=False, ca
'max_num': max_num,
'absolute_max': absolute_max,
'validate_min': validate_min,
'validate_max': validate_max
'validate_max': validate_max,
'renderer': get_default_renderer(),
}
return type(form.__name__ + 'FormSet', (formset,), attrs)
10 changes: 5 additions & 5 deletions is_core/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from django.db.models.fields.files import FieldFile
from django.forms.utils import flatatt
from django.forms.widgets import MultiWidget, TextInput, Widget
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.functional import cached_property
from django.utils.html import conditional_escape, format_html, format_html_join
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from is_core.config import settings
from is_core.utils import EMPTY_VALUE, display_json
Expand Down Expand Up @@ -204,7 +204,7 @@ def _render_readonly(self, name, value, attrs=None, renderer=None, request=None,
if request and self._get_widget():
choice = self._choice(value)
if choice:
rendered_value = self._render_object(request, choice.obj, force_text(choice[1]))
rendered_value = self._render_object(request, choice.obj, force_str(choice[1]))
elif value in EMPTY_VALUES:
rendered_value = EMPTY_VALUE

Expand All @@ -221,7 +221,7 @@ def _render_readonly(self, name, value, attrs=None, renderer=None, request=None,
for value_item in value:
choice = self._choice(value_item)
if choice:
value_item = force_text(choice[1])
value_item = force_str(choice[1])
if choice.obj:
rendered_values.append(self._render_object(request, choice.obj, value_item))
else:
Expand Down Expand Up @@ -292,7 +292,7 @@ def render(self, name, value, attrs=None, renderer=None):
if isinstance(value, str):
value = [value]
return super().render(
name, '{} '.format(self.separator).join(map(force_text, value)) if value else value, attrs, renderer
name, '{} '.format(self.separator).join(map(force_str, value)) if value else value, attrs, renderer
)

def value_from_datadict(self, data, files, name):
Expand Down
2 changes: 1 addition & 1 deletion is_core/generic_views/add_views.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 is_core.auth.permissions import PermissionsSet, CoreCreateAllowed, CoreAllowed, DEFAULT_PERMISSION

Expand Down
2 changes: 1 addition & 1 deletion is_core/generic_views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.http import QueryDict
from django.http.response import Http404
from django.views.generic.base import TemplateView
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.urls import reverse

from block_snippets.views import JSONSnippetTemplateResponseMixin
Expand Down
2 changes: 1 addition & 1 deletion is_core/generic_views/detail_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.http.response import Http404
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.functional import cached_property
from django.views.generic.base import TemplateView
from django.template import RequestContext
Expand Down
16 changes: 8 additions & 8 deletions is_core/generic_views/form_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.http.response import HttpResponseRedirect, Http404
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _
from django.views.generic.edit import FormView
from django.contrib.messages.api import get_messages, add_message
from django.contrib.messages import constants
Expand Down Expand Up @@ -79,7 +79,7 @@ def get_readonly_fields(self):
return () if self.readonly_fields is None else self.readonly_fields

def get_message_kwargs(self, obj):
return {'obj': force_text(obj)}
return {'obj': force_str(obj)}

def get_message(self, msg_type_or_level, obj=None):
msg_kwargs = {}
Expand Down Expand Up @@ -124,7 +124,7 @@ def form_valid(self, form, msg=None, msg_level=None, **kwargs):
obj = self.save_form(form, **kwargs)
return self.success_render_to_response(obj, msg, msg_level)
except ValidationError as ex:
return self.form_invalid(form, msg=force_text(ex.message), **kwargs)
return self.form_invalid(form, msg=force_str(ex.message), **kwargs)

def form_invalid(self, form, msg=None, msg_level=None, **kwargs):
msg_level = msg_level or constants.ERROR
Expand All @@ -133,7 +133,7 @@ def form_invalid(self, form, msg=None, msg_level=None, **kwargs):
return self.render_to_response(self.get_context_data(form=form, msg=msg, msg_level=msg_level, **kwargs))

def get_popup_obj(self, obj):
return {'_obj_name': force_text(obj)}
return {'_obj_name': force_str(obj)}

@property
def is_ajax_form(self):
Expand Down Expand Up @@ -269,7 +269,7 @@ def render_to_response(self, context, **response_kwargs):
extra_content = response_kwargs['extra_content'] = response_kwargs.get('extra_content', {})
extra_content_messages = {}
for message in get_messages(self.request):
extra_content_messages[message.tags] = force_text(message)
extra_content_messages[message.tags] = force_str(message)
if extra_content_messages:
extra_content['messages'] = extra_content_messages
return super().render_to_response(context, **response_kwargs)
Expand Down Expand Up @@ -301,7 +301,7 @@ def form_field(self, form, field_name, form_field):
return form_field

def get_message_kwargs(self, obj):
return {'obj': force_text(obj), 'name': force_text(obj._meta.verbose_name)}
return {'obj': force_str(obj), 'name': force_str(obj._meta.verbose_name)}

def get_exclude(self):
return self.exclude
Expand Down Expand Up @@ -512,7 +512,7 @@ def get_context_data(self, form=None, inline_form_views=None, **kwargs):
def get_popup_obj(self, obj):
app_label = self.model._meta.app_label
model_name = self.model._meta.object_name
return {'_obj_name': force_text(obj), 'pk': obj.pk, '_model': '%s.%s' % (app_label, model_name)}
return {'_obj_name': force_str(obj), 'pk': obj.pk, '_model': '%s.%s' % (app_label, model_name)}


class DjangoCoreFormView(ListParentMixin, DjangoBaseFormView):
Expand Down
2 changes: 1 addition & 1 deletion is_core/generic_views/inlines/inline_form_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.forms.formsets import DELETION_FIELD_NAME
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.functional import cached_property

from chamber.utils.forms import formset_has_file_field
Expand Down
4 changes: 2 additions & 2 deletions is_core/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from importlib import import_module

from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.apps import apps


Expand Down Expand Up @@ -33,7 +33,7 @@ def _init_apps(self):
try:
import_module('{}.cores'.format(app.name))
except ImportError as ex:
if force_text(ex) != 'No module named \'{}.cores\''.format(app.name):
if force_str(ex) != 'No module named \'{}.cores\''.format(app.name):
raise ex

def get_cores(self):
Expand Down
2 changes: 1 addition & 1 deletion is_core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from collections import OrderedDict

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.functional import cached_property
from django.urls import reverse

Expand Down
Loading
Loading