mirror of
https://github.com/yweber/lodel2.git
synced 2026-07-15 11:41:58 +02:00
Implements automatic concatenation fieldtype
This commit is contained in:
parent
1daf9677c6
commit
eaca82da1f
2 changed files with 17 additions and 1 deletions
16
EditorialModel/fieldtypes/concat.py
Normal file
16
EditorialModel/fieldtypes/concat.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#-*- coding: utf-8 -*-
|
||||
|
||||
from . import char
|
||||
|
||||
class EmFieldType(char.EmFieldType):
|
||||
help = 'Automatic string field, defined as concatenation of other fields'
|
||||
|
||||
def __init__(self, field_list, max_length, **kwargs):
|
||||
self._field_list = field_list
|
||||
super().__init__(internal='automatic', max_length = max_length)
|
||||
|
||||
def _construct_data(self, lec, fname, datas, cur_value):
|
||||
ret = ''
|
||||
for fname in self._field_list:
|
||||
ret += datas[fname]
|
||||
return ret
|
||||
|
|
@ -17,7 +17,7 @@ class EmFieldType(char.EmFieldType):
|
|||
self.compiled_re = re.compile(regex) # trigger an error if invalid regex
|
||||
|
||||
|
||||
super(EmFieldType, self).__init__(check_data_value=check_value, max_length=max_length, **kwargs)
|
||||
super().__init__(check_data_value=check_value, max_length=max_length, **kwargs)
|
||||
|
||||
def _check_data_value(self,value):
|
||||
error = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue