Browse Source

Add a forgotten file (namerelation)

Yann Weber 9 years ago
parent
commit
f28c941a38
1 changed files with 24 additions and 0 deletions
  1. 24
    0
      EditorialModel/fieldtypes/namerelation.py

+ 24
- 0
EditorialModel/fieldtypes/namerelation.py View File

@@ -0,0 +1,24 @@
1
+#-*- coding: utf-8 -*-
2
+
3
+from EditorialModel import classtypes as lodelconst
4
+
5
+from . import char
6
+from .generic import FieldTypeError
7
+
8
+class EmFieldType(char.EmFieldType):
9
+    help = 'Only designed to handle relation_name field value'
10
+
11
+    def __init__(self, **kwargs):
12
+        super().__init__(**kwargs)
13
+
14
+    def check_data_consistency(self, lec, fname, datas):
15
+        # We are in a context where lec is a LeRelation child class
16
+        if lec.implements_lerel2type():
17
+            superior = datas[lodelconst.relation_superior]
18
+            if datas[fname] not in superior._linked_types.keys():
19
+                return FieldTypeError("Bad relation_name for rel2type %s : '%s'" % (lec.__name__, datas[fname]))
20
+        elif  (datas[fname] is not None) and len(datas[fname] > 0):
21
+            return FieldTypeError("No relation_name allowed for hierarchical relations")
22
+        return True
23
+            
24
+

Loading…
Cancel
Save