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
24f3a90e
Verified
Commit
24f3a90e
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Move get_db_field to FieldType base class
parent
10704346
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
+7
-15
7 additions, 15 deletions
aleksis/apps/csv_import/field_types.py
with
7 additions
and
15 deletions
aleksis/apps/csv_import/field_types.py
+
7
−
15
View file @
24f3a90e
...
...
@@ -24,6 +24,7 @@ class FieldType:
verbose_name
:
str
=
""
models
:
Sequence
=
[]
data_type
:
type
=
str
db_field
:
str
=
""
converter
:
Optional
[
Union
[
str
,
Sequence
[
str
]]]
=
None
alternative
:
Optional
[
str
]
=
None
args
:
Optional
[
dict
]
=
None
...
...
@@ -69,6 +70,12 @@ class FieldType:
def
get_column_name
(
cls
)
->
str
:
return
cls
.
name
@classmethod
def
get_db_field
(
cls
):
if
cls
.
get_args
().
get
(
"
db_field
"
):
return
cls
.
get_args
()[
"
db_field
"
]
return
cls
.
db_field
@classmethod
def
is_model_valid
(
cls
,
model
:
Model
)
->
bool
:
if
not
cls
.
models
:
...
...
@@ -84,15 +91,8 @@ class FieldType:
class
MatchFieldType
(
FieldType
):
"""
Field type for getting an instance.
"""
db_field
:
str
=
""
priority
:
int
=
1
@classmethod
def
get_db_field
(
cls
):
if
cls
.
get_args
().
get
(
"
db_field
"
):
return
cls
.
get_args
()[
"
db_field
"
]
return
cls
.
db_field
@classmethod
def
get_priority
(
cls
):
return
cls
.
get_args
().
get
(
"
priority
"
,
""
)
or
cls
.
priority
...
...
@@ -101,14 +101,6 @@ class MatchFieldType(FieldType):
class
DirectMappingFieldType
(
FieldType
):
"""
Set value directly in DB.
"""
db_field
:
str
=
""
@classmethod
def
get_db_field
(
cls
):
if
cls
.
get_args
().
get
(
"
db_field
"
):
return
cls
.
get_args
()[
"
db_field
"
]
return
cls
.
db_field
@classmethod
def
get_column_name
(
cls
):
return
cls
.
get_db_field
()
...
...
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