Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
2e9bbd5
WebLinkback: faster email notification
Aug 17, 2013
974f2ac
WebLinkback: faster deletion of linkbacks
Aug 18, 2013
e875dc1
Merge pull request #27 from egabancho/master-faster-weblinkback
egabancho Jul 24, 2015
8beff8c
SolrUtils: reliable regression test suite
Sep 23, 2013
a3ecf52
WebSearch: parsing unbalanced phrase queries
Feb 25, 2014
9a27458
Merge pull request #28 from egabancho/1590-fix-regresion-test-solrutils
egabancho Jul 24, 2015
d7532a6
WebSearch: new fulltext by default search
Aug 5, 2013
982ec3c
Merge pull request #29 from egabancho/master-search-units-phrase
egabancho Jul 24, 2015
6eb6a55
BibRank: Solr: better ranking for fulltext
Aug 26, 2013
7f4218c
SolrUtils: more accurate ranking scores
Aug 26, 2013
dafbee2
BibRecord: new MARC code filter
Jul 26, 2013
8e784eb
Merge pull request #30 from egabancho/master-fulltext-by-default
egabancho Jul 24, 2015
5288081
BibFormat: new 'xmf' format
Jul 29, 2013
48eee66
WebStyle: add CERN specific URL handlers
ludmilamarian Aug 12, 2014
d5db802
Merge pull request #31 from egabancho/master-xm-field
egabancho Jul 24, 2015
54509c1
BibEncode: Video: Push video to youtube
drjova Jan 7, 2014
0e47ac6
Merge pull request #59 from ludmilamarian/master-weblayout-cds
egabancho Jul 24, 2015
adf8882
Merge pull request #61 drjova/Youtube
switowski Sep 1, 2015
42996f0
MiscUtil: Added CERN LDAP plugin.
Nov 27, 2014
3bf4fb1
elasticsearch: Elasticsearch logging with Lumberjack.
Oct 17, 2014
2b51b86
Merge pull request #82 from switowski/ldap_cern
egabancho Jul 24, 2015
390571d
elasticsearch: fixed lumberjack git URL in requirements.txt
Feb 17, 2015
0e93d92
elasticsearch: removes calls to register_schema on load
Jan 19, 2015
e5ffdde
elasticsearch: adds user-agent to logged pageview and download data
Feb 16, 2015
b63d964
Merge pull request #87 from jmacmahon/elasticsearch_logging
egabancho Jul 24, 2015
998a1e1
general: Elasticsearch logging with Lumberjack.
Oct 17, 2014
c8fb254
WebStat: register custom events on es
drjova Dec 4, 2014
ba7aa6c
Merge pull request #88 from drjova/custom-events
switowski Sep 1, 2015
ab6d138
BibFormat: Read record_stats from ES (if enabled)
Dec 12, 2014
b4ad718
WebSearch: none external collection list fix
egabancho Dec 18, 2014
76f7457
Merge pull request #91 from switowski/es_pageviews
egabancho Jul 24, 2015
1fc9ee5
containerutils: new lazy data structures
egabancho Jan 12, 2015
0e40065
xmlDict: initial release backport
egabancho Feb 11, 2015
84f6103
Merge pull request #96 from egabancho/master-fix-non-external-collection
egabancho Jul 24, 2015
b70e845
pidstore: initial release backport
egabancho Feb 11, 2015
1bf55fc
BibFormat: DataCite3 export addition
egabancho Feb 11, 2015
050b2bb
BibIndex: TermCollector empty authority id fix
egabancho Feb 5, 2015
ad7b783
Merge pull request #97 from egabancho/master-backport-pidstore
egabancho Jul 24, 2015
7044af6
BibCirculation: new daemon task
Dec 15, 2014
36b76cc
Merge pull request #100 from egabancho/master-termcollector-fix
egabancho Jul 24, 2015
006a499
BibRank: no rank method fix
egabancho Feb 16, 2015
164b589
Merge pull request #102 from egabancho/prod-bibcirc-update-selfs
egabancho Jul 24, 2015
f835be6
BibDocFile: disallow percent in filenames
Feb 17, 2015
62997bb
Merge pull request #103 from egabancho/master-bibrank-no-method-found
egabancho Jul 24, 2015
b7d0ac7
Merge pull request #104 from switowski/1918-forbidden-characters-fix
egabancho Jul 24, 2015
714899c
BibConvert: retrieve arXiv license information
ludmilamarian Feb 17, 2015
494725a
Merge pull request #105 from ludmilamarian/master-bibconvert-arxiv-li…
egabancho Jul 24, 2015
3ea7566
BibEdit: fix recID type
ludmilamarian Feb 18, 2015
8d16fc3
Merge pull request #107 from ludmilamarian/master-bibedit-fix-recid
egabancho Jul 24, 2015
dfc1a84
errorlib: sentry logging enhancement
egabancho Feb 18, 2015
a905126
WebStyle: default logging level for `SERVER_RETURN`
egabancho Feb 18, 2015
72ceafa
WebStyle: logging level on some `IOError`
egabancho Feb 18, 2015
e3b752f
WebComment: remove unnecessary exceptions
drjova Feb 18, 2015
b8aaa23
Merge pull request #108 from egabancho/master-enhance-sentry-loggin
egabancho Jul 24, 2015
5f224b0
WebSubmit: fix for Stamp_Uploaded_Files
Feb 19, 2015
2dd55eb
Merge pull request #109 from drjova/remove-exceptions-from-comments
egabancho Jul 24, 2015
83b1252
BibFormat: fix for missing cache
Feb 23, 2015
56ae53d
Merge pull request #110 from switowski/stamp-error-fix
egabancho Jul 24, 2015
c9b7e09
BibDocFile: add download all files in BibRecDoc
Oct 25, 2013
81c5b6b
Merge pull request #111 from switowski/bibreformat-removes-no-missing…
egabancho Jul 24, 2015
5897dfa
BibField: bug fixes
egabancho Feb 26, 2015
efe5814
Merge pull request #112 from switowski/download_all_files
egabancho Jul 24, 2015
ea1d594
BibReformat: new --only-missing option
Mar 9, 2015
105feb8
Merge pull request #113 from egabancho/master-bibfield-bug-fixes
egabancho Jul 24, 2015
600ecf3
Merge pull request #114 from switowski/bibreformat-only-missing
egabancho Jul 24, 2015
feca70d
WebSubmit: autocompeltion for authors
Mar 10, 2014
6eea14c
Merge pull request #115 from kasioumis/legacy-websubmit-author-autoco…
switowski Sep 1, 2015
84c044c
WebComment: general comment format improvements
Jul 28, 2014
a906178
WebComment: bibdoc relations & filtering
Aug 15, 2014
2c5a016
WebComment: display comment submission deadline
Aug 13, 2014
f228069
WebComment: Enable a custom checkbox for comments
drjova Nov 21, 2014
6b39a7c
WebComment: fix collapse and review issues
drjova Mar 18, 2015
fbba3f6
WebComment: `collapse` and `expand` all comments
drjova Mar 17, 2015
6e83981
WebComment: cosmetic updates
drjova Mar 20, 2015
efc7f60
Merge pull request #117 from kasioumis/legacy-webcomment-improvements
switowski Sep 1, 2015
afb7a47
bibcirculation: Adds ILL and purchase confirmation
Mar 13, 2015
f871481
Websession: Improvements to inveniogc
Mar 26, 2015
c877efe
Merge pull request #118 from mvesper/l/op/wip/ill_confirmation_email
egabancho Jul 24, 2015
48d5bbb
bibcirculation: Change ILL/purchase e-mail
mvesper Mar 30, 2015
2f3f14c
Merge pull request #119 from switowski/inveniogc-improvements
egabancho Jul 24, 2015
9fc95eb
WebSearch & WebAlert: Your Searches improvements
kasioumis Jun 28, 2011
d60d9d6
Merge pull request #120 from mvesper/l/op/ill_email_address_change
egabancho Jul 24, 2015
fc9a174
WebSearch: yoursearches interface improvements
kasioumis Jul 25, 2011
be0a5b0
WebAlert: youralerts interface improvements
kasioumis Jul 26, 2011
0b260ca
WebSearch: fix yoursearches string format bug
kasioumis Aug 23, 2011
de937a7
WebSearch & WebAlert: CSS fallback to default
kasioumis Aug 30, 2011
d67df23
WebSearch: more CSS fallback to default
kasioumis Aug 30, 2011
d4acf59
WebAlert: paging for youralerts
kasioumis Aug 30, 2011
8d50bac
WebAlert: Searching for youralerts
kasioumis Sep 1, 2011
77354e0
WebSearch: Fix paging bug in yoursearches
kasioumis Sep 1, 2011
bff80cc
WebAlert & WebSearch: fix kwalitee reported issues
kasioumis Feb 2, 2012
d2d8259
WebStyle: add new images to the Makefile
kasioumis Jul 24, 2013
44999a9
WebAlert: option to pause and resume alerts
kasioumis Nov 8, 2013
f23a368
Webalert & Websearch: prettify display list header
kasioumis Mar 17, 2014
57f9314
Webalert: smart display of popular alerts link
kasioumis Mar 17, 2014
d7ab23a
Webalert: improve store results in basket menu
kasioumis Mar 20, 2014
70ca3f1
Webalert & Websearch: harmonize display
kasioumis Mar 20, 2014
7738dbb
Websession: Revamp the "Your Account" page
kasioumis Mar 24, 2014
fab4db4
General: fix kwalitee reported issues
kasioumis Mar 26, 2014
072d959
Miscutil: fix get_authenticated_mechanize_browser
kasioumis Mar 27, 2014
0c98c82
Websearch: remove mentions of total searches
kasioumis Mar 27, 2014
77f94ed
General: fix failing tests
kasioumis Mar 28, 2014
502fe02
Merge pull request #122 from kasioumis/legacy-personalization-fixes-a…
switowski Sep 1, 2015
e60fda7
BibFormat: correct MARC field usage in bfe_doi
egabancho Jun 2, 2015
e91de3f
WebStyle: wsgi handler IP parser enhancement
egabancho Jul 17, 2015
1d04a5f
Merge pull request #124 from egabancho/legacu-correct-doi-display
egabancho Jul 24, 2015
43abf0b
WebStyle: kwalitee fix
egabancho Jul 17, 2015
ecc7744
Merge pull request #126 egabancho/legacy-enhancement-wsgi-ip
switowski Sep 1, 2015
3f0b6e6
WebSearch: tabs miss language parameter
drjova Jun 23, 2015
e1fe846
WebSubmit: author autocomplition name order
egabancho Jul 24, 2015
1934c24
WebSubmit: subtitle file addition to converter
egabancho Jul 14, 2015
18f6a53
Merge pull request #128 drjova/tab-lan
egabancho Jul 24, 2015
35e268d
BibIndex: external file index enhancement
egabancho Jul 14, 2015
9d97516
BibRank: allow ranking external files using solr
egabancho Jul 15, 2015
3af3710
WebJournal: navigation menu category replacement
costaflavio Jul 17, 2015
45afb89
Merge pull request #130 egabancho/bibindex-better-external-files
egabancho Jul 24, 2015
1ee4b23
WebNews: New module to display and manage news
kasioumis Dec 21, 2012
0f0c036
Merge pull request #131 costaflavio/bfe_webjournal_main_navigation
egabancho Jul 24, 2015
b8da067
Merge pull request #8 from kasioumis/master-WebNews
switowski Sep 1, 2015
be2fef6
Fix requirements.txt typo
egabancho Jul 24, 2015
746cf8a
BibConvert: modify oaiharvest xsl template
switowski Jan 8, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ install-jquery-plugins:
wget -N --no-check-certificate http://invenio-software.org/download/jquery/parsley.js &&\
wget -N --no-check-certificate http://invenio-software.org/download/jquery/spin.min.js &&\
rm -f jquery.bookmark.package-1.4.0.zip && \
wget https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js && \
wget https://twitter.github.com/typeahead.js/releases/0.10.5/typeahead.bundle.min.js && \
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.min.js && \
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.map && \
mkdir -p ${prefix}/var/www/img && \
cd ${prefix}/var/www/img && \
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/ && \
Expand Down Expand Up @@ -236,6 +240,10 @@ uninstall-jquery-plugins:
rm -f jquery.dataTables.min.js && \
rm -f ui.core.js && \
rm -f jquery.bookmark.min.js && \
rm -f handlebars.min.js && \
rm -f typeahead.bundle.min.js && \
rm -f es5-shim.min.js && \
rm -f es5-shim.map && \
rm -f jquery.dataTables.ColVis.min.js && \
rm -f jquery.hotkeys.js && \
rm -f jquery.tablesorter.min.js && \
Expand Down Expand Up @@ -324,6 +332,60 @@ uninstall-pdfa-helper-files:
@echo "** The PDF/A helper files were successfully uninstalled. **"
@echo "***********************************************************"

