mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-19 06:30:29 +00:00
Search custom integer, custom_float in range
Search custom bool like read status (unfinished)
This commit is contained in:
parent
8d9f301aea
commit
12d46d33d9
@ -81,13 +81,24 @@ def adv_search_custom_columns(cc, term, q):
|
||||
if custom_end:
|
||||
q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any(
|
||||
func.datetime(db.cc_classes[c.id].value) <= func.datetime(custom_end)))
|
||||
elif c.datatype in ["int", "float"]:
|
||||
custom_low = term.get('custom_column_' + str(c.id) + '_low')
|
||||
custom_high = term.get('custom_column_' + str(c.id) + '_high')
|
||||
if custom_low:
|
||||
q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any(
|
||||
db.cc_classes[c.id].value >= custom_low))
|
||||
if custom_high:
|
||||
q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any(
|
||||
db.cc_classes[c.id].value <= custom_high))
|
||||
else:
|
||||
custom_query = term.get('custom_column_' + str(c.id))
|
||||
if custom_query != '' and custom_query is not None:
|
||||
if c.datatype == 'bool':
|
||||
if c.datatype == 'bool' and custom_query != "Any":
|
||||
# ToDo:
|
||||
q = q.filter(coalesce(db.cc_classes[config.config_read_column].value, False) != True)
|
||||
q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any(
|
||||
db.cc_classes[c.id].value == (custom_query == "True")))
|
||||
elif c.datatype == 'int' or c.datatype == 'float':
|
||||
elif custom_query != '' and custom_query is not None:
|
||||
if c.datatype == 'int' or c.datatype == 'float':
|
||||
q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any(
|
||||
db.cc_classes[c.id].value == custom_query))
|
||||
elif c.datatype == 'rating':
|
||||
@ -279,6 +290,15 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
|
||||
format='medium')
|
||||
)])
|
||||
cc_present = True
|
||||
if c.datatype in ["int", "float"]:
|
||||
column_low = term.get('custom_column_' + str(c.id) + '_low')
|
||||
column_high = term.get('custom_column_' + str(c.id) + '_high')
|
||||
if column_low:
|
||||
search_term.extend(["{} >= {}".format(c.name, column_low)])
|
||||
cc_present = True
|
||||
if column_high:
|
||||
search_term.extend(["{} <= {}".format(c.name,column_high)])
|
||||
cc_present = True
|
||||
elif term.get('custom_column_' + str(c.id)):
|
||||
search_term.extend([("{}: {}".format(c.name, term.get('custom_column_' + str(c.id))))])
|
||||
cc_present = True
|
||||
|
@ -158,21 +158,41 @@
|
||||
{% if cc|length > 0 %}
|
||||
{% for c in cc %}
|
||||
<div class="form-group">
|
||||
<!--input type="number" step="1" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}" value=""-->
|
||||
<label for="{{ 'custom_column_' ~ c.id }}">{{ c.name }}</label>
|
||||
{% if c.datatype == 'bool' %}
|
||||
<select name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}" class="form-control">
|
||||
<option value="" selected></option>
|
||||
<option value="Any" selected>{{_('Any')}}</option>
|
||||
<option value="">{{_('Empty')}}</option>
|
||||
<option value="True" >{{_('Yes')}}</option>
|
||||
<option value="False" >{{_('No')}}</option>
|
||||
</select>
|
||||
{% endif %}
|
||||
|
||||
{% if c.datatype == 'int' %}
|
||||
<input type="number" step="1" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}" value="">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="{{ 'custom_column_' ~ c.id }}_low">{{_('From:')}}</label>
|
||||
<input type="number" step="1" class="form-control" name="{{ 'custom_column_' ~ c.id }}_low" id="{{ 'custom_column_' ~ c.id }}_low" value="">
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="{{ 'custom_column_' ~ c.id }}_high">{{_('To:')}}</label>
|
||||
<input type="number" step="1" class="form-control" name="{{ 'custom_column_' ~ c.id }}_high" id="{{ 'custom_column_' ~ c.id }}_high" value="">
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if c.datatype == 'float' %}
|
||||
<input type="number" step="0.01" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}" value="">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="{{ 'custom_column_' ~ c.id }}_low">{{_('From:')}}</label>
|
||||
<input type="number" step="0.01" class="form-control" name="{{ 'custom_column_' ~ c.id }}_low" id="{{ 'custom_column_' ~ c.id }}_low" value="">
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="{{ 'custom_column_' ~ c.id }}_high">{{_('To:')}}</label>
|
||||
<input type="number" step="0.01" class="form-control" name="{{ 'custom_column_' ~ c.id }}_high" id="{{ 'custom_column_' ~ c.id }}_high" value="">
|
||||
</div>
|
||||
</div>
|
||||
<!--input type="number" step="0.01" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}" value=""-->
|
||||
{% endif %}
|
||||
|
||||
{% if c.datatype == 'datetime' %}
|
||||
|
Loading…
Reference in New Issue
Block a user