Merge branch 'search_on_campaigns'

pull/1/head
Andromeda Yelton 2013-03-20 16:46:40 -04:00
commit 9a15545567
4 changed files with 44 additions and 4 deletions

View File

@ -49,8 +49,9 @@ $j(document).ready(function() {
<div id="js-maincol-fr">
<div class="js-maincol-inner">
<div id="content-block">
{% if campaign_works %}
<div class="content-block-heading">
<h2 class="content-heading">Google Books search results</span></h2>
<h2 class="content-heading">Unglue.it Campaigns</span></h2>
<ul class="book-list-view">
<li>View As:</li>
<li class="view-list">
@ -65,8 +66,39 @@ $j(document).ready(function() {
</li>
</ul>
</div>
<div id="content-block-content-1"><div id="unglueit-results">
{% for work in campaign_works %}
<div class="{% cycle 'row1' 'row2' %} book">
{% with work.googlebooks_id as googlebooks_id %}
{% with work.last_campaign_status as status %}
{% with work.last_campaign.deadline as deadline %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}
</div>
{% endfor %}
</div></div>
{% endif %}
<div class="content-block-heading">
<h2 class="content-heading"><a href="https://www.google.com/search?q={{q }}&amp;tbm=bks">Google Books</a> search results</span></h2>
{% if not campaign_works %}
<ul class="book-list-view">
<li>View As:</li>
<li class="view-list">
<a href="#" id="toggle-list">
<img src="/static/images/booklist/view-list.png" align="view list" title="view list" height="21" width="24" alt="use list view" />
</a>
</li>
<li class="view-list">
<a href="#" id="toggle-panel">
<img src="/static/images/booklist/view-icon.png" align="view icon" title="view icon" height="22" width="22" alt="use panel view" />
</a>
</li>
</ul>
{% endif %}
</div>
<div id="content-block-content"><div id="results">
{% for work in results %}
{% if not work.campaigns %}
<div class="{% cycle 'row1' 'row2' %} book">
{% with work.googlebooks_id as googlebooks_id %}
{% with work.last_campaign_status as status %}
@ -75,6 +107,7 @@ $j(document).ready(function() {
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}{% endwith %}
</div>
{% endif %}
{% empty %}
<h2>Sorry, couldn't find that!</h2>
<div class="js-search">

View File

@ -1555,6 +1555,12 @@ def search(request):
q = request.GET.get('q', None)
page = int(request.GET.get('page', 1))
results = gluejar_search(q, user_ip=request.META['REMOTE_ADDR'], page=page)
if page==1:
work_query = Q(title__icontains=q) | Q(editions__authors__name__icontains=q) | Q(subjects__name__iexact=q)
campaign_works = models.Work.objects.exclude(campaigns = None).filter(work_query).distinct()
else:
campaign_works = None
# flag search result as on wishlist as appropriate
if not request.user.is_anonymous():
@ -1572,7 +1578,8 @@ def search(request):
context = {
"q": q,
"results": works,
"ungluers": ungluers
"ungluers": ungluers,
"campaign_works": campaign_works
}
return render(request, 'search.html', context)

File diff suppressed because one or more lines are too long

View File

@ -656,7 +656,7 @@ div#content-block {
font-weight:normal;
}
div#content-block-content {
div#content-block-content, div#content-block-content-1 {
width:100%;
overflow:hidden;
padding-left: 10px;