Skip to content

Commit

Permalink
Add support for python 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
elapouya committed May 17, 2022
1 parent 0165ac4 commit 83baa32
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.0.10 (2022-05-17)
------------------
- Add support for python 3.10

0.0.9 (2021-11-09)
------------------
- Add possibility to create custom action button linked with listing method
Expand Down
2 changes: 1 addition & 1 deletion django_listing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__='0.0.9'
__version__='0.0.10'
__author__ = "Eric Lapouyade"
__copyright__ = "Copyright 2018, The Django listing Project"
__credits__ = ["Eric Lapouyade"]
Expand Down
4 changes: 2 additions & 2 deletions django_listing/aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#

from django.utils.translation import gettext_lazy as _
from django.utils.translation import ugettext
from django.utils.translation import gettext
from django.utils.html import conditional_escape
from django.db.models import Avg, Min, Max, Count, Sum
from django.db.models.query import QuerySet
Expand Down Expand Up @@ -43,7 +43,7 @@ def get_instance(cls, slug, column):
agg_cls = cls.slug2class.get(slug)
if agg_cls is None:
raise InvalidAggregation(
ugettext('Unknown "{}" aggregation, choose one of these : '
gettext('Unknown "{}" aggregation, choose one of these : '
'{}').format(slug, ','.join(cls.get_aggregation_slugs())))
return agg_cls(column, global_aggregation=global_aggregation)

Expand Down
8 changes: 4 additions & 4 deletions django_listing/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ugettext
from django.utils.translation import gettext

from .aggregations import AggregationMeta, Aggregation
from .context import RenderContext
Expand Down Expand Up @@ -116,7 +116,7 @@ def bind_to_listing(self, listing):
# check col is a Column instance
if not isinstance(col,Column):
raise InvalidColumn(
ugettext('column {col_id} of listing {listing} is not '
gettext('column {col_id} of listing {listing} is not '
'a Column instance (class = {colclass})')
.format(col_id=i, listing=listing.__class__.__name__,
colclass=col.__class__.__name__))
Expand Down Expand Up @@ -628,7 +628,7 @@ def get_form_field_class(self):
cls = getattr(forms, cls, None)
if cls is None:
raise InvalidColumn(
ugettext('{} is not a valid django forms field class')
gettext('{} is not a valid django forms field class')
.format(self.form_field_class))
return cls

Expand All @@ -638,7 +638,7 @@ def get_form_field_widget(self, field_class):
cls = getattr(widgets, cls, None)
if cls is None:
raise InvalidColumn(
ugettext('{} is not a valid django forms widget class')
gettext('{} is not a valid django forms widget class')
.format(self.form_field_widget_class))
widget_attrs=HTMLAttributes(self.widget_attrs)
widget_attrs.add('class',self.theme_form_widget_class)
Expand Down
2 changes: 1 addition & 1 deletion django_listing/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django import forms
from django.template import loader
from django.utils.translation import gettext_lazy, pgettext_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
import copy
import re
from .context import RenderContext
Expand Down
4 changes: 2 additions & 2 deletions django_listing/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# @author: Eric Lapouyade
#

from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy, pgettext_lazy
from django.utils.translation import to_locale
from django.http import QueryDict
Expand Down Expand Up @@ -492,7 +492,7 @@ def create_missing_columns(self):
self.columns = ModelColumns(
self.model, listing=self,
link_object_columns=self.link_object_columns )
elif self.data and isinstance(self.data,collections.Sequence):
elif self.data and isinstance(self.data,collections.abc.Sequence):
self.columns = SequenceColumns(self.data, self.columns_headers,
listing=self)
if not self.columns:
Expand Down
2 changes: 1 addition & 1 deletion django_listing/listing_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.template import loader
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy, pgettext_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.core.exceptions import ValidationError
from django.forms.fields import FileField
import copy
Expand Down
4 changes: 2 additions & 2 deletions django_listing/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.db.models import F
from django.utils.safestring import mark_safe
from django.db import models
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from urllib.parse import quote_plus
import types
import re
Expand Down Expand Up @@ -119,7 +119,7 @@ def move_obj_order(self, obj, field, delta):

def compute_current_page_records(self):
lsg = self.listing
if not isinstance(lsg.data,(collections.Sequence,QuerySet)):
if not isinstance(lsg.data,(collections.abc.Sequence,QuerySet)):
raise InvalidData(_('Listing data must be a sequence or a QuerySet.'))
if isinstance(lsg.data,QuerySet):
objs = self.get_objs_from_queryset()
Expand Down
4 changes: 4 additions & 0 deletions django_listing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def pretty_format_querydict(qd):
return out


def is_ajax(request):
return request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'


class JsonDirect(str):
pass

Expand Down
8 changes: 5 additions & 3 deletions django_listing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django import forms
from django.contrib import messages
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ugettext
from django.utils.translation import gettext
from django.template import loader
from .listing import Listing, logger
from .listing_form import ListingForm
Expand All @@ -30,6 +30,8 @@
'LISTING_REDIRECT_NO_EDIT',
]

from .utils import is_ajax

INSTANCE_METHOD_PREFIX = 'get_listing_instance_'
LISTING_REDIRECT_NONE = None
LISTING_REDIRECT_SAME_PAGE = 1
Expand Down Expand Up @@ -62,7 +64,7 @@ def __init__(self, **kwargs):

def post(self, request, *args, **kwargs):
try:
if request.is_ajax():
if is_ajax(request):
if 'serialized_data' in request.POST:
post = request.POST.copy()
serialized_data = post.pop('serialized_data')
Expand Down Expand Up @@ -264,7 +266,7 @@ def get_form_instance(self, listing):
layout = listing.request.POST.get('listing_form_layout')
name = listing.request.POST.get('listing_form_name')
if not layout or not name:
raise InvalidListingForm(ugettext(
raise InvalidListingForm(gettext(
'At least a form layout and name are mandatory in POST data '
'to build a relevant form instance'))
listing_form = ListingForm(listing.action, name=name, layout=layout)
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ def get_version(pkg):
"Framework :: Django",
"Framework :: Django :: 2.0",
"Framework :: Django :: 3.0",
"Framework :: Django :: 4.0",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
keywords='table, datatable, listing, data grid',
url='https://github.com/elapouya/django-listing',
Expand Down

0 comments on commit 83baa32

Please sign in to comment.