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
c9254ca2
Commit
c9254ca2
authored
Oct 23, 2017
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/simon-unstable' into dev-merge
parents
372d44d1
4eb5af66
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
22 deletions
+39
-22
nodes.py
gargantext/models/nodes.py
+1
-1
dates.py
gargantext/util/dates.py
+3
-1
ISI.py
gargantext/util/parsers/ISI.py
+1
-1
_Parser.py
gargantext/util/parsers/_Parser.py
+2
-8
mail_notification.py
gargantext/util/toolchain/mail_notification.py
+24
-8
main.py
gargantext/util/toolchain/main.py
+6
-1
project.html
templates/pages/projects/project.html
+2
-2
No files found.
gargantext/models/nodes.py
View file @
c9254ca2
...
...
@@ -44,7 +44,7 @@ class Node(ValidatorMixin, Base):
>>> session.query(Node).filter_by(typename='USER').first() # doctest: +ELLIPSIS
<UserNode(...)>
But beware, there are some
caveat
s with bulk queries. In this case typename
But beware, there are some
pitfall
s with bulk queries. In this case typename
MUST be specified manually.
>>> session.query(UserNode).delete() # doctest: +SKIP
...
...
gargantext/util/dates.py
View file @
c9254ca2
...
...
@@ -2,6 +2,7 @@ import os
from
gargantext.settings
import
MEDIA_ROOT
from
datetime
import
MINYEAR
from
dateutil.parser
import
parse
as
parse_datetime_flexible
from
django.utils.dateparse
import
parse_datetime
from
django.utils.timezone
import
datetime
as
_datetime
,
utc
as
UTC
,
now
as
utcnow
...
...
@@ -19,7 +20,8 @@ class datetime(_datetime):
@
staticmethod
def
parse
(
s
):
dt
=
parse_datetime
(
s
)
dt
=
parse_datetime
(
s
)
or
\
parse_datetime_flexible
(
s
,
default
=
datetime
(
MINYEAR
,
1
,
1
))
return
dt
.
astimezone
(
UTC
)
if
dt
.
tzinfo
else
dt
.
replace
(
tzinfo
=
UTC
)
...
...
gargantext/util/parsers/ISI.py
View file @
c9254ca2
...
...
@@ -12,7 +12,7 @@ class ISIParser(RISParser):
"DI"
:
{
"type"
:
"hyperdata"
,
"key"
:
"doi"
},
"SO"
:
{
"type"
:
"hyperdata"
,
"key"
:
"source"
},
"PY"
:
{
"type"
:
"hyperdata"
,
"key"
:
"publication_year"
},
"PD"
:
{
"type"
:
"hyperdata"
,
"key"
:
"publication_
month
"
},
"PD"
:
{
"type"
:
"hyperdata"
,
"key"
:
"publication_
date_to_parse
"
},
"LA"
:
{
"type"
:
"hyperdata"
,
"key"
:
"language_fullname"
},
"AB"
:
{
"type"
:
"hyperdata"
,
"key"
:
"abstract"
,
"separator"
:
" "
},
"WC"
:
{
"type"
:
"hyperdata"
,
"key"
:
"fields"
},
...
...
gargantext/util/parsers/_Parser.py
View file @
c9254ca2
...
...
@@ -3,10 +3,7 @@ import zipfile
import
re
import
dateparser
as
date_parser
from
gargantext.util.languages
import
languages
from
gargantext.util
import
datetime
,
convert_to_datetime
,
MINYEAR
DEFAULT_DATE
=
datetime
(
MINYEAR
,
1
,
1
)
from
gargantext.util
import
datetime
,
convert_to_datetime
class
Parser
:
...
...
@@ -46,10 +43,7 @@ class Parser:
if
date_string
is
not
None
:
date_string
=
re
.
sub
(
r'\/\/+(\w*|\d*)'
,
''
,
date_string
)
try
:
hyperdata
[
'publication_date'
]
=
dateutil
.
parser
.
parse
(
date_string
,
default
=
DEFAULT_DATE
)
hyperdata
[
'publication_date'
]
=
datetime
.
parse
(
date_string
)
except
Exception
as
error
:
print
(
error
,
'Date not parsed for:'
,
date_string
)
hyperdata
[
'publication_date'
]
=
datetime
.
now
()
...
...
gargantext/util/toolchain/mail_notification.py
View file @
c9254ca2
...
...
@@ -6,7 +6,7 @@ from gargantext.settings import BASE_URL
drafts
=
{
drafts
=
{
'workflowEnd'
:
'''
Bonjour,
votre analyse sur Gargantext vient de se terminer.
...
...
@@ -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 @
c9254ca2
...
...
@@ -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 @
c9254ca2
...
...
@@ -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