Merge pull request #354 from Gluejar/revise_landing

landing page now shows three categories
pull/1/head
Raymond Yee 2014-05-23 14:51:41 -07:00
commit 1074afd6bf
3 changed files with 61 additions and 62 deletions

View File

@ -2,7 +2,7 @@
{% load endless %}
{% load lang_utils %}
{% block title %} Active Campaigns {% endblock %}
{% block title %} {{ facet_label }} Campaigns {% endblock %}
{% block extra_css %}
<link type="text/css" rel="stylesheet" href="/static/css/supporter_layout.css" />
<link type="text/css" rel="stylesheet" href="/static/css/book_list.css" />
@ -31,11 +31,15 @@ location.hash = "#2";
<div id="block-intro-text"><span class="special-user-name">{{ facet_label }} Campaigns</span></div>
</div>
<div class="user-block2">
{% ifequal facet "t4u" %}
{% ifequal facet "unglued" %}
The support of ungluers like you helped make these {% if pub_lang %}{{pub_lang|ez_lang_name}} language {% endif %}books free to the world.
{% else %}{% ifequal facet "t4u" %}
Thank the creators for making these {% if pub_lang %}{{pub_lang|ez_lang_name}} language {% endif %}books free to the world.
{% else %}{% ifequal facet "b2u" %}
By purchasing copies of these {% if pub_lang %}{{pub_lang|ez_lang_name}} language {% endif %}books, ungluers like you are helping to make them free to the world.
{% else %}
With your help we're raising money to make these {% if pub_lang %}{{pub_lang|ez_lang_name}} language {% endif %}books free to the world.
{% endifequal %}
{% endifequal %}{% endifequal %}{% endifequal %}
</div>
<div class="user-block3">
</div>

View File

