From b8d45b664a09b1d61e19eefd94bd3a1a1f7cfedb Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Sun, 12 Nov 2017 18:48:44 +0100 Subject: [PATCH] Typeahead working again Fix for replacing characters in filenames --- cps/helper.py | 2 +- cps/static/js/edit_books.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index d7cb3a90..52e96b6c 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -280,7 +280,7 @@ def get_valid_filename(value, replace_whitespace=True): value = unicode(re_slugify.sub('', value).strip()) if replace_whitespace: #*+:\"/<>? are replaced by _ - value = re.sub('[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U) + value = re.sub(r'[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U) value = value[:128] if not value: diff --git a/cps/static/js/edit_books.js b/cps/static/js/edit_books.js index 3932e3b6..96fcc848 100644 --- a/cps/static/js/edit_books.js +++ b/cps/static/js/edit_books.js @@ -46,8 +46,7 @@ function prefixedSource(prefix, query, cb, bhAdapter) { function getPath() { var jsFileLocation = $("script[src*=edit_books]").attr("src"); // the js file path - jsFileLocation = jsFileLocation.replace("/static/js/edit_books.js", ""); // the js folder path - return jsFileLocation; + return jsFileLocation.substr(0,jsFileLocation.search("/static/js/edit_books.js")); // the js folder path } var authors = new Bloodhound({