forked from inveniosoftware/invenio
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebSearch: fix for collection names with slashes
* FIX Collection names containing slashes are now supported again. However we recommend not to use slashes in collection names; if slashes were wanted for aesthetic reasons, they can be added in visible collection translations. (closes inveniosoftware#2902) * Adds upgrade recipe to check collection names for slashes and warn the user about them. (Soft warning only, since names-with-slashes will work more or less fine as of this patch.) Signed-off-by: Tibor Simko <tibor.simko@cern.ch>
- Loading branch information
1 parent
ec9359c
commit 6be96d4
Showing
2 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
modules/miscutil/lib/upgrades/invenio_2015_04_15_collection_names_with_slashes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2015 CERN. | ||
# | ||
# Invenio is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License as | ||
# published by the Free Software Foundation; either version 2 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# Invenio is distributed in the hope that it will be useful, but | ||
# WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Invenio; if not, write to the Free Software Foundation, Inc., | ||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
|
||
"""Check collection table and warn user about collection names with slashes.""" | ||
|
||
from invenio.dbquery import run_sql | ||
|
||
depends_on = ['invenio_release_1_2_0'] | ||
|
||
|
||
def info(): | ||
"""Return upgrade recipe information.""" | ||
return "Warns user about collection names with slashes." | ||
|
||
|
||
def do_upgrade(): | ||
"""Carry out the upgrade.""" | ||
res = run_sql("SELECT name FROM collection WHERE name LIKE '%/%'") | ||
for row in res: | ||
print "WARNING: Collection '%s' contains forward slashes" \ | ||
" which is not recommended." % row[0] | ||
print "WARNING: You may safely continue, but we recommend" \ | ||
" changing this collection name to avoid slashes." | ||
|
||
|
||
def estimate(): | ||
"""Estimate running time of upgrade in seconds (optional).""" | ||
return 1 | ||
|
||
|
||
def pre_upgrade(): | ||
"""Pre-upgrade checks.""" | ||
pass # because slashes would still work | ||
|
||
|
||
def post_upgrade(): | ||
"""Post-upgrade checks.""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters