Skip to content

Commit 7da3a48

Browse files
committed
fixes saxix#206. new AUTO_CREATE_TRIGGERS
1 parent 9948bcc commit 7da3a48

File tree

7 files changed

+32
-9
lines changed

7 files changed

+32
-9
lines changed

docs/settings.rst

+16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ default values.
1111
.. note:: Each entry **MUST** have the prefix ``CONCURRENCY_`` when used in your settings.py
1212

1313

14+
.. setting:: CONCURRENCY_AUTO_CREATE_TRIGGERS
15+
16+
AUTO_CREATE_TRIGGERS
17+
--------------------
18+
.. versionadded:: 2.3
19+
20+
Default: ``True``
21+
22+
If true automatically create triggers.
23+
To manually create triggers set `CONCURRENCY_AUTO_CREATE_TRIGGERS=False` and use :ref:`triggers`
24+
management command or create them manually using your DB client.
25+
26+
Note:: This flag deprecate :ref:`MANUAL_TRIGGERS`
27+
28+
1429
.. setting:: CONCURRENCY_ENABLED
1530

1631
ENABLED
@@ -102,6 +117,7 @@ numbers to pass concurrency checks.
102117
MANUAL_TRIGGERS
103118
---------------
104119
.. versionadded:: 1.0
120+
.. deprecated:: 2.3
105121

106122
Default: ``False``
107123

setup.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ def run_tests(self):
5454
'Development Status :: 5 - Production/Stable',
5555
'Environment :: Web Environment',
5656
'Intended Audience :: Developers',
57-
'License :: OSI Approved :: BSD License',
57+
'License :: OSI Approved :: MIT License',
5858
'Operating System :: OS Independent',
5959
'Programming Language :: Python',
60-
'Framework :: Django :: 1.11',
61-
'Framework :: Django :: 2.1',
62-
'Framework :: Django :: 2.2',
6360
'Framework :: Django :: 3.0',
61+
'Framework :: Django :: 3.1',
6462
'Programming Language :: Python :: 3',
6563
'Programming Language :: Python :: 3.6',
6664
'Programming Language :: Python :: 3.7',

src/concurrency/config.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
from django.core.exceptions import ImproperlyConfigured
24
from django.test.signals import setting_changed
35

@@ -18,7 +20,8 @@
1820
class AppSettings(object):
1921
defaults = {
2022
'ENABLED': True,
21-
'MANUAL_TRIGGERS': False,
23+
'AUTO_CREATE_TRIGGERS': True,
24+
'MANUAL_TRIGGERS': False, # deprecated: use AUTO_CREATE_TRIGGERS
2225
'FIELD_SIGNER': 'concurrency.forms.VersionFieldSigner',
2326
'POLICY': CONCURRENCY_LIST_EDITABLE_POLICY_SILENT,
2427
'CALLBACK': 'concurrency.views.callback',
@@ -58,6 +61,10 @@ def _set_attr(self, prefix_name, value):
5861
"{} is not a valid value for `CALLBACK`. It must be a callable or a fullpath to callable. ".format(
5962
value))
6063
self._callback = func
64+
elif name == "MANUAL_TRIGGERS":
65+
warnings.warn("MANUAL_TRIGGERS is deprecated and will be removed in 2.5. Use AUTO_CREATE_TRIGGERS",
66+
category=DeprecationWarning)
67+
self.AUTO_CREATE_TRIGGERS = not value
6168

6269
setattr(self, name, value)
6370

tests/conftest.py

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def pytest_configure():
2626

2727
settings.SILENCED_SYSTEM_CHECKS = ['concurrency.W001']
2828
settings.CONCURRENCY_VERSION_FIELD_REQUIRED = False
29+
settings.CONCURRENCY_MANUAL_TRIGGERS = False
30+
settings.CONCURRENCY_AUTO_CREATE_TRIGGERS = True
2931

3032

3133
@pytest.fixture(scope='session')

tests/test_admin_list_editable.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ def _create_conflict(self, pk):
2929

3030
def test_normal_add(self):
3131
res = self.app.get('/admin/', user='sax')
32-
32+
# file:///admin/demo/listeditableconcurrentmodel/add/
3333
res = res.click(self.TARGET._meta.verbose_name_plural)
34-
35-
res = res.click('Add', href='/admin/auth/user/add/')
34+
res = res.click('Add', href=f'/admin/demo/{self.TARGET._meta.model_name}/add/')
3635
form = res.form
3736
form['username'] = 'CHAR'
3837
res = form.submit().follow()

tests/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
@pytest.mark.django_db(transaction=False)
16-
@pytest.mark.skipIf('os.environ["DBENGINE"]=="pg"')
16+
@pytest.mark.skipif('os.environ.get("DBENGINE", "")=="pg"')
1717
def test_get_revision_of_object(model_class=SimpleConcurrentModel):
1818
instance = model_class(username=next(nextname))
1919
instance.save()

tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ addopts =
2222
pep8ignore = * ALL
2323
markers =
2424
functional: mark a test as functional
25+
admin: admin tests
2526

2627
[testenv]
2728
;install_command=pip install {opts} {packages}

0 commit comments

Comments
 (0)