include user faves on landing page

and stop redirecting / to supporter page
pull/1/head
eric 2015-08-24 10:27:39 -04:00
parent 8d80be5248
commit ff39129674
2 changed files with 30 additions and 15 deletions

View File

@ -82,7 +82,21 @@ function put_un_in_cookie2(){
</div> </div>
{% endwith %} {% endwith %}
</div> </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 %} {% if top_pledge %}
<div class="spacer"></div>
<h3 class="featured_books">Pledge to Make These eBooks Free</h3> <h3 class="featured_books">Pledge to Make These eBooks Free</h3>
<div> <div>
{% for campaign in top_pledge %} {% 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> <a class="more_featured_books" href="{% url 'campaign_list' 'pledge' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div> </div>
{% endif %} {% 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> <div class="spacer"></div>
{% if top_b2u %} {% if top_b2u %}
<h3 class="featured_books">Buy and Read These eBooks to Make Them Free</h3> <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> <a class="more_featured_books" href="{% url 'campaign_list' 'unglued' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div> </div>
<div class="spacer"></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>
<div id="js-rightcol"> <div id="js-rightcol">

View File

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