Skip to content

Commit 605e879

Browse files
committed
fixes django 1.11 compat issue
1 parent 62dd7cf commit 605e879

File tree

13 files changed

+53
-24
lines changed

13 files changed

+53
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ __pycache__
2222
*.pyc
2323
*.egg-info
2424
*.sqlite
25+
.testmondata

CHANGES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Release 1.4 (dev)
22
-----------------
3-
*
3+
* django 1.11 compatibility
44

55

66
Release 1.3.2 (10 Sep 2016)

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Django Concurrency
55

66
django-concurrency is an optimistic lock [1]_ implementation for Django.
77

8-
Supported Django versions: 1.6.x, 1.7.x, 1.8.x, 1.9.
8+
Supported Django versions: 1.8.x, 1.9.x, 1.10.x., 1.11.x
99

1010
It prevents users from doing concurrent editing in Django both from UI and from a
1111
django command.

src/concurrency/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from __future__ import absolute_import, unicode_literals
22

33
from django.core.exceptions import ImproperlyConfigured
4-
from django.core.urlresolvers import get_callable
4+
try:
5+
from django.core.urlresolvers import get_callable
6+
except ImportError:
7+
from django.urls.utils import get_callable
58
from django.test.signals import setting_changed
69
from django.utils import six
710

src/concurrency/middleware.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
from __future__ import absolute_import, unicode_literals
33

44
from django.core.signals import got_request_exception
5-
from django.core.urlresolvers import get_callable
65

76
from concurrency.config import conf
87
from concurrency.exceptions import RecordModifiedError
98

9+
try:
10+
from django.core.urlresolvers import get_callable
11+
except ImportError:
12+
from django.urls.utils import get_callable
13+
14+
1015

1116
class ConcurrencyMiddleware(object):
1217
""" Intercept :ref:`RecordModifiedError` and invoke a callable defined in

src/concurrency/views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from django.http import HttpResponse
55
from django.template import loader
66
from django.template.base import Template
7-
from django.template.context import RequestContext
87
from django.utils.translation import ugettext as _
98

109
from concurrency.compat import TemplateDoesNotExist
@@ -40,7 +39,8 @@ def conflict(request, target=None, template_name='409.html'):
4039
saved = target.__class__._default_manager.get(pk=target.pk)
4140
except target.__class__.DoesNotExist:
4241
saved = None
43-
ctx = RequestContext(request, {'target': target,
44-
'saved': saved,
45-
'request_path': request.path})
42+
ctx = {'target': target,
43+
'saved': saved,
44+
'request_path': request.path}
45+
4646
return ConflictResponse(template.render(ctx))

src/requirements/develop.pip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
coverage
22
django_extensions
33
flake8
4-
ipython
4+
ipython<6.0
55
pdbpp
66
psycopg2
77
sphinx

src/requirements/testing.pip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ pytest-django>=3.0.0
77
pytest-echo>=1.3
88
pytest-pythonpath>=0.7.1
99
pytest>=3.0.3
10+
pytest-watch
11+
pytest-testmon
1012
pdbpp
1113
readline
1214
tox>=2.4.1

tests/demoapp/demo/models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class ConditionalVersionModel(models.Model):
209209
field1 = models.CharField(max_length=30, blank=True, null=True, unique=True)
210210
field2 = models.CharField(max_length=30, blank=True, null=True, unique=True)
211211
field3 = models.CharField(max_length=30, blank=True, null=True, unique=True)
212-
user = models.ForeignKey(User, null=True)
212+
user = models.ForeignKey(User, null=True, on_delete=models.CASCADE)
213213

214214
class Meta:
215215
app_label = 'demo'
@@ -224,7 +224,8 @@ class Anything(models.Model):
224224
ConditionalVersionModelWithoutMeta instances.
225225
"""
226226
name = models.CharField(max_length=10)
227-
a_relation = models.ForeignKey('demo.ConditionalVersionModelWithoutMeta')
227+
a_relation = models.ForeignKey('demo.ConditionalVersionModelWithoutMeta',
228+
on_delete=models.CASCADE)
228229

229230
class Meta:
230231
app_label = 'demo'
@@ -238,7 +239,7 @@ class ConditionalVersionModelWithoutMeta(models.Model):
238239
field1 = models.CharField(max_length=30, blank=True, null=True, unique=True)
239240
field2 = models.CharField(max_length=30, blank=True, null=True, unique=True)
240241
field3 = models.CharField(max_length=30, blank=True, null=True, unique=True)
241-
user = models.ForeignKey(User, null=True)
242+
user = models.ForeignKey(User, null=True, on_delete=models.CASCADE)
242243
anythings = models.ManyToManyField(Anything)
243244

244245
class Meta:
@@ -248,8 +249,10 @@ class Meta:
248249
class ThroughRelation(models.Model):
249250
version = ConditionalVersionField()
250251
left = models.ForeignKey('demo.ConditionalVersionModelSelfRelation',
252+
on_delete=models.CASCADE,
251253
related_name='+')
252254
right = models.ForeignKey('demo.ConditionalVersionModelSelfRelation',
255+
on_delete=models.CASCADE,
253256
related_name='+')
254257

255258
class Meta:

tests/demoapp/demo/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
UpdateView.as_view(model=SimpleConcurrentModel),
1818
name='concurrent-edit'),
1919
url(r'^admin/',
20-
include(admin.site.urls))
20+
admin.site.urls)
2121
)

0 commit comments

Comments
 (0)