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

Fix deprecation warnings #219

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion binder/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from .json import jsondumps, JsonResponse


transaction_commit = Signal(providing_args=['changeset'])
# Providing args is ['changeset']
transaction_commit = Signal()


class Changeset(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion binder/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ def update_dimension_fields(self, instance, force=False, *args, **kwargs):
if not file and not force:
return

dimension_fields_filled = not(
dimension_fields_filled = not (
(self.width_field and not getattr(instance, self.width_field)) or
(self.height_field and not getattr(instance, self.height_field))
)
Expand Down
17 changes: 8 additions & 9 deletions binder/router.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from importlib import import_module

import django
from django.apps import apps
from django.urls import reverse
from django.urls import reverse, re_path

from binder.views import ModelView
from .exceptions import BinderRequestError, BinderCSRFFailure, BinderMethodNotAllowed, BinderNotFound
Expand Down Expand Up @@ -171,18 +170,18 @@ def urls(self):
name = view.model.__name__ if view.model else route.route
# List and detail endpoints
if route.list_endpoint:
urls.append(django.conf.urls.url(r'^{}/$'.format(route.route), view.as_view(), {'router': self}, name=name))
urls.append(re_path(r'^{}/$'.format(route.route), view.as_view(), {'router': self}, name=name))
if route.detail_endpoint:
urls.append(django.conf.urls.url(r'^{}/(?P<pk>[0-9]+)/$'.format(route.route), view.as_view(), {'router': self}, name=name))
urls.append(re_path(r'^{}/(?P<pk>[0-9]+)/$'.format(route.route), view.as_view(), {'router': self}, name=name))

# History views
if view.model and hasattr(view.model, 'Binder') and view.model.Binder.history:
urls.append(django.conf.urls.url(r'^{}/(?P<pk>[0-9]+)/history/$'.format(route.route), view.as_view(), {'history': 'normal', 'router': self}, name=name))
urls.append(django.conf.urls.url(r'^{}/(?P<pk>[0-9]+)/history/debug/$'.format(route.route), view.as_view(), {'history': 'debug', 'router': self}, name=name))
urls.append(re_path(r'^{}/(?P<pk>[0-9]+)/history/$'.format(route.route), view.as_view(), {'history': 'normal', 'router': self}, name=name))
urls.append(re_path(r'^{}/(?P<pk>[0-9]+)/history/debug/$'.format(route.route), view.as_view(), {'history': 'debug', 'router': self}, name=name))

# File field endpoints
for ff in view.file_fields:
urls.append(django.conf.urls.url(r'^{}/(?P<pk>[0-9]+)/{}/$'.format(route.route, ff),
urls.append(re_path(r'^{}/(?P<pk>[0-9]+)/{}/$'.format(route.route, ff),
view.as_view(), {'file_field': ff, 'router': self}, name='{}.{}'.format(name, ff)))

# Custom endpoints
Expand All @@ -195,10 +194,10 @@ def urls(self):
if method.unauthenticated:
kwargs['unauthenticated'] = True
if hasattr(method, 'detail_route'):
urls.append(django.conf.urls.url(r'^{}/(?P<pk>[0-9]+)/{}/{}$'.format(route.route, route_name, extra),
urls.append(re_path(r'^{}/(?P<pk>[0-9]+)/{}/{}$'.format(route.route, route_name, extra),
view.as_view(), kwargs, name='{}.{}'.format(name, route_name)))
if hasattr(method, 'list_route'):
urls.append(django.conf.urls.url(r'^{}/{}/{}$'.format(route.route, route_name, extra),
urls.append(re_path(r'^{}/{}/{}$'.format(route.route, route_name, extra),
view.as_view(), kwargs, name='{}.{}'.format(name, route_name)))

return urls
4 changes: 2 additions & 2 deletions binder/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def _annotate_objs(self, datas_by_id, objs_by_id):
for obj_id, data in datas_by_id.items():
# TODO: Don't require OneToOneFields in the m2m_fields list
if isinstance(local_field, models.OneToOneRel):
assert(len(idmap[obj_id]) <= 1)
assert len(idmap[obj_id]) <= 1
data[field_name] = idmap[obj_id][0] if len(idmap[obj_id]) == 1 else None
else:
data[field_name] = idmap[obj_id]
Expand Down Expand Up @@ -1634,7 +1634,7 @@ def store_m2m_field(obj, field, value, request):

try:
obj.save()
assert(obj.pk is not None) # At this point, the object must have been created.
assert obj.pk is not None # At this point, the object must have been created.
except ValidationError as ve:
validation_errors.append(self.binder_validation_error(obj, ve, pk=pk))

Expand Down