improving data flow of acks throughout system

pull/1/head
Andromeda Yelton 2012-08-06 15:44:43 -04:00
parent 8db1e5b59a
commit da0f4970c2
6 changed files with 49 additions and 47 deletions

View File

@ -386,17 +386,14 @@ class Campaign(models.Model):
translist = [] translist = []
for transaction in translist: for transaction in translist:
ungluers['all'].append(transaction.user) ungluers['all'].append(transaction.user)
if not transaction.anonymous: if transaction.anonymous:
anons += 1
if transaction.amount >= Premium.TIERS["bibliophile"]: if transaction.amount >= Premium.TIERS["bibliophile"]:
ungluers['bibliophiles'].append(transaction) ungluers['bibliophiles'].append(transaction)
elif transaction.amount >= Premium.TIERS["patron"]: elif transaction.amount >= Premium.TIERS["patron"]:
ungluers['patrons'].append(transaction) ungluers['patrons'].append(transaction)
elif transaction.amount >= Premium.TIERS["supporter"]: elif transaction.amount >= Premium.TIERS["supporter"]:
ungluers['supporters'].append(transaction) ungluers['supporters'].append(transaction)
else:
anons += 1
ungluers['anons'] = anons
return ungluers return ungluers

View File

@ -45,12 +45,9 @@
</dl> </dl>
</p> </p>
{% endif %} {% endif %}
{% if transactions.anons %}
<p>We also gratefully acknowledge the support of {{ transactions.anons }} anonymous ungluer{% if transactions.anons > 1 %}s{% endif %}.</p>
{% endif %}
{% endwith %} {% endwith %}
<p> <p>
You can say thank you by supporting the ungluing of more books at <a href="https://unglue.it/">https://unglue.it/</a> You can say thank you by supporting the ungluing of more books at <a href="https://unglue.it/">https://unglue.it/</a> .
</p> </p>
</section> </section>
<!-- trim here --> <!-- trim here -->

View File