@ -41,72 +41,66 @@ function put_un_in_cookie2(){
<div class="js-main" id="content-block">
<div id="js-maincol-fl">
<div id="js-main-container">
{% if top_campaigns %}
<h3 class="featured_books">Active Campaigns</h3>
{% if top_pledge %}
<h3 class="featured_books">Pledge to Make These eBooks Free</h3>
<div>
{% for campaign in top_campaigns %}
{% for campaign in top_pledge %}
{% with campaign.work as work %}
{% with work.googlebooks_id as googlebooks_id %}
{% with "ACTIVE" as status %}
{% with campaign.deadline as deadline %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}{% endwith %}
{% endwith %}{% endwith %}
{% endfor %}
<a class="more_featured_books" href="{% url campaign_list 'ending' %}"><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>
{% else %}{% if coming_soon %}
<h3 class="featured_books">Coming Soon</h3>
<div>
{% for campaign in coming_soon %}
{% with campaign.work as work %}
{% with work.googlebooks_id as googlebooks_id %}
{% with "INITIALIZED" as status %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}
{% endfor %}
<a class="more_featured_books" href="{% url campaign_list 'soon' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div>
{% endif %}{% endif %}
{% endif %}
<div class="spacer"></div>
<h3 class="featured_books">Already Unglued</h3>
{% if top_b2u %}
<h3 class="featured_books">Buy and Read These eBooks to Make Them Free</h3>
<div>
{% for campaign in top_b2u %}
{% with campaign.work as work %}
{% with work.googlebooks_id as googlebooks_id %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}
{% endfor %}
<a class="more_featured_books" href="{% url campaign_list 'b2u' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div>
{% endif %}
<div class="spacer"></div>
{% if top_t4u %}
<h3 class="featured_books">Read These Free eBooks and Thank the Creators</h3>
<div>
{% for campaign in top_t4u %}
{% with campaign.work as work %}
{% with work.googlebooks_id as googlebooks_id %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}
{% endfor %}
<a class="more_featured_books" href="{% url campaign_list 't4u' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div>
{% endif %}
<div class="spacer"></div>
<h3 class="featured_books">Read These Unglued eBooks - You've Made Them Free</h3>
<div>
{% for work in unglued_books %}
{% with work.googlebooks_id as googlebooks_id %}
{% with "ACTIVE" as status %}
{% with work.last_campaign.deadline as deadline %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}
{% endwith %}
{% endfor %}
<a class="more_featured_books" href="{% url unglued_list '' %}"><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 class="spacer"></div>
<h3 class="featured_books">Latest Creative Commons</h3>
<h3 class="featured_books">Read These Free Creative Commons eBooks</h3>
<div>
{% for work in cc_books %}
{% with work.googlebooks_id as googlebooks_id %}
{% with "ACTIVE" as status %}
{% with work.last_campaign.deadline as deadline %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}
{% 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>
<h3 class="featured_books">Site Faves</h3>
<div>
{% for work in most_wished %}
{% with work.googlebooks_id as googlebooks_id %}
{% with "ACTIVE" as status %}
{% with work.last_campaign.deadline as deadline %}
{% include "book_panel.html" %}
{% endwith %}{% endwith %}{% endwith %}
{% endfor %}
<a class="more_featured_books" href="{% url work_list 'popular' %}"><i class="fa fa-arrow-circle-o-right fa-3x"></i></a>
</div>
<div class="spacer"></div>
</div>
<div id="js-rightcol">
<div class="js-rightcol-padd">

View File

@ -221,10 +221,10 @@ def home(request, landing=False):
use campaigns instead of works so that we can order by amount left,
drive interest toward most-nearly-successful
"""
top_campaigns = models.Campaign.objects.filter(status="ACTIVE").order_by('left')[:4]
coming_soon = []
if not top_campaigns:
coming_soon = models.Campaign.objects.filter(status="INITIALIZED").order_by('-work__num_wishes')[:4]
top_pledge = models.Campaign.objects.filter(status="ACTIVE",type=REWARDS).order_by('left')[:4]
top_b2u = models.Campaign.objects.filter(status="ACTIVE", type=BUY2UNGLUE).order_by('-work__num_wishes')[:4]
top_t4u = models.Campaign.objects.filter(status="ACTIVE",type=THANKS).order_by('-work__num_wishes')[:4]
most_wished = models.Work.objects.order_by('-num_wishes')[:4]
@ -292,8 +292,9 @@ def home(request, landing=False):
'home.html',
{
'events': events,
'top_campaigns': top_campaigns,
'coming_soon': coming_soon,
'top_pledge': top_pledge,
'top_b2u': top_b2u,
'top_t4u': top_t4u,
'unglued_books': unglued_books,
'cc_books': cc_books,
'most_wished': most_wished,
@ -945,7 +946,12 @@ class UngluedListView(FilterableListView):
else:
context['activetab'] = "#1"
return context
FACET_LABELS = {
'b2u': "Buy to Unglue",
't4u': "Thanks for Ungluing",
'pledge': "Pledge to Unglue",
'unglued': "Successful",
}
class CampaignListView(FilterableListView):
template_name = "campaign_list.html"
context_object_name = "campaign_list"
@ -971,6 +977,8 @@ class CampaignListView(FilterableListView):
return models.Campaign.objects.filter(status='ACTIVE', type=THANKS).annotate(pledges=Count('transaction')).order_by('-pledges')
elif (facet == 'pledge'):
return models.Campaign.objects.filter(status='ACTIVE', type=REWARDS).annotate(pledges=Count('transaction')).order_by('-pledges')
elif (facet == 'unglued'):
return models.Campaign.objects.filter(status='SUCCESSFUL').annotate(pledges=Count('transaction')).order_by('-pledges')
else:
return models.Campaign.objects.all()
@ -980,14 +988,7 @@ class CampaignListView(FilterableListView):
context['ungluers'] = userlists.campaign_list_users(qs,5)
facet = self.kwargs['facet']
context['facet'] =facet
if facet == 'b2u':
context['facet_label'] = "Buy to Unglue"
elif facet == 't4u':
context['facet_label'] = "Thanks for Ungluing"
elif facet == 'pledge':
context['facet_label'] = "Pledge to Unglue"
else:
context['facet_label'] = "Active"
context['facet_label'] = FACET_LABELS.get(facet, 'Active')
return context
class MergeView(FormView):