Merge pull request #168 from Gluejar/degruyter_stub_template

put status information in de gruyter initialized campaigns
pull/1/head
thatandromeda 2013-05-06 13:04:50 -07:00
commit 97bc857eab
3 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,40 @@
<div class="launch_top" id="degruyter_countdown" style="font-size:20px;text-align:center;width:50%"></div>
<h4>Help us unglue this book!</h4>
<p>De Gruyter has agreed to run an ungluing campaign for this book, if it can get enough support from ungluers like you. The target price will be $2100, after which the book will be free for everyone on earth to read, copy, and share, forever (under a Creative Commons <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/">BY-NC-ND</a> license).</p>
<p>They'll launch a campaign when 50 ungluers have wished for this book. Right now <span id="wisher_data"></span>. </p>
<p id="cta"></p>
<hr>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function(){
var countdown = 50 - numWishers;
if(countdown == 1) {
$j("#degruyter_countdown").html("Only 1 more ungluer to go!");
} else {
$j("#degruyter_countdown").html(countdown + " ungluers to go");
}
if(numWishers == 1) {
var wisherDataText = "1 ungluer has wished for this book"
} else {
var wisherDataText = numWishers + " ungluers have wished for this book"
}
$j("#wisher_data").html(wisherDataText);
if(isSupporter){
if(numWishers == 1) {
var callToAction = "Thanks for getting things started! Will you ask your friends to join you?"
} else {
var callToAction = "Thanks for being one of them! Will you ask your friends to join you?"
}
} else {
var callToAction = "Won't you join in?"
}
$j("#cta").html(callToAction);
});
</script>

View File

@ -0,0 +1,22 @@
"""
seed empty but initialized deGruyter books with something useful
"""
from django.core.management.base import BaseCommand
from regluit.core.models import Work
class Command(BaseCommand):
help = "Seed empty but initialized deGruyter books with something useful. Takes filename containing seed description as argument. Can be safely run more than once; will ignore books with descriptions."
def handle(self, filename, **options):
books = Work.objects.filter(editions__publisher_name__id=4311, campaigns__status="INITIALIZED")
for book in books:
if not 'degruyter_countdown' in book.description:
"""
read in file and prepend to description
ignores descriptions that already start with the seed file
"""
seed_file = open(filename)
book.description = seed_file.read() + book.description
book.save()
seed_file.close()

View File

@ -21,6 +21,19 @@
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
<script type="text/javascript" src="/static/js/counter.js"></script> <script type="text/javascript" src="/static/js/counter.js"></script>
<script type="text/javascript" src="/static/js/embed.js"></script> <script type="text/javascript" src="/static/js/embed.js"></script>
<!-- needed for DeGruyter seed description hack
makes template vars accessible in JS
-->
<script type="text/javascript">
var numWishers = {{ wishers }};
{% if request.user.id in work.last_campaign.supporters %}
var isSupporter = true;
{% else %}
var isSupporter = false;
{% endif %}
</script>
{% endblock %} {% endblock %}
{% block topsection %} {% block topsection %}