Browse Source

Implements automatic concatenation fieldtype

Yann Weber 9 years ago
parent
commit
eaca82da1f
2 changed files with 17 additions and 1 deletions
  1. 16
    0
      EditorialModel/fieldtypes/concat.py
  2. 1
    1
      EditorialModel/fieldtypes/regexchar.py

+ 16
- 0
EditorialModel/fieldtypes/concat.py View File

@@ -0,0 +1,16 @@
1
+#-*- coding: utf-8 -*-
2
+
3
+from . import char
4
+
5
+class EmFieldType(char.EmFieldType):
6
+    help = 'Automatic string field, defined as concatenation of other fields'
7
+
8
+    def __init__(self, field_list, max_length, **kwargs):
9
+        self._field_list = field_list
10
+        super().__init__(internal='automatic', max_length = max_length)
11
+
12
+    def _construct_data(self, lec, fname, datas, cur_value):
13
+        ret = ''
14
+        for fname in self._field_list:
15
+            ret += datas[fname]
16
+        return ret

+ 1
- 1
EditorialModel/fieldtypes/regexchar.py View File

@@ -17,7 +17,7 @@ class EmFieldType(char.EmFieldType):
17 17
         self.compiled_re = re.compile(regex)  # trigger an error if invalid regex
18 18
 
19 19
 
20
-        super(EmFieldType, self).__init__(check_data_value=check_value, max_length=max_length, **kwargs)
20
+        super().__init__(check_data_value=check_value, max_length=max_length, **kwargs)
21 21
 
22 22
     def _check_data_value(self,value):
23 23
         error = None

Loading…
Cancel
Save