Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
4eb5af66
Commit
4eb5af66
authored
Oct 23, 2017
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Send a notification email when recount is done
parent
0f3751ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
9 deletions
+30
-9
mail_notification.py
gargantext/util/toolchain/mail_notification.py
+22
-6
main.py
gargantext/util/toolchain/main.py
+6
-1
project.html
templates/pages/projects/project.html
+2
-2
No files found.
gargantext/util/toolchain/mail_notification.py
View file @
4eb5af66
...
...
@@ -42,18 +42,33 @@ drafts = {
'''
,
'recountDone'
:
'''
Bonjour,
le recalcul que vous avez lancé est terminé.
}
Vous pouvez accéder à votre corpus intitulé
\"
%
s
\"
à l'adresse:
http://
%
s/projects/
%
d/corpora/
%
d
Nous restons à votre disposition pour tout complément d'information.
Cordialement
--
L'équipe de Gargantext (CNRS)
'''
}
def
notification
(
corpus
,
draft
):
def
notification
(
corpus
,
draft
,
subject
=
'Update'
):
user
=
session
.
query
(
User
)
.
filter
(
User
.
id
==
corpus
.
user_id
)
.
first
()
message
=
draft
%
(
corpus
.
name
,
BASE_URL
,
corpus
.
parent_id
,
corpus
.
id
)
if
user
.
email
!=
""
:
send_mail
(
'[Gargantext]
Update'
send_mail
(
'[Gargantext]
%
s'
%
subject
,
message
,
'contact@gargantext.org'
,
[
user
.
email
],
fail_silently
=
False
)
...
...
@@ -63,11 +78,12 @@ def notification(corpus,draft):
def
notify_owner
(
corpus
):
notification
(
corpus
,
drafts
[
'workflowEnd'
])
notification
(
corpus
,
drafts
[
'workflowEnd'
]
,
'Corpus updated'
)
def
notify_listMerged
(
corpus
):
notification
(
corpus
,
drafts
[
'listMerged'
])
notification
(
corpus
,
drafts
[
'listMerged'
],
'List merged'
)
def
notify_recount
(
corpus
):
notification
(
corpus
,
drafts
[
'recountDone'
],
'Recount done'
)
gargantext/util/toolchain/main.py
View file @
4eb5af66
...
...
@@ -13,7 +13,7 @@ from .ngram_coocs import compute_coocs
#from .ngram_coocs_old_sqlalchemy_version import compute_coocs
from
.metric_specgen
import
compute_specgen
from
.list_map
import
do_maplist
from
.mail_notification
import
notify_owner
from
.mail_notification
import
notify_owner
,
notify_recount
from
gargantext.util.db
import
session
from
gargantext.models
import
Node
...
...
@@ -299,5 +299,10 @@ def recount(corpus_id):
corpus
.
save_hyperdata
()
session
.
commit
()
if
not
DEBUG
:
print
(
'RECOUNT #
%
d: [
%
s] FINISHED Sending email notification'
%
(
corpus
.
id
,
t
()))
notify_recount
(
corpus
)
def
t
():
return
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d_
%
H:
%
M:
%
S"
)
templates/pages/projects/project.html
View file @
4eb5af66
...
...
@@ -1170,10 +1170,10 @@
// REST and callback
garganrest
.
metrics
.
update
(
corpusId
,
function
(){
statusDiv
.
innerHTML
=
'<div class="statusinfo">
Corpus updated
</div>'
statusDiv
.
innerHTML
=
'<div class="statusinfo">
Recount is started, please wait, you will be sent a notification email.
</div>'
// revert visual
setTimeout
(
function
(){
statusDiv
.
innerHTML
=
previousStatus
},
2000
);
//
setTimeout(function(){ statusDiv.innerHTML = previousStatus }, 2000);
})
}
...
...
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