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 id="js-maincol-fl">
<div id="js-main-container">
<h3 class="featured_books">Active Campaigns</h3>
<div>
{% for campaign in top_campaigns %}
{% 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 %}
{% endfor %}
<a class="more_featured_books" href="{% url campaign_list 'ending' %}"></a>
</div>
{% if top_campaigns %}
<h3 class="featured_books">Active Campaigns</h3>
<div>
{% for campaign in top_campaigns %}
{% 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 %}
{% endfor %}
<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>
<h3 class="featured_books">Already Unglued</h3>

View File

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