install-youtube:
@echo "***********************************************************"
@echo "** Installing youtube client libraries **"
@echo "***********************************************************"
@echo "Please make sure that you have pip installed **"
@echo "-----------------------------------------------------------"
@echo "For more infos about the library please visit:"
@echo "https://developers.google.com/api-client-library/python/start/installation"
sudo pip install --upgrade google-api-python-client
rm -rf /tmp/invenio_js_frameworks
mkdir -p /tmp/invenio_js_frameworks
(cd /tmp/invenio_js_frameworks && \
wget https://github.com/dimsemenov/Magnific-Popup/archive/master.zip && \
unzip master.zip && \
mkdir -p ${prefix}/var/www/static/magnific_popup && \
cp -r Magnific-Popup-master/dist/* ${prefix}/var/www/static/magnific_popup && \
cd /tmp && \
rm -rf invenio_js_frameworks)
@echo "***********************************************************"
@echo "** Youtube client libraries was successfully installed **"
@echo "***********************************************************"

unistall-youtube:
@echo "***********************************************************"
@echo "** Unistalling Youtube client libraries **"
@echo "***********************************************************"
sudo pip uninstall google-api-python-client
rm -rf ${prefix}/var/www/static/magnific_popup
@echo "***********************************************************"
@echo "** Youtube client libraries was successfully unistalled **"

install-webcomment:
@echo "***********************************************************"
@echo "** Installing Webcomment plugin dependencies. **"
@echo "***********************************************************"
rm -rf /tmp/webcomment
mkdir /tmp/webcomment
wget 'https://github.com/cowboy/jquery-throttle-debounce/archive/master.zip' -O '/tmp/webcomment/webcomment.zip' --no-check-certificate
unzip -u -d '/tmp/webcomment' '/tmp/webcomment/webcomment.zip'
mv /tmp/webcomment/jquery-throttle-debounce-master/jquery.ba-throttle-debounce.min.js ${prefix}/var/www/js
wget 'https://raw.githubusercontent.com/bartaz/sandbox.js/master/jquery.highlight.js' -O '/tmp/webcomment/jquery.highlight.min.js' --no-check-certificate
mv /tmp/webcomment/jquery.highlight.min.js ${prefix}/var/www/js
rm -rf /tmp/webcomment
@echo "***********************************************************"
@echo "** Webcomment plugins were successfully installed. **"
@echo "***********************************************************"

uninstall-webcomment:
rm -f ${prefix}/var/www/js/jquery.ba-throttle-debounce.min.js
rm -f ${prefix}/var/www/js/jquery.highlight.min.js
@echo "***********************************************************"
@echo "** The Webcomment plugins were successfully uninstalled. **"
@echo "***********************************************************"

#Solrutils allows automatic installation, running and searching of an external Solr index.
install-solrutils:
@echo "***********************************************************"
Expand Down
55 changes: 55 additions & 0 deletions config/invenio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,8 @@ CFG_BIBINDEX_PERFORM_OCR_ON_DOCNAMES = scan-.*
# NOTE: for backward compatibility reasons you can set this to a simple
# regular expression that will directly be used as the unique key of the
# map, with corresponding value set to ".*" (in order to match any URL)
# NOTE2: If the value is None, the url mapping the key regex will be used
# directly
CFG_BIBINDEX_SPLASH_PAGES = {
"http://documents\.cern\.ch/setlink\?.*": ".*",
"http://ilcagenda\.linearcollider\.org/subContributionDisplay\.py\?.*|http://ilcagenda\.linearcollider\.org/contributionDisplay\.py\?.*": "http://ilcagenda\.linearcollider\.org/getFile\.py/access\?.*|http://ilcagenda\.linearcollider\.org/materialDisplay\.py\?.*",
Expand Down Expand Up @@ -1475,6 +1477,15 @@ CFG_WEBCOMMENT_MAX_ATTACHED_FILES = 5
# discussions.
CFG_WEBCOMMENT_MAX_COMMENT_THREAD_DEPTH = 1

# CFG_WEBCOMMENT_ENABLE_HTML_EMAILS -- if True, emails will also contain
# HTML content, in addition to the plaintext version.
CFG_WEBCOMMENT_ENABLE_HTML_EMAILS = True

# CFG_WEBCOMMENT_ENABLE_MARKDOWN_TEXT_RENDERING -- if True, and when
# CFG_WEBCOMMENT_USE_RICH_TEXT_EDITOR is False, plain text will be rendered
# as Markdown <http://daringfireball.net/projects/markdown/>.
CFG_WEBCOMMENT_ENABLE_MARKDOWN_TEXT_RENDERING = True

##################################
# Part 11: BibSched parameters ##
##################################
Expand Down Expand Up @@ -2565,6 +2576,50 @@ CFG_ARXIV_URL_PATTERN = http://export.arxiv.org/pdf/%sv%s.pdf
# e.g. CFG_REDIS_HOSTS = [{'db': 0, 'host': '127.0.0.1', 'port': 7001}]
CFG_REDIS_HOSTS = {'default': [{'db': 0, 'host': '127.0.0.1', 'port': 6379}]}

#################################
## Elasticsearch Configuration ##
#################################

## CFG_ELASTICSEARCH_LOGGING -- Whether to use Elasticsearch logging or not
CFG_ELASTICSEARCH_LOGGING = 0

## CFG_ELASTICSEARCH_INDEX_PREFIX -- The prefix to be used for the
## Elasticsearch indices.
CFG_ELASTICSEARCH_INDEX_PREFIX = invenio-

## CFG_ELASTICSEARCH_HOSTS -- The list of Elasticsearch hosts to connect to.
## This is a list of dictionaries with connection information.
CFG_ELASTICSEARCH_HOSTS = [{'host': '127.0.0.1', 'port': 9200}]

## CFG_ELASTICSEARCH_SUFFIX_FORMAT -- The time format string to base the
## suffixes for the Elasticsearch indices on. E.g. "%Y.%m" for indices to be
## called "invenio-2014.10" for example.
CFG_ELASTICSEARCH_SUFFIX_FORMAT = %Y.%m

## CFG_ELASTICSEARCH_MAX_QUEUE_LENGTH -- The maximum length the queue of events
## is allowed to grow to before it is flushed to Elasticsearch. If you don't
## want to set a maximum, and rely entirely on the periodic flush instead, set
## this to -1.
CFG_ELASTICSEARCH_MAX_QUEUE_LENGTH = -1

## CFG_ELASTICSEARCH_FLUSH_INTERVAL -- The time (in seconds) to wait between
## flushes of the event queue to Elasticsearch. If you want to disable
## periodic flushing and instead rely on the max. queue length to trigger
## flushes, set this to -1.
CFG_ELASTICSEARCH_FLUSH_INTERVAL = 30

## CFG_ELASTICSEARCH_BOT_AGENT_STRINGS -- A list of strings which, if found in
## the user agent string, will cause a 'bot' flag to be added to the logged
## event. This list taken from bots marked "active" at
## <http://www.searchenginedictionary.com/spider-names.shtml>. Googlebot and
## bingbot added to the head of the list for speed.
CFG_ELASTICSEARCH_BOT_AGENT_STRINGS = ['Googlebot', 'bingbot', 'Arachnoidea',
'FAST-WebCrawler', 'Fluffy the spider', 'Gigabot', 'Gulper', 'ia_archiver',
'MantraAgent', 'MSN', 'Scooter', 'Scrubby', 'Slurp', 'Teoma_agent1', 'Winona',
'ZyBorg', 'Almaden', 'Cyveillance', 'DTSearch', 'Girafa.com', 'Indy Library',
'LinkWalker', 'MarkWatch', 'NameProtect', 'Robozilla', 'Teradex Mapper',
'Tracerlock', 'W3C_Validator', 'WDG_Validator', 'Zealbot']

##########################
# THAT's ALL, FOLKS! ##
##########################
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ AC_CONFIG_FILES([config.nice \
modules/miscutil/etc/ckeditor_scientificchar/lang/Makefile \
modules/miscutil/lib/Makefile \
modules/miscutil/lib/upgrades/Makefile \
modules/miscutil/lib/pid_providers/Makefile \
modules/miscutil/sql/Makefile \
modules/miscutil/web/Makefile \
modules/webaccess/Makefile \
Expand Down Expand Up @@ -874,6 +875,10 @@ AC_CONFIG_FILES([config.nice \
modules/webmessage/doc/hacking/Makefile \
modules/webmessage/lib/Makefile \
modules/webmessage/web/Makefile \
modules/webnews/Makefile \
modules/webnews/doc/Makefile \
modules/webnews/lib/Makefile \
modules/webnews/web/Makefile \
modules/websearch/Makefile \
modules/websearch/bin/Makefile \
modules/websearch/bin/webcoll \
Expand Down Expand Up @@ -923,6 +928,7 @@ AC_CONFIG_FILES([config.nice \
modules/websubmit/etc/Makefile \
modules/websubmit/lib/Makefile \
modules/websubmit/lib/functions/Makefile \
modules/websubmit/lib/author_sources/Makefile \
modules/websubmit/web/Makefile \
modules/websubmit/web/admin/Makefile \
modules/docextract/Makefile \
Expand Down
1 change: 1 addition & 0 deletions modules/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ SUBDIRS = bibauthorid \
webjournal \
weblinkback \
webmessage \
webnews \
websearch \
websession \
webstat \
Expand Down
16 changes: 14 additions & 2 deletions modules/bibcirculation/lib/bibcirculation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
'We will process your order of the document immediately and will contact you as soon as it is delivered.\n\n'\
'Best regards,\nCERN Library team\n',


'PURCHASE_RECEIVED_TID': 'Dear colleague,\n\n'\
'The document you requested has been received. '\
'The price is %s'\
Expand Down Expand Up @@ -221,7 +222,6 @@
'Thank you in advance for your cooperation, CERN Library Staff',
'EMPTY': 'Please choose one template'
}

else:
CFG_BIBCIRCULATION_TEMPLATES = {
'OVERDUE': 'Overdue letter template (write some text)',
Expand Down Expand Up @@ -375,8 +375,20 @@
'EMPTY': 'Please choose one template'
}

ill_conf = ('Dear colleague,\n\n'
'We have received your interlibrary loan request\n'
'\tTitle: {0}\n\n'
'We will process your order of the document immediately and will '
'contact you as soon as it is delivered.\n\n'
'If you have any questions about your request, please contact '
'{1}\n\n'
'Best regards,\n'
'CERN Library team')

CFG_BIBCIRCULATION_TEMPLATES['ILL_CONFIRMATION'] = ill_conf

if CFG_CERN_SITE == 1:
CFG_BIBCIRCULATION_ILLS_EMAIL = 'CERN External loans<external.loans@cern.ch>'
CFG_BIBCIRCULATION_ILLS_EMAIL = 'CERN External loans<lib.acq@cern.ch>'
CFG_BIBCIRCULATION_LIBRARIAN_EMAIL = 'CERN Library Desk<library.desk@cern.ch>'
CFG_BIBCIRCULATION_LOANS_EMAIL = 'CERN Lib loans<lib.loans@cern.ch>'
else:
Expand Down
76 changes: 74 additions & 2 deletions modules/bibcirculation/lib/bibcirculation_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,30 @@

__revision__ = "$Id$"

import os
import sys
import time
import tempfile
from invenio.config import CFG_TMPDIR
from invenio.dbquery import run_sql
from invenio.bibtask import task_init, \
task_sleep_now_if_required, \
task_low_level_submission, \
task_update_progress, \
task_set_option, \
task_get_option, \
write_message
from invenio.mailutils import send_email
from invenio.search_engine_utils import get_fieldvalues
import invenio.bibcirculation_dblayer as db
from invenio.bibcirculation_config import CFG_BIBCIRCULATION_TEMPLATES, \
CFG_BIBCIRCULATION_LOANS_EMAIL, \
CFG_BIBCIRCULATION_ILLS_EMAIL, \
CFG_BIBCIRCULATION_REQUEST_STATUS_WAITING, \
CFG_BIBCIRCULATION_LOAN_STATUS_EXPIRED

from invenio.config import CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF, \
CFG_BIBCIRCULATION_ITEM_STATUS_ON_LOAN
from invenio.bibcirculation_utils import generate_email_body, \
book_title_from_MARC, \
update_user_info_from_ldap, \
Expand All @@ -59,6 +66,8 @@ def task_submit_elaborate_specific_parameter(key, value, opts, args):
task_set_option('update-borrowers', True)
elif key in ('-r', '--update-requests'):
task_set_option('update-requests', True)
elif key in ('-p', '--add-physical-copies-shelf-number-to-marc'):
task_set_option('add-physical-copies-shelf-number-to-marc', True)
else:
return False
return True
Expand Down Expand Up @@ -252,17 +261,80 @@ def task_run_core():
task_update_progress("ILL recall: processed %d out of %d expired ills." % (done+1, total_expired_ills))
write_message("Processed %d out of %d expired ills." % (done+1, total_expired_ills))

if task_get_option("add-physical-copies-shelf-number-to-marc"):
write_message("Started adding info. reg. physical copies and shelf number to records")
modified_rec_locs = db.get_modified_items_physical_locations()
#Tagging of records
if modified_rec_locs:
total_modified_rec_locs = len(modified_rec_locs)
MARC_RECS_STR = "<?xml version='1.0' encoding='UTF-8'?>\n<collection>"
recids_seen = []
for done, (recid, status, location, collection) in enumerate(modified_rec_locs):
if not int(recid) or not location or status not in [ CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF, \
CFG_BIBCIRCULATION_ITEM_STATUS_ON_LOAN ] or collection=='periodical' or\
recid in recids_seen or 'DELETED' in get_fieldvalues(recid, '980__c'):
#or location in get_fieldvalues(recid, '852__h'):
continue
#MARC_RECS_STR: Compose a string with the records containing the controlfield(recid) and
#the 2 datafields(shelf no, physical copies) for each item retrieved from the query
copies = db.get_item_copies_details(recid)
MARC_RECS_STR += '<record><controlfield tag="001">' + str(recid) + '</controlfield>'
type_copies = get_fieldvalues(recid, '340__a')
if 'paper' not in type_copies:
MARC_RECS_STR += '<datafield tag="340" ind1=" " ind2=" "> \
<subfield code="a">paper</subfield> \
</datafield>'
if 'ebook' in type_copies or 'e-book' in type_copies:
MARC_RECS_STR += '<datafield tag="340" ind1=" " ind2=" "> \
<subfield code="a">ebook</subfield> \
</datafield>'
lib_loc_tuples = []
for (_barcode, _loan_period, library_name, _library_id,
location, _nb_requests, _status, _collection,
_description, _due_date) in copies:
if not library_name or not location: continue
if not (library_name, location) in lib_loc_tuples:
lib_loc_tuples.append((library_name, location))
else: continue
MARC_RECS_STR += '<datafield tag="852" ind1=" " ind2=" "> \
<subfield code="c">' + library_name + '</subfield> \
<subfield code="h">' + location.replace('&', ' and ') +'</subfield> \
</datafield>'
MARC_RECS_STR += '</record>'
recids_seen.append(recid)
# Upload chunks of 100 records and sleep if needed
if (done+1)%100 == 0 or (done+1) == total_modified_rec_locs:
MARC_RECS_STR += "</collection>"
timestamp = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.localtime())
marcxmlfile = 'MARCxml_booksearch' + '_' + timestamp + '_'
fd, marcxmlfile = tempfile.mkstemp(dir=CFG_TMPDIR, prefix=marcxmlfile, suffix='.xml')
os.write(fd, MARC_RECS_STR)
os.close(fd)
write_message("Composed MARCXML saved into %s" % marcxmlfile)
#Schedule the bibupload task.
task_id = task_low_level_submission("bibupload", "BibCirc", "-c", marcxmlfile, '-P', '-3')
write_message("BibUpload scheduled with task id %s" % task_id)
write_message("Processed %d out of %d modified record locations." % (done+1, total_modified_rec_locs))
MARC_RECS_STR = "<?xml version='1.0' encoding='UTF-8'?>\n<collection>"
task_sleep_now_if_required(can_stop_too=True)

else:
write_message("No new records modified. Not scheduling any bibupload task")

return 1


def main():

task_init(authorization_action='runbibcircd',
authorization_msg="BibCirculation Task Submission",
help_specific_usage="""-o, --overdue-letters\tCheck overdue loans and send recall emails if necessary.\n
-b, --update-borrowers\tUpdate borrowers information from ldap.\n
-r, --update-requests\tUpdate pending requests of users\n\n""",
-r, --update-requests\tUpdate pending requests of users\n
-p, --add-physical-copies-shelf-number-to-marc\tAdd info. reg. physical copies and shelf number to records' marc\n\n""",
description="""Example: %s -u admin \n\n""" % (sys.argv[0]),
specific_params=("obr", ["overdue-letters", "update-borrowers", "update-requests"]),
specific_params=("obrp", ["overdue-letters", "update-borrowers", "update-requests",
"add-physical-copies-shelf-number-to-marc"]),
task_submit_elaborate_specific_parameter_fnc=task_submit_elaborate_specific_parameter,
version=__revision__,
task_run_fnc = task_run_core
Expand Down
Loading