summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-04-29 13:20:21 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-04-29 13:20:21 +0200
commit5f77a4ab463e711121484a17bb5de522400b2dc9 (patch)
tree5b8b1ed0402828e1acb818fd2898e7053209ff98 /archaeological_finds
parenta929afc8937dbff7def85251937798c963f85ac0 (diff)
downloadIshtar-5f77a4ab463e711121484a17bb5de522400b2dc9.tar.bz2
Ishtar-5f77a4ab463e711121484a17bb5de522400b2dc9.zip
Extra security to prevent recursion on bulk update
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/models_finds.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 3248e2214..da1823d8a 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -18,6 +18,7 @@
# See the file COPYING for details.
import datetime
+import time
from django.conf import settings
from django.contrib.gis.db import models
@@ -36,7 +37,8 @@ from ishtar_common.models import GeneralType, ImageModel, BaseHistorizedItem, \
from archaeological_operations.models import AdministrativeAct
from archaeological_context_records.models import ContextRecord, Dating
-from ishtar_common.models import PRIVATE_FIELDS, SpatialReferenceSystem
+from ishtar_common.models import PRIVATE_FIELDS, SpatialReferenceSystem, \
+ BulkUpdatedItem
class MaterialType(GeneralType):
@@ -146,7 +148,7 @@ class BFBulkView(object):
"""
-class BaseFind(BaseHistorizedItem, OwnPerms):
+class BaseFind(BulkUpdatedItem, BaseHistorizedItem, OwnPerms):
label = models.TextField(_(u"Free ID"))
external_id = models.TextField(_(u"External ID"), blank=True, null=True)
auto_external_id = models.BooleanField(
@@ -330,7 +332,12 @@ class BaseFind(BaseHistorizedItem, OwnPerms):
@classmethod
def cached_label_bulk_update(cls, operation_id=None, parcel_id=None,
- context_record_id=None):
+ context_record_id=None, transaction_id=None):
+ transaction_id, is_recursion = cls.bulk_recursion(
+ transaction_id, [operation_id, parcel_id, context_record_id])
+ if is_recursion:
+ return
+
if operation_id:
filters = """
INNER JOIN archaeological_context_records_contextrecord acr
@@ -353,6 +360,7 @@ class BaseFind(BaseHistorizedItem, OwnPerms):
kwargs = {'context_record_id': context_record_id}
else:
return
+ kwargs['transaction_id'] = transaction_id
sql = """
UPDATE "archaeological_finds_basefind" AS bf
@@ -487,8 +495,8 @@ class FBulkView(object):
"""
-class Find(ValueGetter, BaseHistorizedItem, ImageModel, OwnPerms,
- ShortMenuItem):
+class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, ImageModel,
+ OwnPerms, ShortMenuItem):
CHECK_DICT = dict(CHECK_CHOICES)
SHOW_URL = 'show-find'
SLUG = 'find'
@@ -911,7 +919,12 @@ class Find(ValueGetter, BaseHistorizedItem, ImageModel, OwnPerms,
@classmethod
def cached_label_bulk_update(cls, operation_id=None, parcel_id=None,
- context_record_id=None):
+ context_record_id=None, transaction_id=None):
+ transaction_id, is_recursion = cls.bulk_recursion(
+ transaction_id, [operation_id, parcel_id, context_record_id])
+ if is_recursion:
+ return
+
if operation_id:
filters = """
INNER JOIN find_first_base_find myfbf