Code cosmetics bugfix error message on failed emails refactored language name generation
This commit is contained in:
parent
34abf95fb2
commit
d414bf3263
|
@ -419,6 +419,8 @@ var lastLength = 0;
|
||||||
function Unpack20(bstream) { //, Solid) {
|
function Unpack20(bstream) { //, Solid) {
|
||||||
var destUnpSize = rBuffer.data.length;
|
var destUnpSize = rBuffer.data.length;
|
||||||
var oldDistPtr = 0;
|
var oldDistPtr = 0;
|
||||||
|
var Length;
|
||||||
|
var Distance;
|
||||||
rarReadTables20(bstream);
|
rarReadTables20(bstream);
|
||||||
while (destUnpSize > rBuffer.ptr) {
|
while (destUnpSize > rBuffer.ptr) {
|
||||||
var num = rarDecodeNumber(bstream, LD);
|
var num = rarDecodeNumber(bstream, LD);
|
||||||
|
@ -428,12 +430,12 @@ function Unpack20(bstream) { //, Solid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (num > 269) {
|
if (num > 269) {
|
||||||
var Length = rLDecode[num -= 270] + 3;
|
Length = rLDecode[num -= 270] + 3;
|
||||||
if ((Bits = rLBits[num]) > 0) {
|
if ((Bits = rLBits[num]) > 0) {
|
||||||
Length += bstream.readBits(Bits);
|
Length += bstream.readBits(Bits);
|
||||||
}
|
}
|
||||||
var DistNumber = rarDecodeNumber(bstream, DD);
|
var DistNumber = rarDecodeNumber(bstream, DD);
|
||||||
var Distance = rDDecode[DistNumber] + 1;
|
Distance = rDDecode[DistNumber] + 1;
|
||||||
if ((Bits = rDBits[DistNumber]) > 0) {
|
if ((Bits = rDBits[DistNumber]) > 0) {
|
||||||
Distance += bstream.readBits(Bits);
|
Distance += bstream.readBits(Bits);
|
||||||
}
|
}
|
||||||
|
@ -459,16 +461,16 @@ function Unpack20(bstream) { //, Solid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (num < 261) {
|
if (num < 261) {
|
||||||
var Distance = rOldDist[(oldDistPtr - (num - 256)) & 3];
|
Distance = rOldDist[(oldDistPtr - (num - 256)) & 3];
|
||||||
var LengthNumber = rarDecodeNumber(bstream, RD);
|
var LengthNumber = rarDecodeNumber(bstream, RD);
|
||||||
var Length = rLDecode[LengthNumber] +2;
|
Length = rLDecode[LengthNumber] + 2;
|
||||||
if ((Bits = rLBits[LengthNumber]) > 0) {
|
if ((Bits = rLBits[LengthNumber]) > 0) {
|
||||||
Length += bstream.readBits(Bits);
|
Length += bstream.readBits(Bits);
|
||||||
}
|
}
|
||||||
if (Distance >= 0x101) {
|
if (Distance >= 0x101) {
|
||||||
Length++;
|
Length++;
|
||||||
if (Distance >= 0x2000) {
|
if (Distance >= 0x2000) {
|
||||||
Length++
|
Length++;
|
||||||
if (Distance >= 0x40000) Length++;
|
if (Distance >= 0x40000) Length++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,7 +490,7 @@ function Unpack20(bstream) { //, Solid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rarUpdateProgress()
|
rarUpdateProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
function rarUpdateProgress() {
|
function rarUpdateProgress() {
|
||||||
|
@ -511,12 +513,15 @@ function rarReadTables20(bstream) {
|
||||||
var BitLength = new Array(rBC20);
|
var BitLength = new Array(rBC20);
|
||||||
var Table = new Array(rMC20 * 4);
|
var Table = new Array(rMC20 * 4);
|
||||||
var TableSize, N, I;
|
var TableSize, N, I;
|
||||||
var AudioBlock = bstream.readBits(1);
|
bstream.readBits(1);
|
||||||
if (!bstream.readBits(1))
|
if (!bstream.readBits(1)) {
|
||||||
for (var i = UnpOldTable20.length; i--;) UnpOldTable20[i] = 0;
|
var i;
|
||||||
|
for (i = UnpOldTable20.length; i--;) UnpOldTable20[i] = 0;
|
||||||
|
}
|
||||||
TableSize = rNC20 + rDC20 + rRC20;
|
TableSize = rNC20 + rDC20 + rRC20;
|
||||||
for (var I = 0; I < rBC20; I++)
|
for (I = 0; I < rBC20; I++) {
|
||||||
BitLength[I] = bstream.readBits(4);
|
BitLength[I] = bstream.readBits(4);
|
||||||
|
}
|
||||||
rarMakeDecodeTables(BitLength, 0, BD, rBC20);
|
rarMakeDecodeTables(BitLength, 0, BD, rBC20);
|
||||||
I = 0;
|
I = 0;
|
||||||
while (I < TableSize) {
|
while (I < TableSize) {
|
||||||
|
@ -544,7 +549,7 @@ function rarReadTables20(bstream) {
|
||||||
rarMakeDecodeTables(Table, 0, LD, rNC20);
|
rarMakeDecodeTables(Table, 0, LD, rNC20);
|
||||||
rarMakeDecodeTables(Table, rNC20, DD, rDC20);
|
rarMakeDecodeTables(Table, rNC20, DD, rDC20);
|
||||||
rarMakeDecodeTables(Table, rNC20 + rDC20, RD, rRC20);
|
rarMakeDecodeTables(Table, rNC20 + rDC20, RD, rRC20);
|
||||||
for (var i = UnpOldTable20.length; i--;) UnpOldTable20[i] = Table[i];
|
for (i = UnpOldTable20.length; i--;) UnpOldTable20[i] = Table[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -555,8 +560,8 @@ function Unpack29(bstream, Solid) {
|
||||||
var DBits = new Array(rDC);
|
var DBits = new Array(rDC);
|
||||||
|
|
||||||
var Dist = 0, BitLength = 0, Slot = 0;
|
var Dist = 0, BitLength = 0, Slot = 0;
|
||||||
|
var I;
|
||||||
for (var I = 0; I < rDBitLengthCounts.length; I++,BitLength++) {
|
for (I = 0; I < rDBitLengthCounts.length; I++,BitLength++) {
|
||||||
for (var J = 0; J < rDBitLengthCounts[I]; J++,Slot++,Dist+=(1<<BitLength)) {
|
for (var J = 0; J < rDBitLengthCounts[I]; J++,Slot++,Dist+=(1<<BitLength)) {
|
||||||
DDecode[Slot]=Dist;
|
DDecode[Slot]=Dist;
|
||||||
DBits[Slot]=BitLength;
|
DBits[Slot]=BitLength;
|
||||||
|
@ -570,8 +575,8 @@ function Unpack29(bstream, Solid) {
|
||||||
|
|
||||||
lastDist = 0;
|
lastDist = 0;
|
||||||
lastLength = 0;
|
lastLength = 0;
|
||||||
|
var i;
|
||||||
for (var i = UnpOldTable.length; i--;) UnpOldTable[i] = 0;
|
for (i = UnpOldTable.length; i--;) UnpOldTable[i] = 0;
|
||||||
|
|
||||||
// read in Huffman tables
|
// read in Huffman tables
|
||||||
RarReadTables(bstream);
|
RarReadTables(bstream);
|
||||||
|
@ -883,8 +888,7 @@ var unrar = function(arrayBuffer) {
|
||||||
|
|
||||||
postProgress();
|
postProgress();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
err("Invalid RAR file");
|
err("Invalid RAR file");
|
||||||
}
|
}
|
||||||
postMessage(new bitjs.archive.UnarchiveFinishEvent());
|
postMessage(new bitjs.archive.UnarchiveFinishEvent());
|
||||||
|
|
|
@ -9,9 +9,32 @@
|
||||||
<h2>{{entries|length}} {{_('Results for:')}} {{searchterm}}</h2>
|
<h2>{{entries|length}} {{_('Results for:')}} {{searchterm}}</h2>
|
||||||
{%endif%}
|
{%endif%}
|
||||||
{% if g.user.is_authenticated %}
|
{% if g.user.is_authenticated %}
|
||||||
<!--a href="{{ url_for('read_books') }}" class="btn btn-primary">{{ _('Search result to shelf') }} </a-->
|
{% if g.user.shelf.all() or g.public_shelfes %}
|
||||||
{% endif %}
|
<div id="shelf-actions" class="btn-toolbar" role="toolbar">
|
||||||
|
<div class="btn-group" role="group" aria-label="Add to shelves">
|
||||||
|
<button id="add-to-shelf" type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<span class="glyphicon glyphicon-list"></span> {{_('Add to shelf')}}
|
||||||
|
<span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul id="add-to-shelves" class="dropdown-menu" aria-labelledby="add-to-shelf">
|
||||||
|
{% for shelf in g.user.shelf %}
|
||||||
|
{% if shelf.is_public != 1 %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ url_for('search_to_shelf', shelf_id=shelf.id) }}"> {{shelf.name}}</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for shelf in g.public_shelfes %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ url_for('search_to_shelf', shelf_id=shelf.id) }}">{{shelf.name}}</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
{% if g.user.is_authenticated %}
|
{% if g.user.is_authenticated %}
|
||||||
{% if (g.user.role_edit_shelfs() and shelf.is_public ) or not shelf.is_public %}
|
{% if (g.user.role_edit_shelfs() and shelf.is_public ) or not shelf.is_public %}
|
||||||
<div data-toggle="modal" data-target="#DeleteShelfDialog" class="btn btn-danger">{{ _('Delete this Shelf') }} </div>
|
<div data-toggle="modal" data-target="#DeleteShelfDialog" class="btn btn-danger">{{ _('Delete this Shelf') }} </div>
|
||||||
<a href="{{ url_for('edit_shelf', shelf_id=shelf.id) }}" class="btn btn-primary">{{ _('Edit Shelf name') }} </a>
|
<a href="{{ url_for('edit_shelf', shelf_id=shelf.id) }}" class="btn btn-primary">{{ _('Edit Shelf') }} </a>
|
||||||
<a href="{{ url_for('order_shelf', shelf_id=shelf.id) }}" class="btn btn-primary">{{ _('Change order') }} </a>
|
<a href="{{ url_for('order_shelf', shelf_id=shelf.id) }}" class="btn btn-primary">{{ _('Change order') }} </a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1515,8 +1515,8 @@ msgid "Delete this Shelf"
|
||||||
msgstr "Lösche dieses Bücherregal"
|
msgstr "Lösche dieses Bücherregal"
|
||||||
|
|
||||||
#: cps/templates/shelf.html:8
|
#: cps/templates/shelf.html:8
|
||||||
msgid "Edit Shelf name"
|
msgid "Edit Shelf"
|
||||||
msgstr "Bücherregal umbenennen"
|
msgstr "Bücherregal editieren"
|
||||||
|
|
||||||
#: cps/templates/shelf.html:9 cps/templates/shelf_order.html:11
|
#: cps/templates/shelf.html:9 cps/templates/shelf_order.html:11
|
||||||
msgid "Change order"
|
msgid "Change order"
|
||||||
|
|
|
@ -46,9 +46,8 @@ DEFAULT_PASS = "admin123"
|
||||||
DEFAULT_PORT = int(os.environ.get("CALIBRE_PORT", 8083))
|
DEFAULT_PORT = int(os.environ.get("CALIBRE_PORT", 8083))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UserBase:
|
class UserBase:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_authenticated(self):
|
def is_authenticated(self):
|
||||||
return True
|
return True
|
||||||
|
@ -170,7 +169,7 @@ class User(UserBase, Base):
|
||||||
theme = Column(Integer, default=0)
|
theme = Column(Integer, default=0)
|
||||||
|
|
||||||
|
|
||||||
# Class for anonymous user is derived from User base and complets overrides methods and properties for the
|
# Class for anonymous user is derived from User base and completly overrides methods and properties for the
|
||||||
# anonymous user
|
# anonymous user
|
||||||
class Anonymous(AnonymousUserMixin, UserBase):
|
class Anonymous(AnonymousUserMixin, UserBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -774,5 +773,6 @@ else:
|
||||||
migrate_Database()
|
migrate_Database()
|
||||||
clean_database()
|
clean_database()
|
||||||
|
|
||||||
# Generate global Settings Object accecable from every file
|
# Generate global Settings Object accessible from every file
|
||||||
config = Config()
|
config = Config()
|
||||||
|
searched_ids = {}
|
||||||
|
|
143
cps/web.py
143
cps/web.py
|
@ -47,7 +47,7 @@ from flask_principal import Principal
|
||||||
from flask_principal import __version__ as flask_principalVersion
|
from flask_principal import __version__ as flask_principalVersion
|
||||||
from flask_babel import Babel
|
from flask_babel import Babel
|
||||||
from flask_babel import gettext as _
|
from flask_babel import gettext as _
|
||||||
import pytz
|
|
||||||
import requests
|
import requests
|
||||||
from werkzeug.security import generate_password_hash, check_password_hash
|
from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
from werkzeug.datastructures import Headers
|
from werkzeug.datastructures import Headers
|
||||||
|
@ -184,14 +184,6 @@ lm.anonymous_user = ub.Anonymous
|
||||||
app.secret_key = os.getenv('SECRET_KEY', 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT')
|
app.secret_key = os.getenv('SECRET_KEY', 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT')
|
||||||
db.setup_db()
|
db.setup_db()
|
||||||
|
|
||||||
'''if config.config_log_level == logging.DEBUG:
|
|
||||||
logging.getLogger("sqlalchemy.engine").addHandler(file_handler)
|
|
||||||
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
|
|
||||||
logging.getLogger("sqlalchemy.pool").addHandler(file_handler)
|
|
||||||
logging.getLogger("sqlalchemy.pool").setLevel(config.config_log_level)
|
|
||||||
logging.getLogger("sqlalchemy.orm").addHandler(file_handler)
|
|
||||||
logging.getLogger("sqlalchemy.orm").setLevel(config.config_log_level)'''
|
|
||||||
|
|
||||||
|
|
||||||
def is_gdrive_ready():
|
def is_gdrive_ready():
|
||||||
return os.path.exists(os.path.join(config.get_main_dir,'settings.yaml')) and \
|
return os.path.exists(os.path.join(config.get_main_dir,'settings.yaml')) and \
|
||||||
|
@ -462,7 +454,7 @@ def edit_required(f):
|
||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
# Language and content filters
|
# Language and content filters for displaying in the UI
|
||||||
def common_filters():
|
def common_filters():
|
||||||
if current_user.filter_language() != "all":
|
if current_user.filter_language() != "all":
|
||||||
lang_filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
|
lang_filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
|
||||||
|
@ -473,6 +465,19 @@ def common_filters():
|
||||||
return and_(lang_filter, ~content_rating_filter)
|
return and_(lang_filter, ~content_rating_filter)
|
||||||
|
|
||||||
|
|
||||||
|
# Creates for all stored languages a translated speaking name in the array for the UI
|
||||||
|
def speaking_language(languages = None):
|
||||||
|
if not languages:
|
||||||
|
languages = db.session.query(db.Languages).all()
|
||||||
|
for lang in languages:
|
||||||
|
try:
|
||||||
|
cur_l = LC.parse(lang.lang_code)
|
||||||
|
lang.name = cur_l.get_language_name(get_locale())
|
||||||
|
except Exception:
|
||||||
|
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
||||||
|
return languages
|
||||||
|
|
||||||
|
|
||||||
# Fill indexpage with all requested data from database
|
# Fill indexpage with all requested data from database
|
||||||
def fill_indexpage(page, database, db_filter, order, *join):
|
def fill_indexpage(page, database, db_filter, order, *join):
|
||||||
if current_user.show_detail_random():
|
if current_user.show_detail_random():
|
||||||
|
@ -489,6 +494,8 @@ def fill_indexpage(page, database, db_filter, order, *join):
|
||||||
return entries, random, pagination
|
return entries, random, pagination
|
||||||
|
|
||||||
|
|
||||||
|
# Modifies different Database objects, first check if elements have to be added to database, than check
|
||||||
|
# if elements have to be deleted, because they are no longer used
|
||||||
def modify_database_object(input_elements, db_book_object, db_object, db_session, db_type):
|
def modify_database_object(input_elements, db_book_object, db_object, db_session, db_type):
|
||||||
input_elements = [x for x in input_elements if x != '']
|
input_elements = [x for x in input_elements if x != '']
|
||||||
# we have all input element (authors, series, tags) names now
|
# we have all input element (authors, series, tags) names now
|
||||||
|
@ -557,7 +564,7 @@ def modify_database_object(input_elements, db_book_object, db_object, db_session
|
||||||
db_book_object.append(new_element)
|
db_book_object.append(new_element)
|
||||||
|
|
||||||
|
|
||||||
# read search results from calibre-database and return it
|
# read search results from calibre-database and return it (function is used for feed and simple search
|
||||||
def get_search_results(term):
|
def get_search_results(term):
|
||||||
q = list()
|
q = list()
|
||||||
authorterms = re.split("[, ]+", term)
|
authorterms = re.split("[, ]+", term)
|
||||||
|
@ -581,7 +588,6 @@ def feed_search(term):
|
||||||
entriescount = len(entries) if len(entries) > 0 else 1
|
entriescount = len(entries) if len(entries) > 0 else 1
|
||||||
pagination = Pagination(1, entriescount, entriescount)
|
pagination = Pagination(1, entriescount, entriescount)
|
||||||
return render_xml_template('feed.xml', searchterm=term, entries=entries, pagination=pagination)
|
return render_xml_template('feed.xml', searchterm=term, entries=entries, pagination=pagination)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return render_xml_template('feed.xml', searchterm="")
|
return render_xml_template('feed.xml', searchterm="")
|
||||||
|
|
||||||
|
@ -907,13 +913,7 @@ def get_tags_json():
|
||||||
def get_languages_json():
|
def get_languages_json():
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
query = request.args.get('q').lower()
|
query = request.args.get('q').lower()
|
||||||
languages = db.session.query(db.Languages).all()
|
languages = speaking_language()
|
||||||
for lang in languages:
|
|
||||||
try:
|
|
||||||
cur_l = LC.parse(lang.lang_code)
|
|
||||||
lang.name = cur_l.get_language_name(get_locale())
|
|
||||||
except Exception:
|
|
||||||
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
|
||||||
entries = [s for s in languages if query in s.name.lower()]
|
entries = [s for s in languages if query in s.name.lower()]
|
||||||
json_dumps = json.dumps([dict(name=r.name) for r in entries])
|
json_dumps = json.dumps([dict(name=r.name) for r in entries])
|
||||||
return json_dumps
|
return json_dumps
|
||||||
|
@ -1212,13 +1212,7 @@ def series(book_id, page):
|
||||||
def language_overview():
|
def language_overview():
|
||||||
if current_user.show_language():
|
if current_user.show_language():
|
||||||
if current_user.filter_language() == u"all":
|
if current_user.filter_language() == u"all":
|
||||||
languages = db.session.query(db.Languages).all()
|
languages = speaking_language()
|
||||||
for lang in languages:
|
|
||||||
try:
|
|
||||||
cur_l = LC.parse(lang.lang_code)
|
|
||||||
lang.name = cur_l.get_language_name(get_locale())
|
|
||||||
except Exception:
|
|
||||||
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
cur_l = LC.parse(current_user.filter_language())
|
cur_l = LC.parse(current_user.filter_language())
|
||||||
|
@ -1521,7 +1515,6 @@ def google_drive_callback():
|
||||||
f.write(credentials.to_json())
|
f.write(credentials.to_json())
|
||||||
except ValueError as error:
|
except ValueError as error:
|
||||||
app.logger.error(error)
|
app.logger.error(error)
|
||||||
finally:
|
|
||||||
return redirect(url_for('configuration'))
|
return redirect(url_for('configuration'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1730,12 +1723,8 @@ def advanced_search():
|
||||||
serie_names = db.session.query(db.Series).filter(db.Series.id.in_(include_series_inputs)).all()
|
serie_names = db.session.query(db.Series).filter(db.Series.id.in_(include_series_inputs)).all()
|
||||||
searchterm.extend(serie.name for serie in serie_names)
|
searchterm.extend(serie.name for serie in serie_names)
|
||||||
language_names = db.session.query(db.Languages).filter(db.Languages.id.in_(include_languages_inputs)).all()
|
language_names = db.session.query(db.Languages).filter(db.Languages.id.in_(include_languages_inputs)).all()
|
||||||
for lang in language_names:
|
if language_names:
|
||||||
try:
|
language_names = speaking_language(language_names)
|
||||||
cur_l = LC.parse(lang.lang_code)
|
|
||||||
lang.name = cur_l.get_language_name(get_locale())
|
|
||||||
except Exception:
|
|
||||||
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
|
||||||
searchterm.extend(language.name for language in language_names)
|
searchterm.extend(language.name for language in language_names)
|
||||||
if rating_high:
|
if rating_high:
|
||||||
searchterm.extend([_(u"Rating <= %s" % rating_high)])
|
searchterm.extend([_(u"Rating <= %s" % rating_high)])
|
||||||
|
@ -1794,22 +1783,19 @@ def advanced_search():
|
||||||
q = q.filter(getattr(db.Books, 'custom_column_'+str(c.id)).any(
|
q = q.filter(getattr(db.Books, 'custom_column_'+str(c.id)).any(
|
||||||
db.cc_classes[c.id].value.ilike("%" + custom_query + "%")))
|
db.cc_classes[c.id].value.ilike("%" + custom_query + "%")))
|
||||||
q = q.all()
|
q = q.all()
|
||||||
|
ids = list()
|
||||||
|
for element in q:
|
||||||
|
ids.append(element.id)
|
||||||
|
ub.searched_ids[current_user.id] = ids
|
||||||
return render_title_template('search.html', searchterm=searchterm,
|
return render_title_template('search.html', searchterm=searchterm,
|
||||||
entries=q, title=_(u"search"), page="search")
|
entries=q, title=_(u"search"), page="search")
|
||||||
# prepare data for search-form
|
# prepare data for search-form
|
||||||
tags = db.session.query(db.Tags).order_by(db.Tags.name).all()
|
tags = db.session.query(db.Tags).order_by(db.Tags.name).all()
|
||||||
series = db.session.query(db.Series).order_by(db.Series.name).all()
|
series = db.session.query(db.Series).order_by(db.Series.name).all()
|
||||||
if current_user.filter_language() == u"all":
|
if current_user.filter_language() == u"all":
|
||||||
languages = db.session.query(db.Languages).all()
|
languages = speaking_language()
|
||||||
for lang in languages:
|
|
||||||
try:
|
|
||||||
cur_l = LC.parse(lang.lang_code)
|
|
||||||
lang.name = cur_l.get_language_name(get_locale())
|
|
||||||
except Exception:
|
|
||||||
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
|
||||||
else:
|
else:
|
||||||
languages = None
|
languages = None
|
||||||
|
|
||||||
return render_title_template('search_form.html', tags=tags, languages=languages,
|
return render_title_template('search_form.html', tags=tags, languages=languages,
|
||||||
series=series, title=_(u"search"), cc=cc, page="advsearch")
|
series=series, title=_(u"search"), cc=cc, page="advsearch")
|
||||||
|
|
||||||
|
@ -2213,6 +2199,56 @@ def add_to_shelf(shelf_id, book_id):
|
||||||
return redirect(request.environ["HTTP_REFERER"])
|
return redirect(request.environ["HTTP_REFERER"])
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
@app.route("/shelf/massadd/<int:shelf_id>")
|
||||||
|
@login_required
|
||||||
|
def search_to_shelf(shelf_id):
|
||||||
|
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
|
||||||
|
if shelf is None:
|
||||||
|
app.logger.info("Invalid shelf specified")
|
||||||
|
return "Invalid shelf specified", 400
|
||||||
|
|
||||||
|
if not shelf.is_public and not shelf.user_id == int(current_user.id):
|
||||||
|
app.logger.info("Sorry you are not allowed to add a book to the the shelf: %s" % shelf.name)
|
||||||
|
return "Sorry you are not allowed to add a book to the the shelf: %s" % shelf.name, 403
|
||||||
|
|
||||||
|
if shelf.is_public and not current_user.role_edit_shelfs():
|
||||||
|
app.logger.info("User is not allowed to edit public shelves")
|
||||||
|
return "User is not allowed to edit public shelves", 403
|
||||||
|
|
||||||
|
if current_user.id in ub.searched_ids and ub.searched_ids[current_user.id]:
|
||||||
|
books_for_shelf = list()
|
||||||
|
books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).all()
|
||||||
|
if books_in_shelf:
|
||||||
|
book_ids = list()
|
||||||
|
for book_id in books_in_shelf:
|
||||||
|
book_ids.append(book_id.book_id)
|
||||||
|
for id in ub.searched_ids[current_user.id]:
|
||||||
|
if id not in book_ids:
|
||||||
|
books_for_shelf.append(id)
|
||||||
|
else:
|
||||||
|
books_for_shelf = ub.searched_ids[current_user.id]
|
||||||
|
|
||||||
|
if not books_for_shelf:
|
||||||
|
app.logger.info("Books are already part of the shelf: %s" % shelf.name)
|
||||||
|
flash(_(u"Books are already part of the shelf: %s" % shelf.name), category="error")
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
maxOrder = ub.session.query(func.max(ub.BookShelf.order)).filter(ub.BookShelf.shelf == shelf_id).first()
|
||||||
|
if maxOrder[0] is None:
|
||||||
|
maxOrder = 0
|
||||||
|
else:
|
||||||
|
maxOrder = maxOrder[0]
|
||||||
|
|
||||||
|
for book in books_for_shelf:
|
||||||
|
maxOrder = maxOrder + 1
|
||||||
|
ins = ub.BookShelf(shelf=shelf.id, book_id=book, order=maxOrder)
|
||||||
|
ub.session.add(ins)
|
||||||
|
ub.session.commit()
|
||||||
|
flash(_(u"Books have been added to shelf: %(sname)s", sname=shelf.name), category="success")
|
||||||
|
else:
|
||||||
|
flash(_(u"Could not add books to shelf: %(sname)s", sname=shelf.name), category="error")
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/shelf/remove/<int:shelf_id>/<int:book_id>")
|
@app.route("/shelf/remove/<int:shelf_id>/<int:book_id>")
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -2397,13 +2433,7 @@ def order_shelf(shelf_id):
|
||||||
def profile():
|
def profile():
|
||||||
content = ub.session.query(ub.User).filter(ub.User.id == int(current_user.id)).first()
|
content = ub.session.query(ub.User).filter(ub.User.id == int(current_user.id)).first()
|
||||||
downloads = list()
|
downloads = list()
|
||||||
languages = db.session.query(db.Languages).all()
|
languages = speaking_language()
|
||||||
for lang in languages:
|
|
||||||
try:
|
|
||||||
cur_l = LC.parse(lang.lang_code)
|
|
||||||
lang.name = cur_l.get_language_name(get_locale())
|
|
||||||
except Exception:
|
|
||||||
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
|
||||||
translations = babel.list_translations() + [LC('en')]
|
translations = babel.list_translations() + [LC('en')]
|
||||||
for book in content.downloads:
|
for book in content.downloads:
|
||||||
downloadBook = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
|
downloadBook = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
|
||||||
|
@ -2769,13 +2799,7 @@ def configuration_helper(origin):
|
||||||
@admin_required
|
@admin_required
|
||||||
def new_user():
|
def new_user():
|
||||||
content = ub.User()
|
content = ub.User()
|
||||||
languages = db.session.query(db.Languages).all()
|
languages = speaking_language()
|
||||||
for lang in languages:
|
|
||||||
try:
|
|
||||||
cur_l = LC.parse(lang.lang_code)
|
|
||||||
lang.name = cur_l.get_language_name(get_locale())
|
|
||||||
except Exception:
|
|
||||||
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
|
||||||
translations = [LC('en')] + babel.list_translations()
|
translations = [LC('en')] + babel.list_translations()
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
to_save = request.form.to_dict()
|
to_save = request.form.to_dict()
|
||||||
|
@ -2880,13 +2904,7 @@ def edit_mailsettings():
|
||||||
def edit_user(user_id):
|
def edit_user(user_id):
|
||||||
content = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first() # type: ub.User
|
content = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first() # type: ub.User
|
||||||
downloads = list()
|
downloads = list()
|
||||||
languages = db.session.query(db.Languages).all()
|
languages = speaking_language()
|
||||||
for lang in languages:
|
|
||||||
try:
|
|
||||||
cur_l = LC.parse(lang.lang_code)
|
|
||||||
lang.name = cur_l.get_language_name(get_locale())
|
|
||||||
except Exception:
|
|
||||||
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
|
||||||
translations = babel.list_translations() + [LC('en')]
|
translations = babel.list_translations() + [LC('en')]
|
||||||
for book in content.downloads:
|
for book in content.downloads:
|
||||||
downloadBook = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
|
downloadBook = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
|
||||||
|
@ -3100,7 +3118,6 @@ def edit_book(book_id):
|
||||||
helper.global_WorkerThread.add_upload(current_user.nickname,
|
helper.global_WorkerThread.add_upload(current_user.nickname,
|
||||||
"<a href=\""+ url_for('show_book', book_id=book.id) +"\">"+ uploadText + "</a>")
|
"<a href=\""+ url_for('show_book', book_id=book.id) +"\">"+ uploadText + "</a>")
|
||||||
|
|
||||||
|
|
||||||
to_save = request.form.to_dict()
|
to_save = request.form.to_dict()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -414,7 +414,7 @@ class WorkerThread(threading.Thread):
|
||||||
sys.stderr = org_stderr
|
sys.stderr = org_stderr
|
||||||
|
|
||||||
except (socket.error, smtplib.SMTPRecipientsRefused, smtplib.SMTPException) as e:
|
except (socket.error, smtplib.SMTPRecipientsRefused, smtplib.SMTPException) as e:
|
||||||
self._handleError(error_message)
|
self._handleError(e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _formatRuntime(self, runtime):
|
def _formatRuntime(self, runtime):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user