Merge pull request #314 from Gluejar/t4u_loose_ends

T4u and library license loose ends
pull/1/head
Raymond Yee 2014-03-17 08:48:38 -07:00
commit f6be1560e6
15 changed files with 89 additions and 88 deletions

View File

@ -172,8 +172,9 @@ def handle_transaction_charged(sender,transaction=None, **kwargs):
if transaction.offer.license == LIBRARY:
library = Library.objects.get(id=transaction.extra['library_id'])
new_acq = Acq.objects.create(user=library.user,work=transaction.campaign.work,license= LIBRARY)
reserve_acq = Acq.objects.create(user=transaction.user,work=transaction.campaign.work,license= RESERVE, lib_acq = new_acq)
reserve_acq.expire_in(datetime.timedelta(hours=2))
if transaction.user.id != library.user.id: # don't put it on reserve if purchased by the library
reserve_acq = Acq.objects.create(user=transaction.user,work=transaction.campaign.work,license= RESERVE, lib_acq = new_acq)
reserve_acq.expire_in(datetime.timedelta(hours=2))
copies = int(transaction.extra.get('copies',1))
while copies > 1:
Acq.objects.create(user=library.user,work=transaction.campaign.work,license= LIBRARY)
@ -204,7 +205,8 @@ transaction_charged.connect(handle_transaction_charged)
# dealing with failed transactions
def handle_transaction_failed(sender,transaction=None, **kwargs):
if transaction is None:
if transaction is None or transaction.campaign.type == THANKS:
# no need to nag a failed THANKS transaction
return
# window for recharging

View File

@ -45,12 +45,13 @@
</div>
{% else %}
<div class="unglued_white">
<b>UNGLUED!</b>
{% ifequal work.last_campaign.type 3 %}
<b>THANKED!</b>
<p><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b> of thanks</p>
<p> from <b>{{ work.last_campaign.supporters_count }}</b> ungluers</p>
<p> and <b>{{ work.last_campaign.anon_count }}</b> others</p>
{% else %}
<b>UNGLUED!</b>
<p><b>On:</b> {{ deadline|date:"M d, Y" }}</p>
<p><b>Raised:</b> {{ work.last_campaign.current_total|floatformat:0|intcomma }}</p>
{% endifequal %}
@ -93,16 +94,18 @@
<p>Available in your library on<br />{{ next_acq.refreshes|date:"M j, Y" }}</p>
{% endif %}
{% else %}
<b>UNGLUE IT!</b>
{% ifequal work.last_campaign.type 1 %}
<b>UNGLUE IT!</b>
<p><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b> raised</p>
<p><b>${{ work.last_campaign.target|floatformat:0|intcomma }}</b> needed</p>
<p>by {{ deadline|naturalday:"M d, Y" }}</p>
{% else %}{% ifequal work.last_campaign.type 2 %}
<b>UNGLUE IT!</b>
<p><b>${{ work.last_campaign.left|floatformat:0|intcomma }}</b> needed</p>
<p>will unglue on </p>
<p>{{ work.last_campaign.cc_date|naturalday:"M d, Y" }}</p>
{% else %}{% ifequal work.last_campaign.type 3 %}
<b>SAY THANKS!</b>
<p><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b> of thanks</p>
<p> from <b>{{ work.last_campaign.supporters_count }}</b> ungluers</p>
<p> and <b>{{ work.last_campaign.anon_count }}</b> others</p>

View File

