Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
ff59a5d7
Commit
ff59a5d7
authored
5 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
formatting of email added
parent
86e61c84
No related branches found
No related tags found
1 merge request
!231
Resolve "auto-import of subject data"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
smash/smash/settings.py
+1
-0
1 addition, 0 deletions
smash/smash/settings.py
smash/web/importer/importer.py
+14
-5
14 additions, 5 deletions
smash/web/importer/importer.py
smash/web/importer/importer_cron_job.py
+7
-3
7 additions, 3 deletions
smash/web/importer/importer_cron_job.py
with
22 additions
and
8 deletions
smash/smash/settings.py
+
1
−
0
View file @
ff59a5d7
...
@@ -76,6 +76,7 @@ CRON_CLASSES = [
...
@@ -76,6 +76,7 @@ CRON_CLASSES = [
'
web.views.kit.KitRequestEmailSendJob
'
,
'
web.views.kit.KitRequestEmailSendJob
'
,
'
web.redcap_connector.RedCapRefreshJob
'
,
'
web.redcap_connector.RedCapRefreshJob
'
,
'
web.views.voucher.ExpireVouchersJob
'
,
'
web.views.voucher.ExpireVouchersJob
'
,
'
web.importer.importer_cron_job.ImporterCronJob
'
]
]
# Password validation
# Password validation
...
...
This diff is collapsed.
Click to expand it.
smash/web/importer/importer.py
+
14
−
5
View file @
ff59a5d7
...
@@ -65,8 +65,17 @@ class Importer(object):
...
@@ -65,8 +65,17 @@ class Importer(object):
self
.
added_count
+=
1
self
.
added_count
+=
1
def
get_summary
(
self
):
def
get_summary
(
self
):
return
"
<p>Number of entries: <b>
"
+
str
(
len
(
self
.
study_subjects
))
+
"
</b></p>
"
+
\
result
=
"
<p>Number of entries: <b>
"
+
str
(
len
(
self
.
study_subjects
))
+
"
</b></p>
"
+
\
"
<p>Number of successfully added entries: <b>
"
+
str
(
self
.
added_count
)
+
"
</b></p>
"
+
\
"
<p>Number of successfully added entries: <b>
"
+
str
(
self
.
added_count
)
+
"
</b></p>
"
+
\
"
<p>Number of successfully merged entries: <b>
"
+
str
(
self
.
merged_count
)
+
"
</b></p>
"
+
\
"
<p>Number of successfully merged entries: <b>
"
+
str
(
self
.
merged_count
)
+
"
</b></p>
"
"
<p>Number of problematic entries: <b>
"
+
str
(
self
.
problematic_count
)
+
"
</b></p>
"
+
\
style
=
''
"
<p>Number of raised warnings: <b>
"
+
str
(
self
.
warning_count
)
+
"
</b></p>
"
if
self
.
problematic_count
>
0
:
style
=
'
color=
"
red
"
'
result
+=
"
<p><font
"
+
style
+
"
>Number of problematic entries: <b>
"
+
str
(
self
.
problematic_count
)
+
"
</b></font></p>
"
style
=
''
if
self
.
warning_count
>
0
:
style
=
'
color=
"
brown
"
'
result
+=
"
<p><font
"
+
style
+
"
>Number of raised warnings: <b>
"
+
str
(
self
.
warning_count
)
+
"
</b></font></p>
"
return
result
This diff is collapsed.
Click to expand it.
smash/web/importer/importer_cron_job.py
+
7
−
3
View file @
ff59a5d7
...
@@ -26,24 +26,28 @@ class ImporterCronJob(CronJobBase):
...
@@ -26,24 +26,28 @@ class ImporterCronJob(CronJobBase):
recipients
=
getattr
(
settings
,
"
DEFAULT_FROM_EMAIL
"
,
None
)
recipients
=
getattr
(
settings
,
"
DEFAULT_FROM_EMAIL
"
,
None
)
filename
=
getattr
(
settings
,
"
DAILY_IMPORT_FILE
"
,
None
)
filename
=
getattr
(
settings
,
"
DAILY_IMPORT_FILE
"
,
None
)
if
filename
is
None
:
if
filename
is
None
:
logger
.
info
(
"
Importing subjects skipped. File not defined
"
)
return
"
import file not defined
"
return
"
import file not defined
"
logger
.
info
(
"
Importing subjects from file:
"
+
filename
)
if
not
os
.
path
.
isfile
(
filename
):
if
not
os
.
path
.
isfile
(
filename
):
EmailSender
().
send_email
(
title
,
EmailSender
().
send_email
(
title
,
"
<h
1
>File with imported data is not available in the system:
"
+
filename
+
"
</
h1
>
"
,
"
<h
3><font color=
'
red
'
>File with imported data is not available in the system:
"
+
filename
+
"
</
font></h3
>
"
,
recipients
)
recipients
)
return
"
import file not found
"
try
:
try
:
importer
=
Importer
(
settings
.
DAILY_IMPORT_FILE
,
CsvSubjectImportReader
())
importer
=
Importer
(
settings
.
DAILY_IMPORT_FILE
,
CsvSubjectImportReader
())
importer
.
execute
()
importer
.
execute
()
body
=
importer
.
get_summary
()
body
=
importer
.
get_summary
()
EmailSender
().
send_email
(
title
,
EmailSender
().
send_email
(
title
,
"
<h
1
>Data was successfully imported from file:
"
+
filename
+
"
</h
1
>
"
+
body
,
"
<h
3
>Data was successfully imported from file:
"
+
filename
+
"
</h
3
>
"
+
body
,
recipients
)
recipients
)
return
"
import is successful
"
return
"
import is successful
"
except
:
except
:
tb
=
traceback
.
format_exc
()
tb
=
traceback
.
format_exc
()
EmailSender
().
send_email
(
title
,
EmailSender
().
send_email
(
title
,
"
<h
1
>There was a problem with importing data from file:
"
+
filename
+
"
</
h1>
"
+
tb
,
"
<h
3><font color=
'
red
'
>There was a problem with importing data from file:
"
+
filename
+
"
</
font></h3><pre>
"
+
tb
+
"
</pre>
"
,
recipients
)
recipients
)
return
"
import crashed
"
return
"
import crashed
"
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