1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2025-11-30 08:36:53 +01:00

Add the relation_name field to relation_common_fields list

We have to create a special fieldtype to handle this field
This commit is contained in:
Yann 2016-01-15 14:48:23 +01:00
commit da89046c33
2 changed files with 16 additions and 2 deletions

View file

@ -7,6 +7,7 @@ object_em_type_id = 'type_id'
relation_uid = 'id_relation'
relation_superior = 'superior'
relation_subordinate = 'subordinate'
relation_name = 'relation_name'
common_fields = {
@ -66,6 +67,11 @@ relations_common_fields = {
relation_subordinate: {
'fieldtype': 'leo',
'superior': False,
},
relation_name: {
'fieldtype': 'char',
'max_length': 128,
'internal': 'automatic',
}
}

View file

@ -8,6 +8,7 @@ from unittest.mock import patch
from collections import OrderedDict
import EditorialModel
import EditorialModel.classtypes
import DataSource.dummy
import leapi
import leapi.test.utils
@ -101,7 +102,7 @@ class LeHierarch(LeRelationTestCase):
[],
LeHierarch,
[ 'nature', 'rank', 'subordinate', 'depth', 'superior', 'id_relation'],
[ 'nature', 'rank', 'subordinate', 'depth', 'superior', 'id_relation', EditorialModel.classtypes.relation_name],
[('superior', '=', Numero(42))],
[],
),
@ -116,6 +117,7 @@ class LeHierarch(LeRelationTestCase):
self.assertEqual(len(cargs), 2)
cargs=cargs[1]
self.assertEqual(cargs['target_cls'], target, "%s != %s"%(cargs, eargs))
print("FUCK : ", cargs['field_list'])
self.assertEqual(set(cargs['field_list']), set(field_ds), "%s != %s"%(cargs, eargs))
self.assertEqual(cargs['filters'], filters_ds, "%s != %s"%(cargs, eargs))
self.assertEqual(cargs['rel_filters'], rfilters_ds, "%s != %s"%(cargs, eargs))
@ -182,6 +184,7 @@ class LeHierarch(LeRelationTestCase):
for query, equery in queries:
equery['rank'] = 1
equery['depth'] = None
equery[EditorialModel.classtypes.relation_name] = None
LeHierarch.insert(query)
dsmock.assert_called_once_with(LeHierarch, **equery)
@ -244,7 +247,12 @@ class LeRel2TypeTestCase(LeRelationTestCase):
for query in queries:
Rel_Textes2Personne.insert(query)
eres = {'nature': None, 'depth': None, 'rank': 0}
eres = {
'nature': None,
'depth': None,
'rank': 0,
EditorialModel.classtypes.relation_name: None,
}
eres.update(query)
for fname in ('superior', 'subordinate'):
if isinstance(eres[fname], int):