Browse Source

Bugfix in datahandlers/base_classes.py

Deleted old methods that are unused (one of them was triggerring an error will doing nothing)
Yann Weber 8 years ago
parent
commit
62f92ff641
1 changed files with 0 additions and 64 deletions
  1. 0
    64
      lodel/leapi/datahandlers/base_classes.py

+ 0
- 64
lodel/leapi/datahandlers/base_classes.py View File

@@ -402,70 +402,6 @@ class MultipleRef(Reference):
402 402
             raise FieldValidationError("MultipleRef have for invalid values [%s]  :" % (",".join(error_list)))
403 403
         return new_val
404 404
 
405
-    ##@brief Construct a multiple ref data
406
-    def construct_data(self, emcomponent, fname, datas, cur_value):
407
-        cur_value = super().construct_data(emcomponent, fname, datas, cur_value)
408
-        if cur_value is not None:
409
-            if self.back_reference is not None:
410
-                br_class = self.back_reference[0]
411
-                for br_id in cur_value:
412
-                    query_filters = list()
413
-                    query_filters.append((br_class.uid_fieldname()[0], '=', br_id))
414
-                    br_obj = br_class.get(query_filters)
415
-                    if len(br_obj) != 0:
416
-                        br_list = br_obj[0].data(self.back_reference[1])
417
-                        if br_list is None:
418
-                            br_list = list()
419
-                        if br_id not in br_list:
420
-                            br_list.append(br_id)
421
-        return cur_value
422
-
423
-    ## @brief Checks the backreference, updates it if it is not complete
424
-    # @param emcomponent EmComponent : An EmComponent child class instance
425
-    # @param fname : the field name
426
-    # @param datas dict : dict storing fields values
427
-    # @note Not done in case of delete
428
-    def make_consistency(self, emcomponent, fname, datas, type_query):
429
-        dh = emcomponent.field(fname)
430
-        logger.info('Warning : multiple uid capabilities are broken here')
431
-        uid = datas[emcomponent.uid_fieldname()[0]]
432
-        if self.back_reference is not None:
433
-            target_class = self.back_reference[0]
434
-            target_field = self.back_reference[1]
435
-            target_uidfield = target_class.uid_fieldname()[0]
436
-            l_value = datas[fname]
437
-
438
-            if l_value is not None:
439
-                for value in l_value:
440
-                    query_filters = list()
441
-                    query_filters.append((target_uidfield, '=', value))
442
-                    obj = target_class.get(query_filters)
443
-                    if len(obj) == 0:
444
-                        logger.warning('Object referenced does not exist')
445
-                        return False
446
-                    l_uids_ref = obj[0].data(target_field)
447
-                    if l_uids_ref is None:
448
-                        l_uids_ref = list()
449
-                    if uid not in l_uids_ref:
450
-                        l_uids_ref.append(uid)
451
-                        obj[0].set_data(target_field, l_uids_ref)
452
-                        obj[0].update()
453
-
454
-            if type_query == 'update':
455
-                query_filters = list()
456
-                query_filters.append((uid, ' in ', target_field))
457
-                objects = target_class.get(query_filters)
458
-                if l_value is None:
459
-                    l_value = list()
460
-                if len(objects) != len(l_value):
461
-                    for obj in objects:
462
-                        l_uids_ref = obj.data(target_field)
463
-                        if obj.data(target_uidfield) not in l_value:
464
-                            l_uids_ref.remove(uid)
465
-                            obj.set_data(target_field, l_uids_ref)
466
-                            obj.update()
467
-
468
-
469 405
 
470 406
 ## @brief Class designed to handle datas access will fieldtypes are constructing datas
471 407
 #@ingroup lodel2_datahandlers

Loading…
Cancel
Save