mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-24 10:37:23 +00:00
Bugfix search for publishdates and custom column dates
Bugfix save umplauts in comments unescaped (as calibre does) Improved testability
This commit is contained in:
parent
f29088e854
commit
b3648187ff
@ -501,6 +501,8 @@ def edit_cc_data_value(book_id, book, c, to_save, cc_db_value, cc_string):
|
||||
to_save[cc_string] = None
|
||||
elif c.datatype == 'bool':
|
||||
to_save[cc_string] = 1 if to_save[cc_string] == 'True' else 0
|
||||
elif c.datatype == 'comments':
|
||||
to_save[cc_string] = Markup(to_save[cc_string]).unescape()
|
||||
elif c.datatype == 'datetime':
|
||||
try:
|
||||
to_save[cc_string] = datetime.strptime(to_save[cc_string], "%Y-%m-%d")
|
||||
@ -772,7 +774,7 @@ def edit_book(book_id):
|
||||
# Add default series_index to book
|
||||
modif_date |= edit_book_series_index(to_save["series_index"], book)
|
||||
# Handle book comments/description
|
||||
modif_date |= edit_book_comments(to_save["description"], book)
|
||||
modif_date |= edit_book_comments(Markup(to_save['description']).unescape(), book)
|
||||
# Handle identifiers
|
||||
input_identifiers = identifier_list(to_save, book)
|
||||
modification, warning = modify_identifiers(input_identifiers, book.identifiers, calibre_db.session)
|
||||
|
@ -161,7 +161,7 @@
|
||||
value="{% if book['custom_column_' ~ c.id][0].value %}{{book['custom_column_' ~ c.id][0].value|formatdate}}{% endif %}"
|
||||
{% endif %}>
|
||||
<span class="input-group-btn">
|
||||
<button type="button" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
<button type="button" id="{{ 'custom_column_' ~ c.id }}_delete" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -17,22 +17,22 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="Publishstart">{{_('Published Date From')}}</label>
|
||||
<label for="publishstart">{{_('Published Date From')}}</label>
|
||||
<div class="input-group">
|
||||
<input type="text" style="position: static;" class="datepicker form-control" name="Publishstart" id="Publishstart" value="">
|
||||
<input type="text" style="position: absolute;" class="form-control fake-input hidden" id="fake_Publishstart" value="">
|
||||
<input type="text" style="position: static;" class="datepicker form-control" name="publish_start" id="publishstart" value="">
|
||||
<input type="text" style="position: absolute;" class="form-control fake-input hidden" id="fake_publishstart" value="">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" id="pubstart_delete" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
<button type="button" id="publishstart_delete" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="Publishend">{{_('Published Date To')}}</label>
|
||||
<label for="publishend">{{_('Published Date To')}}</label>
|
||||
<div class="input-group ">
|
||||
<input type="text" style="position: static;" class="datepicker form-control" name="Publishend" id="Publishend" value="">
|
||||
<input type="text" style="position: absolute;" class="form-control fake-input hidden" id="fake_Publishend" value="">
|
||||
<input type="text" style="position: static;" class="datepicker form-control" name="publishend" id="publishend" value="">
|
||||
<input type="text" style="position: absolute;" class="form-control fake-input hidden" id="fake_publishend" value="">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" id="pubend_delete" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
<button type="button" id="publishend_delete" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -181,7 +181,7 @@
|
||||
<input type="text" style="position: static;" class="datepicker form-control" name="{{ 'custom_column_' ~ c.id }}_start" id="{{ 'custom_column_' ~ c.id }}_start" value="">
|
||||
<input type="text" style="position: absolute;" class="form-control fake-input hidden" id="fake_{{ 'custom_column_' ~ c.id }}_start" value="">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" id="pubstart_delete" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
<button type="button" id="{{ 'custom_column_' ~ c.id }}_start_delete" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -191,7 +191,7 @@
|
||||
<input type="text" style="position: static;" class="datepicker form-control" name="{{ 'custom_column_' ~ c.id }}_end" id="{{ 'custom_column_' ~ c.id }}_end" value="">
|
||||
<input type="text" style="position: absolute;" class="form-control fake-input hidden" id="fake_{{ 'custom_column_' ~ c.id }}_end" value="">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" id="pubend_delete" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
<button type="button" id="{{ 'custom_column_' ~ c.id }}_end_delete" class="datepicker_delete btn btn-default"><span class="glyphicon glyphicon-remove-circle"></span></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
12
cps/web.py
12
cps/web.py
@ -1080,10 +1080,10 @@ def adv_search_custom_columns(cc, term, q):
|
||||
custom_end = term.get('custom_column_' + str(c.id) + '_end')
|
||||
if custom_start:
|
||||
q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any(
|
||||
db.cc_classes[c.id].value >= custom_start))
|
||||
func.datetime(db.cc_classes[c.id].value) >= func.datetime(custom_start)))
|
||||
if custom_end:
|
||||
q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any(
|
||||
db.cc_classes[c.id].value <= custom_end))
|
||||
func.datetime(db.cc_classes[c.id].value) <= func.datetime(custom_end)))
|
||||
else:
|
||||
custom_query = term.get('custom_column_' + str(c.id))
|
||||
if custom_query != '' and custom_query is not None:
|
||||
@ -1254,8 +1254,8 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
|
||||
author_name = term.get("author_name")
|
||||
book_title = term.get("book_title")
|
||||
publisher = term.get("publisher")
|
||||
pub_start = term.get("Publishstart")
|
||||
pub_end = term.get("Publishend")
|
||||
pub_start = term.get("publishstart")
|
||||
pub_end = term.get("publishend")
|
||||
rating_low = term.get("ratinghigh")
|
||||
rating_high = term.get("ratinglow")
|
||||
description = term.get("comment")
|
||||
@ -1310,9 +1310,9 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
|
||||
if book_title:
|
||||
q = q.filter(func.lower(db.Books.title).ilike("%" + book_title + "%"))
|
||||
if pub_start:
|
||||
q = q.filter(db.Books.pubdate >= pub_start)
|
||||
q = q.filter(func.datetime(db.Books.pubdate) > func.datetime(pub_start))
|
||||
if pub_end:
|
||||
q = q.filter(db.Books.pubdate <= pub_end)
|
||||
q = q.filter(func.datetime(db.Books.pubdate) < func.datetime(pub_end))
|
||||
q = adv_search_read_status(q, read_status)
|
||||
if publisher:
|
||||
q = q.filter(db.Books.publishers.any(func.lower(db.Publishers.name).ilike("%" + publisher + "%")))
|
||||
|
Loading…
Reference in New Issue
Block a user