Skip to content

Commit 23459b2

Browse files
committed
Merge pull request #62 from kasioumis/master-websubmit-author-autocompletion
WebSubmit: Autocompletion for authors
2 parents e781095 + ed35bf0 commit 23459b2

24 files changed

+1313
-43
lines changed

Makefile.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ install-jquery-plugins:
206206
wget --no-check-certificate http://invenio-software.org/download/jquery/parsley.js &&\
207207
wget --no-check-certificate http://invenio-software.org/download/jquery/spin.min.js &&\
208208
rm -f jquery.bookmark.package-1.4.0.zip && \
209+
wget https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js && \
210+
wget https://twitter.github.com/typeahead.js/releases/0.10.5/typeahead.bundle.min.js && \
211+
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.min.js && \
212+
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.map && \
209213
mkdir -p ${prefix}/var/www/img && \
210214
cd ${prefix}/var/www/img && \
211215
wget -r -np -nH --cut-dirs=4 -A "png,css" -P jquery-ui/themes http://jquery-ui.googlecode.com/svn/tags/1.8.17/themes/base/ && \
@@ -237,6 +241,10 @@ uninstall-jquery-plugins:
237241
rm -f jquery.dataTables.min.js && \
238242
rm -f ui.core.js && \
239243
rm -f jquery.bookmark.min.js && \
244+
rm -f handlebars.min.js && \
245+
rm -f typeahead.bundle.min.js && \
246+
rm -f es5-shim.min.js && \
247+
rm -f es5-shim.map && \
240248
rm -f jquery.dataTables.ColVis.min.js && \
241249
rm -f jquery.hotkeys.js && \
242250
rm -f jquery.tablesorter.min.js && \

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ AC_CONFIG_FILES([config.nice \
927927
modules/websubmit/etc/Makefile \
928928
modules/websubmit/lib/Makefile \
929929
modules/websubmit/lib/functions/Makefile \
930+
modules/websubmit/lib/author_sources/Makefile \
930931
modules/websubmit/web/Makefile \
931932
modules/websubmit/web/admin/Makefile \
932933
modules/docextract/Makefile \

modules/bibfield/lib/bibfield_utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,21 @@ def _validate(self, document, schema=None, update=False):
443443
self._validate_required_fields()
444444

445445
return len(self._errors) == 0
446+
447+
def retrieve_authorid_type(id_string):
448+
"""Retrieve the type part of the author id_string (e.g. inspireid)."""
449+
450+
if not id_string or type(id_string) is not str:
451+
return ""
452+
if id_string.find("|(") != -1 and id_string.split("|(")[1].find(")") != -1:
453+
return id_string.split("|(")[1].split(")")[0]
454+
return "id"
455+
456+
def retrieve_authorid_id(id_string):
457+
"""Retrieve the id part of the author id_string."""
458+
459+
if not id_string or type(id_string) is not str:
460+
return ""
461+
if id_string.find("|(") != -1 and id_string.split("|(")[1].find(")") != -1:
462+
return id_string.split(")")[1]
463+
return ""

modules/miscutil/demo/democfgdata.sql

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ INSERT INTO sbmFIELD VALUES ('SRVDEMOPIC',1,2,'DEMOPIC_CONT','<br /><br /></td><
11821182
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,1,'DEMOTHE_REP','<TABLE WIDTH=\"100%\" BGCOLOR=\"#D3E3E2\" ALIGN=\"center\" CELLSPACING=\"2\" CELLPADDING=\"2\" BORDER=\"1\"><TR><TD ALIGN=\"left\"><br /><b>Submit an ATLANTIS Thesis:</b><br /><br />Your thesis will be given a reference number automatically.<br /> However, if it has other reference numbers, please enter them here:<br /><i>(one per line)</i><br />','O','Other Report Numbers','','2008-03-02','2008-03-06',NULL,NULL);
11831183
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,2,'DEMOTHE_TITLE','<br /><br /><span style=\"color: red;\">*</span>Thesis Title:<br />','M','Title','','2008-03-02','2008-03-06',NULL,NULL);
11841184
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,3,'DEMOTHE_SUBTTL','<br /><br />Thesis Subtitle <i>(if any)</i>:<br />','O','Subtitle','','2008-03-02','2008-03-06',NULL,NULL);
1185-
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,4,'DEMOTHE_AU','<br /><br /><table width=\"100%\"><tr><td valign=\"top\"><span style=\"color: red;\">*</span>Author of the Thesis: <i>(one per line)</i><br />','M','Author(s)','','2008-03-02','2008-03-06',NULL,NULL);
1185+
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,4,'DEMOTHE_AU','<br /><br /><table width=\"100%\"><tr><td valign=\"top\"><span style=\"color: red;\">*</span>Author of the Thesis:<br />','M','Author(s)','','2008-03-02','2008-03-06',NULL,NULL);
11861186
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,5,'DEMOTHE_SUPERV','</td></tr><tr><td valign=\"top\"><br>Thesis Supervisor(s): <i>(one per line)</i><br />','O','Thesis Supervisor(s)','','2008-03-02','2008-03-06',NULL,NULL);
11871187
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,6,'DEMOTHE_ABS','</td></tr></table><br /><span style=\"color: red;\">*</span>Abstract:<br />','M','Abstract','','2008-03-02','2008-03-06',NULL,NULL);
11881188
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,7,'DEMOTHE_NUMP','<br /><br />Number of Pages: ','O','Number of Pages','','2008-03-02','2008-03-06',NULL,NULL);
@@ -1273,7 +1273,7 @@ INSERT INTO sbmFIELDDESC VALUES ('DEMOPIC_CONT',NULL,'','D',NULL,NULL,NULL,NULL,
12731273
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_REP',NULL,'088__a','T',NULL,4,30,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Other Report Numbers (one per line):',NULL,0);
12741274
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_TITLE',NULL,'245__a','T',NULL,5,60,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Title:<br />',NULL,0);
12751275
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_SUBTTL',NULL,'245__b','T',NULL,3,60,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br /><br />Thesis Subtitle (if any):<br />',NULL,0);
1276-
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_AU',NULL,'100__a','T',NULL,6,60,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Authors:<br />(one per line):<br />',NULL,0);
1276+
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_AU',NULL,'100__a','R',NULL,6,60,NULL,NULL,'from invenio.websubmit_engine import get_authors_autocompletion\r\n\r\nrecid = action == "MBI" and sysno or None\r\nauthor_sources = ["bibauthority"]\r\nextra_options = {\r\n "allow_custom_authors": True,\r\n "highlight_principal_author": True,\r\n}\r\nextra_fields = {\r\n "contribution": False,\r\n}\r\n\r\ntext = get_authors_autocompletion(\r\n element,\r\n recid,\r\n curdir,\r\n author_sources,\r\n extra_options,\r\n extra_fields\r\n)','2008-03-02','2014-06-30','<br />Authors:<br />(one per line):<br />',NULL,0);
12771277
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_SUPERV',NULL,'','T',NULL,6,60,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Thesis Supervisor(s)<br />(one per line):<br />',NULL,0);
12781278
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_ABS',NULL,'520__a','T',NULL,12,80,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Abstract:<br />',NULL,0);
12791279
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_NUMP',NULL,'300__a','I',5,NULL,NULL,NULL,NULL,NULL,'2008-03-02','2008-03-06','<br />Number of Pages:&nbsp;',NULL,0);
@@ -1385,11 +1385,12 @@ INSERT INTO sbmFUNCTIONS VALUES ('SRV','DEMOPIC','Mail_Submitter',40,2);
13851385
INSERT INTO sbmFUNCTIONS VALUES ('SRV','DEMOPIC','Move_Uploaded_Files_to_Storage',30,2);
13861386
INSERT INTO sbmFUNCTIONS VALUES ('SRV','DEMOPIC','Is_Original_Submitter',20,2);
13871387
INSERT INTO sbmFUNCTIONS VALUES ('SRV','DEMOPIC','Get_Recid',10,2);
1388-
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Move_to_Done',90,1);
1389-
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Mail_Submitter',80,1);
1390-
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Make_Record',50,1);
1391-
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Insert_Record',60,1);
1392-
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Print_Success',70,1);
1388+
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Move_to_Done',100,1);
1389+
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Mail_Submitter',90,1);
1390+
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Print_Success',80,1);
1391+
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Insert_Record',70,1);
1392+
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Make_Record',60,1);
1393+
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','process_authors_json',50,1);
13931394
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Move_Files_to_Storage',40,1);
13941395
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Stamp_Uploaded_Files',30,1);
13951396
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Report_Number_Generation',20,1);
@@ -1398,11 +1399,12 @@ INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Get_Report_Number',10,1);
13981399
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Get_Recid',20,1);
13991400
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Is_Original_Submitter',30,1);
14001401
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Create_Modify_Interface',40,1);
1401-
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Move_to_Done',80,2);
1402-
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Send_Modify_Mail',70,2);
1403-
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Print_Success_MBI',60,2);
1404-
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Insert_Modify_Record',50,2);
1405-
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Make_Modify_Record',40,2);
1402+
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Move_to_Done',90,2);
1403+
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Send_Modify_Mail',80,2);
1404+
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Print_Success_MBI',70,2);
1405+
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Insert_Modify_Record',60,2);
1406+
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Make_Modify_Record',50,2);
1407+
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','process_authors_json',40,2);
14061408
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Is_Original_Submitter',30,2);
14071409
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Get_Recid',20,2);
14081410
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Get_Report_Number',10,2);
@@ -1592,6 +1594,7 @@ INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','fieldnameMBI','DEMOTHE_CHANGE');
15921594
INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','modifyTemplate','DEMOTHEmodify.tpl');
15931595
INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','addressesMBI','');
15941596
INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','sourceDoc','Thesis');
1597+
INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','authors_json','DEMOTHE_AU');
15951598
INSERT INTO sbmPARAMETERS VALUES ('DEMOART','addressesMBI','');
15961599
INSERT INTO sbmPARAMETERS VALUES ('DEMOART','authorfile','DEMOART_AU');
15971600
INSERT INTO sbmPARAMETERS VALUES ('DEMOART','autorngen','Y');
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of Invenio.
4+
# Copyright (C) 2014 CERN.
5+
#
6+
# Invenio is free software; you can redistribute it and/or
7+
# modify it under the terms of the GNU General Public License as
8+
# published by the Free Software Foundation; either version 2 of the
9+
# License, or (at your option) any later version.
10+
#
11+
# Invenio is distributed in the hope that it will be useful, but
12+
# WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
# General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with Invenio; if not, write to the Free Software Foundation,
18+
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19+
20+
"""Upgrade recipe for new column tag.recjson_value."""
21+
22+
import os
23+
24+
from invenio.dbquery import run_sql
25+
from invenio.config import CFG_PREFIX
26+
27+
depends_on = ['invenio_release_1_1_0']
28+
29+
30+
def info():
31+
"""Upgrade recipe information."""
32+
return "Set up autocompletion for DEMOTHE authors"
33+
34+
35+
def do_upgrade():
36+
"""Upgrade recipe procedure."""
37+
os.system("cd %(prefix)s/var/www/js && \
38+
wget https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js && \
39+
wget https://twitter.github.com/typeahead.js/releases/0.10.5/typeahead.bundle.min.js && \
40+
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.min.js && \
41+
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.map"
42+
% {'prefix': CFG_PREFIX})
43+
44+
# Remove "one line per author" info on author textbox
45+
run_sql("""UPDATE sbmFIELD
46+
set fitext='<br /><br /><table width="100%"><tr><td valign="top"><span style="color: red;">*</span>Author of the Thesis:<br />'
47+
where fidesc="DEMOTHE_AU";""")
48+
49+
# Add the response logic to the DEMOTHE_AU element
50+
run_sql("""REPLACE sbmFIELDDESC VALUES ('DEMOTHE_AU',NULL,'100__a','R',NULL,6,60,NULL,NULL,'from invenio.websubmit_engine import get_authors_autocompletion\r\n\r\nrecid = action == "MBI" and sysno or None\r\nauthor_sources = ["bibauthority"]\r\nextra_options = {\r\n "allow_custom_authors": True,\r\n "highlight_principal_author": True,\r\n}\r\nextra_fields = {\r\n "contribution": False,\r\n}\r\n\r\ntext = get_authors_autocompletion(\r\n element,\r\n recid,\r\n curdir,\r\n author_sources,\r\n extra_options,\r\n extra_fields\r\n)','2008-03-02','2014-06-30','',NULL,0);""")
51+
52+
# Create the process_author_json_function
53+
run_sql("INSERT INTO sbmFUNDESC VALUES ('process_authors_json','authors_json');")
54+
55+
# Add it to the DEMOTHE workflow
56+
run_sql("INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','authors_json','DEMOTHE_AU');")
57+
58+
# Add proccess_author_json into the submission function sequence for DEMOTHESIS
59+
run_sql("INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','process_authors_json',50,1);")
60+
run_sql("UPDATE sbmFUNCTIONS set score=100 where action='SBI' and doctype='DEMOTHE' and function='Move_to_Done';")
61+
run_sql("UPDATE sbmFUNCTIONS set score=90 where action='SBI' and doctype='DEMOTHE' and function='Mail_Submitter';")
62+
run_sql("UPDATE sbmFUNCTIONS set score=80 where action='SBI' and doctype='DEMOTHE' and function='Print_Success';")
63+
run_sql("UPDATE sbmFUNCTIONS set score=70 where action='SBI' and doctype='DEMOTHE' and function='Insert_Record';")
64+
run_sql("UPDATE sbmFUNCTIONS set score=60 where action='SBI' and doctype='DEMOTHE' and function='Make_Record';")
65+
66+
# Add proccess_author_json into the modification function sequence for DEMOTHESIS
67+
run_sql("INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','process_authors_json',40,2);")
68+
run_sql("UPDATE sbmFUNCTIONS set score=90 where action='MBI' and doctype='DEMOTHE' and function='Move_to_Done';")
69+
run_sql("UPDATE sbmFUNCTIONS set score=80 where action='MBI' and doctype='DEMOTHE' and function='Send_Modify_Mail';")
70+
run_sql("UPDATE sbmFUNCTIONS set score=70 where action='MBI' and doctype='DEMOTHE' and function='Print_Success_MBI';")
71+
run_sql("UPDATE sbmFUNCTIONS set score=60 where action='MBI' and doctype='DEMOTHE' and function='Insert_Modify_Record';")
72+
run_sql("UPDATE sbmFUNCTIONS set score=50 where action='MBI' and doctype='DEMOTHE' and function='Make_Modify_Record';")
73+
74+
75+
def estimate():
76+
"""Upgrade recipe time estimate."""
77+
return 1

modules/miscutil/sql/tabfill.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ INSERT INTO sbmFUNDESC VALUES ('Run_PlotExtractor','with_docname');
857857
INSERT INTO sbmFUNDESC VALUES ('Run_PlotExtractor','with_doctype');
858858
INSERT INTO sbmFUNDESC VALUES ('Run_PlotExtractor','with_docformat');
859859
INSERT INTO sbmFUNDESC VALUES ('Run_PlotExtractor','extract_plots_switch_file');
860+
INSERT INTO sbmFUNDESC VALUES ('process_authors_json','authors_json');
860861

861862
INSERT INTO sbmGFILERESULT VALUES ('HTML','HTML document');
862863
INSERT INTO sbmGFILERESULT VALUES ('WORD','data');

modules/webstyle/css/Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
webdir = $(localstatedir)/www/img
1919

20-
web_DATA = invenio.css invenio-ie7.css tablesorter.css jquery.ajaxPager.css
20+
web_DATA = invenio.css \
21+
invenio-ie7.css \
22+
tablesorter.css \
23+
jquery.ajaxPager.css \
24+
author_autocompletion.css
2125

2226
EXTRA_DIST = $(web_DATA)
2327

0 commit comments

Comments
 (0)