diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-04-19 10:21:37 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-04-19 10:21:37 +0200 |
commit | 016c49d7a9b149720c75501525f79f19a73ff3b3 (patch) | |
tree | 60fb8dbf5cd76ab46ccfdf975b216999c6d3315d | |
parent | 270d2a3735ec65b58bdb23678aaede1b0ff90b7d (diff) | |
download | Ishtar-016c49d7a9b149720c75501525f79f19a73ff3b3.tar.bz2 Ishtar-016c49d7a9b149720c75501525f79f19a73ff3b3.zip |
Django 1.8: remove transaction.commit_unless_managed
-rw-r--r-- | archaeological_context_records/models.py | 6 | ||||
-rw-r--r-- | archaeological_finds/models_finds.py | 12 | ||||
-rw-r--r-- | ishtar_common/tests.py | 7 |
3 files changed, 9 insertions, 16 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 0a5ab7cbc..64859c185 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -346,10 +346,8 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms, """.format(main_ope_prefix=settings.ISHTAR_OPE_PREFIX, ope_prefix=settings.ISHTAR_DEF_OPE_PREFIX, join=settings.JOINT, where=where) - # with connection.cursor() as c: # django 1.8 - c = connection.cursor() - c.execute(sql, args) - transaction.commit_unless_managed() + with connection.cursor() as c: + c.execute(sql, args) cls._meta.get_field_by_name( 'base_finds')[0].model.cached_label_bulk_update(**kwargs) diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index b5e58a98b..6e920bc7d 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -430,10 +430,8 @@ class BaseFind(BaseHistorizedItem, OwnPerms): ope_prefix=settings.ISHTAR_DEF_OPE_PREFIX, join=settings.JOINT, filters=filters, zeros=settings.ISHTAR_FINDS_INDEX_ZERO_LEN * "0") - # with connection.cursor() as c: # django 1.8 - c = connection.cursor() - c.execute(sql, args) - transaction.commit_unless_managed() + with connection.cursor() as c: + c.execute(sql, args) cls._meta.get_field_by_name( 'find')[0].model.cached_label_bulk_update(**kwargs) @@ -983,10 +981,8 @@ class Find(ValueGetter, BaseHistorizedItem, ImageModel, OwnPerms, ope_prefix=settings.ISHTAR_DEF_OPE_PREFIX, join=settings.JOINT, filters=filters, zeros=settings.ISHTAR_FINDS_INDEX_ZERO_LEN * "0") - # with connection.cursor() as c: # django 1.8 - c = connection.cursor() - c.execute(sql, args) - transaction.commit_unless_managed() + with connection.cursor() as c: + c.execute(sql, args) def save(self, *args, **kwargs): super(Find, self).save(*args, **kwargs) diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 49db86b64..01ff26c5e 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -91,10 +91,9 @@ class TestCase(BaseTestCase): super(TestCase, self)._pre_setup() if settings.USE_SPATIALITE_FOR_TESTS: return - c = connection.cursor() - for view in [CRBulkView, FirstBaseFindView, BFBulkView, FBulkView]: - c.execute(view.CREATE_SQL) - transaction.commit_unless_managed() + with connection.cursor() as c: + for view in [CRBulkView, FirstBaseFindView, BFBulkView, FBulkView]: + c.execute(view.CREATE_SQL) class CommandsTestCase(TestCase): |