Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-CSVImport
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mike Gabriel
AlekSIS-App-CSVImport
Commits
ea703a7e
Verified
Commit
ea703a7e
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Allow defining converter_pre and converter_post in templates
parent
849baba6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/csv_import/field_types.py
+22
-16
22 additions, 16 deletions
aleksis/apps/csv_import/field_types.py
with
22 additions
and
16 deletions
aleksis/apps/csv_import/field_types.py
+
22
−
16
View file @
ea703a7e
...
...
@@ -32,22 +32,28 @@ class FieldType:
@classmethod
def
get_converter
(
cls
)
->
Callable
[[
Any
],
Any
]:
if
not
cls
.
converter
:
return
lambda
val
:
val
else
:
if
isinstance
(
cls
.
converter
,
Sequence
):
funcs
=
cls
.
converter
else
:
funcs
=
[
cls
.
converter
]
funcs
=
[
converter_registry
.
get_from_name
(
name
)
for
name
in
funcs
]
def
_converter_chain
(
val
:
Any
)
->
Any
:
new_val
=
val
for
func
in
funcs
:
new_val
=
func
(
new_val
)
return
new_val
return
_converter_chain
converters_pre
=
cls
.
get_args
().
get
(
"
converter_pre
"
,
[])
if
isinstance
(
converters_pre
,
str
):
converters_pre
=
[
converters_pre
]
converters_post
=
cls
.
get_args
().
get
(
"
converter_post
"
,
[])
if
isinstance
(
converters_post
,
str
):
converters_post
=
[
converters_post
]
converters
=
cls
.
converter
if
converters
is
None
:
converters
=
[]
elif
isinstance
(
converters
,
str
):
converters
=
[
converters
]
converters
=
converters_pre
+
converters
+
converters_post
funcs
=
[
converter_registry
.
get_from_name
(
name
)
for
name
in
converters
]
def
_converter_chain
(
val
:
Any
)
->
Any
:
new_val
=
val
for
func
in
funcs
:
new_val
=
func
(
new_val
)
return
new_val
return
_converter_chain
@classmethod
def
get_alternative
(
cls
)
->
Optional
[
str
]:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment