add search_form.html

pull/18/head
Cervinko Cera 9 years ago
parent 431b6009a5
commit 7fce28790d

@ -0,0 +1,50 @@
{% extends "layout.html" %}
{% block body %}
<div class="col-sm-8">
<form role="form" action="{{ url_for('advanced_search') }}" method="GET">
<div class="form-group">
<label for="book_title">Book Title</label>
<input type="text" class="form-control" name="book_title" id="book_title" value="">
</div>
<div class="form-group">
<label for="bookAuthor">Author</label>
<input type="text" class="form-control typeahead" name="author_name" id="bookAuthor" value="" autocomplete="off">
</div>
<label for="Tags">Select Tags</label>
<div class="form-group">
<div class="btn-toolbar btn-toolbar-lg" data-toggle="buttons">
{% for tag in tags %}
<label id="tag_{{tag.id}}" class="btn btn-primary tag_click">
<input type="checkbox" autocomplete="off" name="tag" value="{{tag.id}}">{{tag.name}}</input>
</label>
{% endfor %}
</div>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
{% endblock %}
{% block js %}
<script src="{{ url_for('static', filename='js/typeahead.bundle.js') }}"></script>
<script src="{{ url_for('static', filename='js/edit_books.js') }}"></script>
<script>
$('form').on('change input', function() {
form = $('form').serialize();
$.getJSON( "{{ url_for('get_matching_tags') }}", form, function( data ) {
$('.tag_click').each(function() {
console.log(data.tags);
if ($.inArray(parseInt($(this).children('input').first().val(), 10), data.tags) == -1 ) {
$(this).addClass('disabled');
}
else {
$(this).removeClass('disabled');
}
});
});
});
</script>
{% endblock %}
{% block header %}
<link href="{{ url_for('static', filename='css/typeahead.css') }}" rel="stylesheet" media="screen">
{% endblock %}

@ -446,7 +446,6 @@ def search():
@login_required_if_no_ano @login_required_if_no_ano
def advanced_search(): def advanced_search():
if request.method == 'GET': if request.method == 'GET':
print "GETTTTTTTTTTTT"
q = db.session.query(db.Books) q = db.session.query(db.Books)
tag_inputs = request.args.getlist('tag') tag_inputs = request.args.getlist('tag')
author_name = request.args.get("author_name") author_name = request.args.get("author_name")

Loading…
Cancel
Save