Merge pull request #516 from Gluejar/rejigger-home

include user faves on landing page
pull/1/head
Raymond Yee 2015-08-25 19:38:59 -04:00
commit 809ee36093
3 changed files with 38 additions and 17 deletions

View File

@ -82,7 +82,21 @@ function put_un_in_cookie2(){
</div>
{% endwith %}
</div>
{% if faves %}
<div class="spacer"></div>
<h3 class="featured_books">Your Recent Faves</h3>
<div>
{% for work in faves %}
{% with work.googlebooks_id as googlebooks_id %}
{% include "book_panel.html" %}
{% endwith %}
{% endfor %}
<a class="more_featured_books" href="{% url 'supporter' request.user %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div>
{% endif %}
{% if top_pledge %}
<div class="spacer"></div>
<h3 class="featured_books">Pledge to Make These eBooks Free</h3>
<div>
{% for campaign in top_pledge %}
@ -94,6 +108,16 @@ function put_un_in_cookie2(){
<a class="more_featured_books" href="{% url 'campaign_list' 'pledge' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div>
{% endif %}
<div class="spacer"></div>
<h3 class="featured_books">Read These Free Licensed eBooks</h3>
<div>
{% for work in cc_books %}
{% with work.googlebooks_id as googlebooks_id %}
{% include "book_panel.html" %}
{% endwith %}
{% endfor %}
<a class="more_featured_books" href="{% url 'cc_list' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div>
<div class="spacer"></div>
{% if top_b2u %}
<h3 class="featured_books">Buy and Read These eBooks to Make Them Free</h3>
@ -131,16 +155,6 @@ function put_un_in_cookie2(){
<a class="more_featured_books" href="{% url 'campaign_list' 'unglued' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div>
<div class="spacer"></div>
<h3 class="featured_books">Read These Free Creative Commons eBooks</h3>
<div>
{% for work in cc_books %}
{% with work.googlebooks_id as googlebooks_id %}
{% include "book_panel.html" %}
{% endwith %}
{% endfor %}
<a class="more_featured_books" href="{% url 'cc_list' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div>
<div class="spacer"></div>
</div>
<div id="js-rightcol">

View File

@ -217,14 +217,15 @@ def cover_width(work):
return cover_width
def home(request, landing=False):
if request.user.is_authenticated() and landing == False:
faves = None
if request.user.is_authenticated() :
next=request.GET.get('next', False)
if next:
# should happen only for new users
return HttpResponseRedirect(next)
return HttpResponseRedirect(reverse('supporter',
args=[request.user.username]))
else:
wishes = request.user.wishlist.wishes_set.all().order_by('-created')[:4]
faves = [wish.work for wish in wishes]
"""
use campaigns instead of works so that we can order by amount left,
drive interest toward most-nearly-successful
@ -244,7 +245,6 @@ def home(request, landing=False):
cc_books = models.Work.objects.exclude(id = featured.id).filter(
featured__isnull=False,
editions__ebooks__rights__in=cc.LICENSE_LIST
).distinct().order_by('-featured')[:4]
"""
@ -311,6 +311,7 @@ def home(request, landing=False):
'cc_books': cc_books,
'most_wished': most_wished,
'featured': featured,
'faves': faves,
}
)

View File

@ -6,6 +6,7 @@ import os
import re
import time
import unittest
from urlparse import (urlparse, urlunparse)
from selenium import selenium, webdriver
from selenium.common.exceptions import NoSuchElementException
@ -204,8 +205,13 @@ def test_relaunch(unglue_it_url = settings.LIVE_SERVER_TEST_URL, do_local=True,
# click on biggest campaign list
# I have no idea why selenium thinks a is not displayed....so that's why I'm going up one element.
# http://stackoverflow.com/a/6141678/7782
biggest_campaign_link = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("li > a[href*='/campaigns/ending']"))
biggest_campaign_link.click()
#biggest_campaign_link = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("li > a[href*='/campaigns/ending']"))
#biggest_campaign_link.click()
#time.sleep(1)
# jump to /campaigns/ending#2
p = list(urlparse(UNGLUE_IT_URL)); p[2] = '/campaigns/ending#2'
sel.get(urlunparse(p))
time.sleep(1)
# pull up one of the campaigns to pledge to