diff options
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r-- | archaeological_context_records/models.py | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index eb786db74..985390861 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -999,94 +999,6 @@ class ContextRecord( } return dct - @classmethod - def cached_label_bulk_update( - cls, operation_id=None, parcel_id=None, transaction_id=None - ): - profile = get_current_profile() - if profile.contextrecord_cached_label: - # no bulk possible - q = cls.objects - if operation_id: - q = q.filter(operation_id=operation_id) - elif parcel_id: - q = q.filter(parcel_id=parcel_id) - else: - return - for cr in q.all(): - cr.skip_history_when_saving = True - cr._no_move = True - cr.save() - cls._meta.get_field("base_finds").related_model.cached_label_bulk_update( - operation_id=operation_id, parcel_id=parcel_id, - transaction_id=transaction_id - ) - return - transaction_id, is_recursion = cls.bulk_recursion( - transaction_id, [operation_id, parcel_id] - ) - if is_recursion: - return - - if operation_id: - where = "operation_id = %s" - args = [int(operation_id)] - kwargs = {"operation_id": operation_id} - elif parcel_id: - where = "parcel_id = %s" - args = [int(parcel_id)] - kwargs = {"parcel_id": parcel_id} - else: - return - kwargs["transaction_id"] = transaction_id - - profile = get_current_profile() - - sql = """ - UPDATE "archaeological_context_records_contextrecord" AS cr - SET cached_label = - CASE - WHEN context_records_cached_label_bulk_update.main_code - IS NULL - THEN - CASE - WHEN context_records_cached_label_bulk_update.year - IS NOT NULL - AND context_records_cached_label_bulk_update.ope_code - IS NOT NULL - THEN - '{ope_prefix}' || - context_records_cached_label_bulk_update.year || - '-' || - context_records_cached_label_bulk_update.ope_code - ELSE '' - END - ELSE - '{main_ope_prefix}' || - context_records_cached_label_bulk_update.main_code - END - || '{join}' || - context_records_cached_label_bulk_update.section || '{join}' || - context_records_cached_label_bulk_update.number || '{join}' || - context_records_cached_label_bulk_update.label - FROM context_records_cached_label_bulk_update - WHERE cr.id = context_records_cached_label_bulk_update.id - AND cr.id IN ( - SELECT id FROM archaeological_context_records_contextrecord - WHERE {where} - ); - """.format( - main_ope_prefix=(profile.operation_prefix or ""), - ope_prefix=(profile.default_operation_prefix or ""), - join=settings.JOINT, - where=where, - ) - with connection.cursor() as c: - c.execute(sql, args) - cls._meta.get_field("base_finds").related_model.cached_label_bulk_update( - **kwargs - ) - @property def short_label(self): return settings.JOINT.join( @@ -1230,10 +1142,6 @@ class ContextRecord( BaseFind.objects.filter(context_record=self).all() ) - def _cached_labels_bulk_update(self): - self.base_finds.model.cached_label_bulk_update(context_record_id=self.pk) - return True - def _get_base_image_path(self): return self.operation._get_base_image_path() + "/{}/{}".format( self.SLUG, slugify(self.label or "00") |