Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
e8013730
Commit
e8013730
authored
4 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Připsání mailu do chybové hlášky při importu.
Closes
#190
parent
61e22e2e
No related branches found
No related tags found
1 merge request
!83
Připsání mailu do chybové hlášky při importu.
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/imports.py
+13
-1
13 additions, 1 deletion
mo/imports.py
with
13 additions
and
1 deletion
mo/imports.py
+
13
−
1
View file @
e8013730
...
@@ -69,6 +69,7 @@ class Import:
...
@@ -69,6 +69,7 @@ class Import:
gatekeeper
:
mo
.
rights
.
Gatekeeper
gatekeeper
:
mo
.
rights
.
Gatekeeper
new_user_ids
:
List
[
int
]
new_user_ids
:
List
[
int
]
line_number
:
int
=
0
line_number
:
int
=
0
row_name
:
Optional
[
str
]
=
None
def
__init__
(
self
):
def
__init__
(
self
):
self
.
errors
=
[]
self
.
errors
=
[]
...
@@ -84,6 +85,9 @@ class Import:
...
@@ -84,6 +85,9 @@ class Import:
def
error
(
self
,
msg
:
str
)
->
Any
:
def
error
(
self
,
msg
:
str
)
->
Any
:
if
self
.
line_number
>
0
:
if
self
.
line_number
>
0
:
if
self
.
row_name
:
msg
=
f
"
Řádek
{
self
.
line_number
}
(
{
self
.
row_name
}
):
{
msg
}
"
else
:
msg
=
f
"
Řádek
{
self
.
line_number
}
:
{
msg
}
"
msg
=
f
"
Řádek
{
self
.
line_number
}
:
{
msg
}
"
self
.
errors
.
append
(
msg
)
self
.
errors
.
append
(
msg
)
logger
.
info
(
'
Import: >> %s
'
,
msg
)
logger
.
info
(
'
Import: >> %s
'
,
msg
)
...
@@ -376,6 +380,12 @@ class Import:
...
@@ -376,6 +380,12 @@ class Import:
except
UnicodeDecodeError
:
except
UnicodeDecodeError
:
return
False
return
False
def
get_row_name
(
self
,
row
:
mo
.
csv
.
Row
)
->
Optional
[
str
]:
if
hasattr
(
row
,
'
email
'
):
return
row
.
email
# type: ignore
# čtení prvku potomka
return
None
def
generic_import
(
self
,
path
:
str
)
->
bool
:
def
generic_import
(
self
,
path
:
str
)
->
bool
:
charset
=
self
.
fmt
.
get_charset
()
charset
=
self
.
fmt
.
get_charset
()
if
charset
!=
'
utf-8
'
and
self
.
check_utf8
(
path
):
if
charset
!=
'
utf-8
'
and
self
.
check_utf8
(
path
):
...
@@ -396,12 +406,14 @@ class Import:
...
@@ -396,12 +406,14 @@ class Import:
self
.
line_number
=
2
self
.
line_number
=
2
for
row
in
rows
:
for
row
in
rows
:
self
.
row_name
=
self
.
get_row_name
(
row
)
self
.
cnt_rows
+=
1
self
.
cnt_rows
+=
1
self
.
import_row
(
row
)
self
.
import_row
(
row
)
if
len
(
self
.
errors
)
>=
100
:
if
len
(
self
.
errors
)
>=
100
:
self
.
errors
.
append
(
'
Import přerušen pro příliš mnoho chyb
'
)
self
.
errors
.
append
(
'
Import přerušen pro příliš mnoho chyb
'
)
break
break
self
.
line_number
+=
1
self
.
line_number
+=
1
self
.
row_name
=
None
return
len
(
self
.
errors
)
==
0
return
len
(
self
.
errors
)
==
0
...
...
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