@ -23,10 +23,10 @@ $j(document).ready(function() {
<div id="lightbox_content">
{% if show_beg %}
<div class="border" style="padding: 10px; height: 18em">
<div id="begblock" class="rh_beg">
<div class="border" style="padding: 10px; min-height: 18em">
<div id="askblock">
<div>Please help us thank the creators for making this book free. The amount is up to you.</div>
<form class="begform" method="POST" action="{% url thank work.id %}#">
<form class="askform" method="POST" action="{% url thank work.id %}#">
{% csrf_token %}
{{ form.non_field_errors }}
<div class="contrib_amount">Amount: {{ form.preapproval_amount.errors }}${{ form.preapproval_amount }}</div>
@ -38,7 +38,7 @@ $j(document).ready(function() {
</form>
</div>
<div class="rh_beg" style="">
<div class="rh_ask">
{{ work.last_campaign.description|safe }}
</div>
</div>

View File

@ -32,7 +32,9 @@
<a href="{% url new_edition work_id edition.id %}">Edit this edition/Add ebook</a><br />
{% else %}{% if user in work.last_campaign.managers.all %}
<a href="{% url new_edition work_id edition.id %}">Edit this edition/Add ebook</a><br />
{% endif %}{% endif %}
{% else %}{% if user.is_authenticated %}
<a href="{% url new_edition work_id edition.id %}">Add ebook</a><br />
{% endif %}{% endif %}{% endif %}
{% if edition.googlebooks_id %}
See <a href="https://encrypted.google.com/books?id={{ edition.googlebooks_id }}">this edition on Google Books</a><br />
{% endif %}

View File

@ -112,25 +112,7 @@ Please fix the following before launching your campaign:
<div class="clearfix"></div>
<div class="tabs-1">
<h3>Edit the editions (if needed)</h3>
{% if campaign.rh.can_sell %}
<p> If you want to sell ebooks as part of a buy to unglue campaign, you'll also need to upload an EPUB file for the ebook you want to sell. </p>
{% endif %}
<ul>
<li><a href="{% url new_edition campaign.work.id '' %}"> Create a new edition</a> for this work</li>
{% for edition in campaign.work.editions.all %}
<li>Edition: <i>{{ edition }}</i>
<ul>
<li><a href="{% url new_edition edition.work.id edition.id %}"> Edit </a> the edition</li>
{% ifnotequal campaign.type 1 %}
{% if campaign.rh.can_sell %}
<li>You can also <a href="{% url edition_uploads edition.id %}"> Load a file</a> for this edition.</li>
{% endif %}
{% endifnotequal %}
</ul>
</li>
{% endfor %}
</ul>
{% if campaign.work.ebookfiles.0 %}
<p> <b>An Ebook file has been loaded.</b> </p>
<p>Active file: <a href="{{campaign.work.ebookfiles.0.file.url}}">{{campaign.work.ebookfiles.0.file}}</a> created {{campaign.work.ebookfiles.0.created}} </p>
@ -145,17 +127,37 @@ Please fix the following before launching your campaign:
<form action="#" method="POST">
{% csrf_token %}
{{ form.media }}
<h3>Select the main edition</h3>
<h3>Edit the editions (if needed)</h3>
{% if campaign.rh.can_sell %}
{% ifequal work.last_campaign.type 2 %}
<p> To sell ebooks as part of a buy to unglue campaign, you will need to upload an EPUB file for the ebook you want to sell. </p>
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
<p> To distribute ebooks as part of a thanks for ungluing campaign, you will need to upload the ebook files to unglue.it. </p>
{% endifequal %}
{% endif %}
<p> Please choose the edition that most closely matches the edition to be unglued. This is the edition whose cover image will display on your book's page. Your unglued edition should be identical to this edition if possible; you should note any differences under Rights Details below.</p>
<div class="std_form">
{{ form.edition.errors }}{{ form.edition }}
<div class="std_form">
<ul>
{{ form.edition.errors }}
{% for edition in campaign.work.editions.all %}
<li>Edition: <label for="id_edition_{{forloop.counter}}"> {{ edition }}</label>
<ul style="text-indent:1em">
<li> <input type="radio" {% ifequal edition.id work.preferred_edition.id %}checked="checked" {% endifequal %}id="id_edition_{{forloop.counter}}" value="{{edition.id}}" name="edition" /> Use this edition </li>
<li style="text-indent:2.5em"><a href="{% url new_edition edition.work.id edition.id %}"> Edit </a> this edition</li>
{% ifnotequal campaign.type 1 %}
{% if campaign.rh.can_sell %}
<li style="text-indent:2.5em">You can <a href="{% url edition_uploads edition.id %}"> Load a file</a> for this edition.</li>
{% endif %}
{% endifnotequal %}
</ul>
</li>
{% endfor %}
</ul>
</div>
{% if campaign.edition %}
<p>If the details of the edition you've chosen aren't accurate, you can <a href="{% url rh_edition work.id campaign.edition.id %}">edit the edition</a>.</p>
{% else %}
<p>If the edition details are inaccurate (e.g. wrong cover image), go ahead and set up the campaign with that edition anyway. You'll be able to edit the edition details from this page later on.</p>
{% endif %}
<p>If the details of the edition you've chosen aren't accurate, you can <a href="{% url rh_edition work.id work.preferred_edition.id %}">edit the edition</a>.</p>
<p>If you don't see an edition that matches what you want to release, you can <a href="{% url rh_edition work.id '' %}">create a new edition</a>.</p>
{% ifnotequal campaign_status 'ACTIVE' %}
{% ifnotequal campaign.type 3 %}
@ -421,7 +423,7 @@ Please fix the following before launching your campaign:
{% ifequal campaign.type 3 %}
<h3> Suggested Contributions </h3>
{% if not campaign.work.ebookfiles.0 %}
<p> <b>An EPUB file for this work <a class="tabs1">needs to be loaded</a>!</b></p>
<p> <b>ebook files for this work <a class="tabs1">need to be loaded</a>!</b></p>
{% endif %}
<p> Enter a suggested per/copy contribution for each user type. You may change these numbers after the campaign has begun. Don't suggest contributions between $0.00 and $1.00, because these won't be processed.</p>
<div class="jsmod-content">
@ -443,31 +445,31 @@ Please fix the following before launching your campaign:
{% ifequal campaign_status 'INITIALIZED' %}
<div class="tabs-3">
{% if not is_preview or request.user.is_staff %}
{% if campaign.launchable %}
<p>Before you hit launch:</p>
<ul class="bullets">
<li>Have you proofread your campaign? (Make sure to spellcheck!)</li>
<li>Have you <a href="{% url work_preview campaign.work.id %}">previewed your campaign</a>? Does it look how you want it to?</li>
</ul>
<p>If it doesn't look exactly the way you like, or you're having any trouble with your description, we're happy to help; please email unglue.it support (<a href="mailto:support@gluejar.com">support@gluejar.com</a>).</p>
<p>If you're happy with your campaign, here's your moment of truth!</p>
<div id="launchme"><a href="#" class="manage">Launch Campaign</a></div>
{% else %}
<p>Please make sure you've selected your campaign's edition and entered its description, target, deadline, prices or premiums, and previewed your campaign, before launching.</p>
{% ifequal campaign.type 2 %}
<p> Buy To Unglue campaigns can't be launched until ebook files <a class="tabs1">have been loaded</a> and <a class="tabs2">pricing has been set and made active</a></p>
<!-- {{campaign.problems }} -->
{% endifequal %}
{% endif %}
{% else %}
While you're free to edit your campaign, it won't be launchable until we've fully tested our new payment processor.
{% endif %}
{% if campaign.launchable %}
<p>Before you hit launch:</p>
<ul class="bullets">
<li>Have you proofread your campaign? (Make sure to spellcheck!)</li>
<li>Have you <a href="{% url work_preview campaign.work.id %}">previewed your campaign</a>? Does it look how you want it to?</li>
</ul>
<p>If it doesn't look exactly the way you like, or you're having any trouble with your description, we're happy to help; please email unglue.it support (<a href="mailto:support@gluejar.com">support@gluejar.com</a>).</p>
<p>If you're happy with your campaign, here's your moment of truth!</p>
<div id="launchme"><a href="#" class="manage">Launch Campaign</a></div>
{% else %}
{% ifequal campaign.type 1 %}
<p>Please make sure you've selected your campaign's edition and entered its description, funding goal, deadline, premiums, and previewed your campaign, before launching.</p>
{% endifequal %}
{% ifequal campaign.type 2 %}
<p>Please make sure you've selected your campaign's edition and entered its description, funding goal, initial ungluing date, prices, and previewed your campaign, before launching.</p>
<p> Buy To Unglue campaigns can't be launched until ebook files <a class="tabs1">have been loaded</a> and <a class="tabs2">pricing has been set and made active</a></p>
{% endifequal %}
{% ifequal campaign.type 3 %}
<p>Please make sure you've selected your campaign's edition and entered its description and previewed your campaign, before launching.</p>
<p> Thanks for Ungluing campaigns can't be launched until ebook files <a class="tabs1">have been loaded</a> and <a class="tabs2">a suggested contribution has been set </a></p>
{% endifequal %}
{% endif %}
</div>
{% endifequal %}

View File

@ -11,12 +11,12 @@
{% block doccontent %}
{% if admin %}
{% if edition.pk %}
<h2>Edit Edition / Add Ebook Links</h2>
<h2>Edit Edition / Add Ebook Links for <a href="{% url work edition.work.id %}">{{ edition.work }}</a></h2>
{% else %}
<h2>Create New Edition</h2>
{% endif %}
{% else %}
<h2>Add Ebook Links</h2>
<h2>Add Ebook Links for <a href="{% url work edition.work.id %}">{{ edition.work }}</a></h2>
{% endif %}
{% if admin %}

View File

@ -1,4 +1,4 @@
{{ supporter }} ({{ base_url }}{% url supporter supporter.username %}) has wished for a work you hold rights to, {{ work.title }} ({{ base_url }}{% url work work.id %}). Hooray! {% with work.num_wishes as num_wishes %}{% ifequal num_wishes 1 %}Your first ungluer!{% else %}There are now {{ num_wishes }} people wishing for this work.{% endifequal %}{% endwith %}
{{ supporter }} ({{ base_url }}{% url supporter supporter.username %}) has favorited for a work you hold rights to, {{ work.title }} ({{ base_url }}{% url work work.id %}). Hooray! {% with work.num_wishes as num_wishes %}{% ifequal num_wishes 1 %}Your first ungluer!{% else %}There are now {{ num_wishes }} people who have favorited this work.{% endifequal %}{% endwith %}
The Unglue.it team

View File

@ -5,5 +5,5 @@
{% endblock %}
{% block comments_graphical %}
<a href="{% url supporter supporter %}">{{ supporter }}</a> has wished for a work you hold rights to, <a href="{% url work work.id %}?tab=2">{{ work.title }}</a>. Hooray!
<a href="{% url supporter supporter %}">{{ supporter }}</a> has favorited a work you hold rights to, <a href="{% url work work.id %}?tab=2">{{ work.title }}</a>. Hooray!
{% endblock %}

View File

@ -1,3 +1,3 @@
{{ supporter }} has wished for a work you hold rights to, {{ work.title }}. Hooray! There are now {{ work.num_wishes }} people wishing for this work.
{{ supporter }} has favorited for a work you hold rights to, {{ work.title }}. Hooray! There are now {{ work.num_wishes }} people who have favorited this work.

View File

@ -127,7 +127,7 @@
<li class="last">
{% if request.user.profile.libraries %}
<label for="offer_{{offer.id}}">
<input type="radio" name="offer_id" id="offer_{{offer.id}}" value="{{offer.id}}" {% ifequal request.REQUEST.offer_id offer.id|stringformat:"s" %}checked="checked"{% else %} {% ifequal offer_id offer.id %}checked="checked"{% endifequal %}{% endifequal %} />
<input type="radio" name="offer_id" id="offer_{{offer.id}}" value="{{offer.id}}" {% ifequal request.REQUEST.offer_id offer.id|stringformat:"s" %}checked="checked"{% else %} {% ifequal offer_id offer.id %}checked="checked"{% else %} {% if user.library %}checked="checked"{% endif %}{% endifequal %}{% endifequal %} />
<span class="menu-item-price">
${{ offer.price|intcomma }}
</span>

View File

@ -1502,20 +1502,9 @@ class FundCompleteView(TemplateView):
# should be 403 -- but let's try 404 for now -- 403 exception coming in Django 1.4
raise Http404
# check that the user had not already approved the transaction
# do we need to first run PreapprovalDetails to check on the status
# is it of type=PAYMENT_TYPE_AUTHORIZATION and status is NONE or ACTIVE (but approved is false)
if transaction.type == PAYMENT_TYPE_AUTHORIZATION:
correct_transaction_type = True
else:
correct_transaction_type = False
# add the work corresponding to the Transaction on the user's wishlist if it's not already on the wishlist
# fire add-wishlist notification if needed
if transaction.user is not None and correct_transaction_type and (campaign is not None) and (work is not None):
# ok to overwrite Wishes.source?
if transaction.user is not None and (campaign is not None) and (work is not None):
transaction.user.wishlist.add_work(work, 'pledging', notify=True)
else:
#put info into session for download page to pick up.

View File

@ -108,7 +108,8 @@ class CreateLibraryView(BaseLibraryView, CreateView):
user.save()
form.instance.user = user
form.instance.save()
form.instance.add_user(user)
form.instance.add_user(user) # library is a member of itself
form.instance.add_user(self.request.user) # library.owner is a member of library
context_data = self.get_context_data(form=form)
context_data['status'] = 'Library Updated'
return HttpResponseRedirect(reverse('library_admin',args=[form.instance.id]))

View File

@ -73,7 +73,7 @@ class Transaction(models.Model):
# a preapproval key that Paypal generates to identify this transaction
preapproval_key = models.CharField(max_length=128, null=True)
# (RY is not sure what receipt is for)
# (RY is not sure what receipt is for; t4u has hijacked this to be an email address for user.is_anonymous to send a receipt to)
receipt = models.CharField(max_length=256, null=True)
# whether a Preapproval has been approved or not

File diff suppressed because one or more lines are too long

View File

@ -997,14 +997,16 @@ li.checked {
line-height: 30px;
font-size: @font-size-larger;
}
#begblock {
#askblock {
float:right;
width:280px;
min-width:260px;
background: @pale-blue;
padding: 10px;
width:30%
}
.rh_beg {
.rh_ask {
font-size: @font-size-larger;
width:65%;
}
#contribsubmit {
text-align: center;