Browse Source

[87] delete method from LeRelation can now take a string as parameter for the target_class

Roland Haroutiounian 8 years ago
parent
commit
71443679d5
2 changed files with 4 additions and 1 deletions
  1. 3
    0
      leapi/lerelation.py
  2. 1
    1
      leapi/test/test_lerelation.py

+ 3
- 0
leapi/lerelation.py View File

@@ -85,6 +85,9 @@ class _LeRelation(lecrud._LeCrud):
85 85
     # @param target_class str
86 86
     def delete(cls, filters_list, target_class):
87 87
         filters, rel_filters = cls._prepare_filters(filters_list)
88
+        if isinstance(target_class, str):
89
+            target_class = cls.name2class(target_class)
90
+
88 91
         ret = cls._datasource.delete(target_class, filters)
89 92
         return True if ret == 1 else False
90 93
 

+ 1
- 1
leapi/test/test_lerelation.py View File

@@ -73,7 +73,7 @@ class LeRelationTestCase(TestCase):
73 73
         """ Testing LeHierarch insert method """
74 74
         from dyncode import LeCrud, Publication, Numero, Personnes, LeObject, Rubrique, LeHierarch, LeRelation
75 75
         
76
-        LeRelation.delete([LeRelation.sup_filter(Numero(42)), 'nature = "parent"'], LeHierarch)
76
+        LeRelation.delete([LeRelation.sup_filter(Numero(42)), 'nature = "parent"'], 'LeHierarch')
77 77
         dsmock.assert_called_once_with(LeHierarch, [('lesup', '=', Numero(42)), ('nature','=','"parent"')])
78 78
         dsmock.reset_mock()
79 79
 

Loading…
Cancel
Save