@ -98,28 +98,6 @@
<div id="ack_name" class="ack_inactive"><div class="ack_level">$25+</div><div class="ack_header">You'll be acknowledged on the acknowledgements page of the unglued ebook<span id="ack_section"></span>.&nbsp;{{ form.ack_name.label_tag }} {{ form.ack_name.errors }}{{ form.ack_name }}<div id="anonbox"><I>{{ form.anonymous.label_tag }}</I> {{ form.anonymous.errors }}{{ form.anonymous }}</div></div></div> <div id="ack_name" class="ack_inactive"><div class="ack_level">$25+</div><div class="ack_header">You'll be acknowledged on the acknowledgements page of the unglued ebook<span id="ack_section"></span>.&nbsp;{{ form.ack_name.label_tag }} {{ form.ack_name.errors }}{{ form.ack_name }}<div id="anonbox"><I>{{ form.anonymous.label_tag }}</I> {{ form.anonymous.errors }}{{ form.anonymous }}</div></div></div>
<div id="ack_link" class="ack_inactive"><div class="ack_level">$50+</div><div class="ack_header">Your acknowledgement will link to your Unglue.it supporter page.{{ form.ack_link }}</div></div> <div id="ack_link" class="ack_inactive"><div class="ack_level">$50+</div><div class="ack_header">Your acknowledgement will link to your Unglue.it supporter page.{{ form.ack_link }}</div></div>
<div id="ack_dedication" class="ack_inactive"><div class="ack_level">$100+</div><div class="ack_header">Your acknowledgement can include a dedication (140 characters max).&nbsp;{{ form.ack_dedication.label_tag }} {{ form.ack_dedication.errors }}{{ form.ack_dedication }}</div></div> <div id="ack_dedication" class="ack_inactive"><div class="ack_level">$100+</div><div class="ack_header">Your acknowledgement can include a dedication (140 characters max).&nbsp;{{ form.ack_dedication.label_tag }} {{ form.ack_dedication.errors }}{{ form.ack_dedication }}</div></div>
{% comment %}
What this needs:
DONE fields for name (and anonymity), link, dedication (140 char limit)
selective highlighting/activation. if inactive, grey out and provide an indication of the amount ( "$50+" or "($50+)" ); remove indication when active
DONE "How would you like to be recognized on the supporters page?" or similar
DONE validation? how?
prefill name and link? how? (do NOT prefill dedication; make them commit to that) At any rate, this is a second-step problem.
A way to commit this to the db.
DONE: fields attached to transaction
- do we want to update supporter with a last-committed-name-and-link to allow prefilling?
- path from frontend through db field. add to existing form and use for validation? make sure everything is optional.
styling
Testing:
run tests
create tests pertaining to name/link/dedication. what?
scour for places transaction authorize() & pledge() happen
make sure they've all been fed needed data!
wire in support analogously to PledgeView, then ask raymond to check in on DonateView
make sure forms do something sensible when ack_name, etc., are empty
make sure to expose & handle anonymity checkbox
{% endcomment %}
</div> </div>
<input name="pledge" type="submit" {% if faqmenu == 'modify' %}value="Modify Pledge"{% else %}value="Pledge Now"{% endif %} id="pledgesubmit" /> <input name="pledge" type="submit" {% if faqmenu == 'modify' %}value="Modify Pledge"{% else %}value="Pledge Now"{% endif %} id="pledgesubmit" />
<input name="decoy" type="submit" id="fakepledgesubmit" disabled="disabled" /> <input name="decoy" type="submit" id="fakepledgesubmit" disabled="disabled" />
@ -131,7 +109,15 @@
</div> </div>
<div class="cancel_notice">(You will be sent to <b>{{ payment_processor|capfirst }}</b> <div class="cancel_notice">(You will be sent to <b>{{ payment_processor|capfirst }}</b>
{% if faqmenu == 'modify' %}, if needed, to modify your pledge. We hope you won't, but of course you're also free to <a href="{% url pledge_cancel campaign_id=work.last_campaign.id %}">cancel your pledge</a>{% else %} to complete your pledge.{% endif %}.)</div> {% if faqmenu == 'modify' %}, if needed, to modify your pledge. We hope you won't, but of course you're also free to <a href="{% url pledge_cancel campaign_id=work.last_campaign.id %}">cancel your pledge</a>{% else %} to complete your pledge.{% endif %}.)</div>
<div id="supporter_name" style="display: none;">{{ request.user.username }}</div> <div id="pass_supporter_name" style="display: none;">{{ request.user.username }}</div>
{% if transaction.ack_name %}
<div id="pass_ack_name" style="display: none;">{{ transaction.ack_name }}</div>
{% else %}
<div id="pass_ack_name" style="display: none;">{{ request.user.username }}</div>
{% endif %}
<div id="pass_ack_link" style="display: none;">{{ transaction.ack_link }}</div>
<div id="pass_ack_dedication" style="display: none;">{{ transaction.ack_dedication }}</div>
<div id="pass_anon" style="display: none;">{{ transaction.anonymous }}</div>
{% endblock %} {% endblock %}

View File

@ -761,6 +761,7 @@ class PledgeModifyView(FormView):
'faqmenu': 'modify', 'faqmenu': 'modify',
'tid': transaction.id, 'tid': transaction.id,
'payment_processor':settings.PAYMENT_PROCESSOR, 'payment_processor':settings.PAYMENT_PROCESSOR,
'transaction': transaction,
}) })
return context return context
@ -781,10 +782,10 @@ class PledgeModifyView(FormView):
work_id = self.kwargs["work_id"] work_id = self.kwargs["work_id"]
preapproval_amount = form.cleaned_data["preapproval_amount"] preapproval_amount = form.cleaned_data["preapproval_amount"]
anonymous = form.cleaned_data["anonymous"]
ack_name = form.cleaned_data["ack_name"] ack_name = form.cleaned_data["ack_name"]
ack_link = form.cleaned_data["ack_link"] ack_link = form.cleaned_data["ack_link"]
ack_dedication = form.cleaned_data["ack_dedication"] ack_dedication = form.cleaned_data["ack_dedication"]
anonymous = form.cleaned_data["anonymous"]
assert self.request.user.is_authenticated() assert self.request.user.is_authenticated()
user = self.request.user user = self.request.user
@ -811,7 +812,7 @@ class PledgeModifyView(FormView):
paymentReason = "Unglue.it Pledge for {0}".format(campaign.name) paymentReason = "Unglue.it Pledge for {0}".format(campaign.name)
status, url = p.modify_transaction(transaction=transaction, amount=preapproval_amount, premium=premium, status, url = p.modify_transaction(transaction=transaction, amount=preapproval_amount, premium=premium,
paymentReason=paymentReason, ack_name=ack_name, ack_link=ack_link, paymentReason=paymentReason, ack_name=ack_name, ack_link=ack_link,
ack_dedication=ack_dedication) ack_dedication=ack_dedication, anonymous=anonymous)
logger.info("status: {0}, url:{1}".format(status, url)) logger.info("status: {0}, url:{1}".format(status, url))

View File

@ -738,7 +738,7 @@ class PaymentManager( object ):
transaction.user, transaction.user,
return_url, return_url,
nevermind_url, nevermind_url,
transaction.anonymous, anonymous,
premium, premium,
paymentReason, paymentReason,
ack_name, ack_name,
@ -771,6 +771,9 @@ class PaymentManager( object ):
transaction.amount = amount transaction.amount = amount
transaction.anonymous = anonymous transaction.anonymous = anonymous
transaction.premium = premium transaction.premium = premium
transaction.ack_name = ack_name
transaction.ack_link = ack_link
transaction.ack_dedication = ack_dedication
transaction.save() transaction.save()
logger.info("Updated amount of transaction to %f" % amount) logger.info("Updated amount of transaction to %f" % amount)

View File

@ -11,12 +11,21 @@ $j().ready(function() {
var fakesubmitbutton = $j('#fakepledgesubmit'); var fakesubmitbutton = $j('#fakepledgesubmit');
var anonbox = $j('#anonbox input'); var anonbox = $j('#anonbox input');
var ackSection = $j('#ack_section'); var ackSection = $j('#ack_section');
var supporterName = $j('#supporter_name').html(); var supporterName = $j('#pass_supporter_name').html();
var ackName = $j('#pass_ack_name').html();
var ackLink = $j('#pass_ack_link').html();
var ackDedication = $j('#pass_ack_dedication').html();
if(ackDedication == 'None') {
ackDedication = '';
}
var acks = { var acks = {
ack_name: supporterName, ack_name: ackName,
ack_dedication: '' ack_link: ackLink,
ack_dedication: ackDedication
}; };
var ackAnon = $j('#pass_anon').html();
// we're not letting people submit arbitrary links // we're not letting people submit arbitrary links
$j('#id_ack_link').attr('disabled', 'disabled'); $j('#id_ack_link').attr('disabled', 'disabled');
@ -49,7 +58,7 @@ $j().ready(function() {
submitbutton.removeAttr('disabled'); submitbutton.removeAttr('disabled');
} }
// make mandatory premium input area active // make acknowledgements input area active
var activate = function(mySpan) { var activate = function(mySpan) {
$j('#'+mySpan).removeClass('ack_inactive').addClass('ack_active'); $j('#'+mySpan).removeClass('ack_inactive').addClass('ack_active');
$j('#'+mySpan+' input').removeAttr('disabled'); $j('#'+mySpan+' input').removeAttr('disabled');
@ -66,8 +75,12 @@ $j().ready(function() {
// fill mandatory premium link input with supporter page // fill mandatory premium link input with supporter page
var activateLink = function() { var activateLink = function() {
$j('#ack_link').removeClass('ack_inactive').addClass('ack_active'); $j('#ack_link').removeClass('ack_inactive').addClass('ack_active');
if(ackLink) {
$j('input#id_ack_link').val(ackLink);
} else {
$j('input#id_ack_link').val('https://unglue.it/supporter/'+supporterName); $j('input#id_ack_link').val('https://unglue.it/supporter/'+supporterName);
} }
}
// empty mandatory premium link // empty mandatory premium link
var deactivateLink = function() { var deactivateLink = function() {
@ -131,6 +144,11 @@ $j().ready(function() {
} else { } else {
rectifyAcknowledgements(0); rectifyAcknowledgements(0);
} }
if (ackAnon == 'True') {
anonymizeName();
deactivateLink();
anonbox.prop("checked", true);
}
// when user clicks a premium, ensure it is compatible with the pledge box amount // when user clicks a premium, ensure it is compatible with the pledge box amount
$j('#premiums_list input').on("click", function() { $j('#premiums_list input').on("click", function() {