diff --git a/core/models.py b/core/models.py
index 0866ae10..065e6941 100755
--- a/core/models.py
+++ b/core/models.py
@@ -973,6 +973,7 @@ def pledger():
pledger.instance = Badge.objects.get(name='pledger')
return pledger.instance
pledger.instance=None
+
def pledger2():
if not pledger2.instance:
pledger2.instance = Badge.objects.get(name='pledger2')
@@ -1019,6 +1020,7 @@ class UserProfile(models.Model):
return None
else:
return accounts[0]
+
@property
def old_account(self):
accounts = self.user.account_set.filter(date_deactivated__isnull=False).order_by('-date_deactivated')
@@ -1030,7 +1032,32 @@ class UserProfile(models.Model):
@property
def pledges(self):
return self.user.transaction_set.filter(status=TRANSACTION_STATUS_ACTIVE)
+
+ @property
+ def last_transaction(self):
+ from regluit.payment.models import Transaction
+ try:
+ return Transaction.objects.filter(user=self.user).order_by('-date_modified')[0]
+ except IndexError:
+ return None
+ @property
+ def ack_name(self):
+ # use preferences from last transaction, if any
+ last = self.last_transaction
+ if last and last.ack_name:
+ return last.ack_name
+ else:
+ return self.user.username
+
+ @property
+ def anon_pref(self):
+ # use preferences from last transaction, if any
+ last = self.last_transaction
+ if last:
+ return last.anonymous
+ else:
+ return None
#class CampaignSurveyResponse(models.Model):
# # generic
diff --git a/frontend/templates/pledge.html b/frontend/templates/pledge.html
index 84173b09..65a1924c 100644
--- a/frontend/templates/pledge.html
+++ b/frontend/templates/pledge.html
@@ -8,6 +8,7 @@
+
{% endblock %}
{% block news %}
@@ -125,14 +126,7 @@
{% if faqmenu == 'modify' %}We hope you won't, but of course you're also free to
cancel your pledge.{% endif %}
{{ request.user.username }}
-{% if transaction.ack_name %}
-{{ transaction.ack_name }}
-{% else %}
-{{ request.user.username }}
-{% endif %}
-{{ transaction.ack_link }}
-{{ transaction.ack_dedication }}
-{{ transaction.anonymous }}
+
{% endblock %}
diff --git a/frontend/views.py b/frontend/views.py
index ff3e7eff..b8032103 100755
--- a/frontend/views.py
+++ b/frontend/views.py
@@ -644,15 +644,18 @@ class PledgeView(FormView):
transactions = self.campaign.transactions().filter(user=self.request.user, status=TRANSACTION_STATUS_ACTIVE, type=PAYMENT_TYPE_AUTHORIZATION)
premium_id = self.request.REQUEST.get('premium_id', 150)
if transactions.count() == 0:
- ack_name=''
+ ack_name=self.request.user.profile.ack_name
ack_dedication=''
- anonymous=''
+ anonymous=self.request.user.profile.anon_pref
else:
self.transaction = transactions[0]
if premium_id == 150 and self.transaction.premium is not None:
premium_id = self.transaction.premium.id
- ack_name=self.transaction.ack_name
- ack_dedication=self.transaction.ack_dedication
+ if self.transaction.ack_name:
+ ack_name = self.transaction.ack_name
+ else:
+ ack_name = self.request.user.profile.ack_name
+ ack_dedication = self.transaction.ack_dedication
anonymous=self.transaction.anonymous
self.data = {'preapproval_amount':self.get_preapproval_amount(), 'premium_id':premium_id,
diff --git a/static/js/reconcile_pledge.js b/static/js/reconcile_pledge.js
index 551ab007..a85a83d8 100644
--- a/static/js/reconcile_pledge.js
+++ b/static/js/reconcile_pledge.js
@@ -12,19 +12,17 @@ $j().ready(function() {
var anonbox = $j('#anonbox input');
var ackSection = $j('#ack_section');
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();
+ var ackName = $j('#id_ack_name').val();
+ var ackDedication = $j('#id_ack_dedication').val();
if(ackDedication == 'None') {
ackDedication = '';
}
var acks = {
ack_name: ackName,
- ack_link: ackLink,
ack_dedication: ackDedication
};
- var ackAnon = $j('#pass_anon').html();
+ var ackAnon = $j('#id_anonymous').val();
// we're not letting people submit arbitrary links
$j('#id_ack_link').attr('disabled', 'disabled');
@@ -75,17 +73,11 @@ $j().ready(function() {
// fill mandatory premium link input with supporter page
var activateLink = function() {
$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);
- }
}
// empty mandatory premium link
var deactivateLink = function() {
$j('#ack_link').removeClass('ack_active').addClass('ack_inactive');
- $j('input#id_ack_link').val('');
}
var anonymizeName = function() {