Commit 937cdf72 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '68-bug-collaborations' into 'master'

Add the filter CLEAN_COLLABORATION_SYNONYM.

* Close #68 

See merge request !67
parents f039ec66 54a97187
......@@ -22,5 +22,6 @@ db.collaborations._before_delete.append(dbui.INHIBIT_DELETE_UNDEF)
db.collaborations._before_update.append(dbui.INHIBIT_UPDATE_UNDEF)
db.collaborations.collaboration.filter_in = filters.CLEAN_COLLABORATION
db.collaborations.synonyms.filter_in = filters.CLEAN_COLLABORATION_SYNONYM
db.collaborations.collaboration.requires = IS_MATCH(REG_COLLABORATION)
\ No newline at end of file
......@@ -43,6 +43,41 @@ def CLEAN_COLLABORATION(value):
return ', '.join(li)
def CLEAN_COLLABORATION_SYNONYM(value):
"""Correct stupid mistakes in the synonym field for collaboration
A synonym can contain several names separated by a comma. It should follow
standard typographic rules:
* No heading and trailing spaces
* One space after comma
* One space between word
Args:
value (list):
Returns:
list:
"""
if not isinstance(value, list):
return value
values = []
for synonym in value:
# remove leading an trailing spaces
li = [el.strip() for el in synonym.split(",")]
# remove ,,
li = [el for el in li if len(el) > 0]
# one space between word
li = [" ".join(el.split()) for el in li]
values.append(", ".join(li))
return values
def CLEAN_THESIS_DEFENSE(value):
"""Correct stupid mistakes on the thesis defence field.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment