Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
54a97187
Commit
54a97187
authored
May 06, 2016
by
LE GAC Renaud
Browse files
Add the filter CLEAN_COLLABORATION_SYNONYM.
parent
f039ec66
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
models/db0_collaborations.py
models/db0_collaborations.py
+1
-0
modules/filters.py
modules/filters.py
+35
-0
No files found.
models/db0_collaborations.py
View file @
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
modules/filters.py
View file @
54a97187
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment