show coming soon campaigns if none active, or skip section if none initialized either

pull/1/head
Andromeda Yelton 2013-06-05 15:05:14 -04:00
parent 43cf61a7e8
commit c8ff245e80
2 changed files with 41 additions and 15 deletions

View File

@ -41,18 +41,32 @@ function put_un_in_cookie2(){
<div class="js-main" id="content-block"> <div class="js-main" id="content-block">
<div id="js-maincol-fl"> <div id="js-maincol-fl">
<div id="js-main-container"> <div id="js-main-container">
<h3 class="featured_books">Active Campaigns</h3> {% if top_campaigns %}
<div> <h3 class="featured_books">Active Campaigns</h3>
{% for campaign in top_campaigns %} <div>
{% with campaign.work as work %} {% for campaign in top_campaigns %}
{% with work.googlebooks_id as googlebooks_id %} {% with campaign.work as work %}
{% with "ACTIVE" as status %} {% with work.googlebooks_id as googlebooks_id %}
{% with campaign.deadline as deadline %} {% with "ACTIVE" as status %}
{% include "book_panel.html" %} {% with campaign.deadline as deadline %}
{% endwith %}{% endwith %}{% endwith %}{% endwith %} {% include "book_panel.html" %}
{% endfor %} {% endwith %}{% endwith %}{% endwith %}{% endwith %}
<a class="more_featured_books" href="{% url campaign_list 'ending' %}"></a> {% endfor %}
</div> <a class="more_featured_books" href="{% url campaign_list 'ending' %}"></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 'ending' %}"></a>
</div>
{% endif %}{% endif %}
<div class="spacer"></div> <div class="spacer"></div>
<h3 class="featured_books">Already Unglued</h3> <h3 class="featured_books">Already Unglued</h3>

View File

@ -148,6 +148,9 @@ def home(request, landing=False):
drive interest toward most-nearly-successful drive interest toward most-nearly-successful
""" """
top_campaigns = models.Campaign.objects.filter(status="ACTIVE").order_by('left')[:4] 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]
most_wished = models.Work.objects.order_by('-num_wishes')[:4] most_wished = models.Work.objects.order_by('-num_wishes')[:4]
@ -203,9 +206,18 @@ def home(request, landing=False):
else: else:
events = latest_actions[:6] events = latest_actions[:6]
return render(request, 'home.html', { return render(
'suppress_search_box': True, 'events': events, 'top_campaigns': top_campaigns, 'unglued_books': unglued_books, 'most_wished': most_wished request,
}) 'home.html',
{
'suppress_search_box': True,
'events': events,
'top_campaigns': top_campaigns,
'coming_soon': coming_soon,
'unglued_books': unglued_books,
'most_wished': most_wished
}
)
def stub(request): def stub(request):
path = request.path[6:] # get rid of /stub/ path = request.path[6:] # get rid of /stub/