roemoved vestigial code from search view
parent
8d7f7fe612
commit
739fccbe83
|
@ -2,8 +2,6 @@
|
|||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="/static/css/book_list.css">
|
||||
<link rel="stylesheet" href="/static/css/book_panel.css">
|
||||
<!-- important! search.css goes last -->
|
||||
<link rel="stylesheet" href="/static/css/search.css">
|
||||
{% endblock %}
|
||||
{% block extra_head %}
|
||||
<script type="text/javascript" src="/static/js/wishlist.js"></script>
|
||||
|
@ -43,8 +41,10 @@
|
|||
{% for work in results %}
|
||||
<div class="{% cycle 'row1' 'row2' %}">
|
||||
{% 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 %}{% endwith %}
|
||||
</div>
|
||||
{% empty %}
|
||||
<h2>Sorry, couldn't find that!</h2>
|
||||
|
|
|
@ -634,30 +634,20 @@ def search(request):
|
|||
|
||||
# flag search result as on wishlist as appropriate
|
||||
if not request.user.is_anonymous():
|
||||
# get a list of all the googlebooks_ids for works on the user's wishlist
|
||||
wishlist = request.user.wishlist
|
||||
editions = models.Edition.objects.filter(work__wishlists__in=[wishlist])
|
||||
googlebooks_ids = [e['googlebooks_id'] for e in editions.values('googlebooks_id')]
|
||||
ungluers = userlists.other_users(request.user, 5)
|
||||
# if the results is on their wishlist flag it
|
||||
for result in results:
|
||||
if result['googlebooks_id'] in googlebooks_ids:
|
||||
result['on_wishlist'] = True
|
||||
else:
|
||||
result['on_wishlist'] = False
|
||||
else:
|
||||
ungluers = userlists.other_users(None, 5)
|
||||
|
||||
# also urlencode some parameters we'll need to pass to workstub in the title links
|
||||
# needs to be done outside the if condition
|
||||
works=[]
|
||||
for result in results:
|
||||
result['urlimage'] = urllib.quote_plus(sub('^https?:\/\/','', result['cover_image_thumbnail']).encode("utf-8"), safe='')
|
||||
result['urlauthor'] = urllib.quote_plus(result['author'].encode("utf-8"), safe='')
|
||||
result['urltitle'] = urllib.quote_plus(result['title'].encode("utf-8"), safe='')
|
||||
|
||||
try:
|
||||
edition = models.Edition.objects.get(googlebooks_id=result['googlebooks_id'])
|
||||
works.append(edition.work)
|
||||
except models.Edition.DoesNotExist:
|
||||
works.append(result)
|
||||
context = {
|
||||
"q": q,
|
||||
"results": results,
|
||||
"results": works,
|
||||
"ungluers": ungluers
|
||||
}
|
||||
return render(request, 'search.html', context)
|
||||
|
|
Loading…
Reference in New Issue