diff --git a/branch.sql b/branch.sql new file mode 100644 index 0000000000..f8c05fab14 --- /dev/null +++ b/branch.sql @@ -0,0 +1,8 @@ +------------------------------------------------------------------------------- +-- https://github.com/gittip/www.gittip.com/issues/1683 + +BEGIN; + ALTER TABLE participants RENAME COLUMN anonymous TO anonymous_giving; + ALTER TABLE participants ADD COLUMN anonymous_receiving bool NOT NULL DEFAULT FALSE; + ALTER TABLE homepage_top_receivers ADD COLUMN anonymous boolean; +END; diff --git a/gittip/models/participant.py b/gittip/models/participant.py index 4677c087ca..e01a7e825b 100644 --- a/gittip/models/participant.py +++ b/gittip/models/participant.py @@ -674,9 +674,9 @@ def get_og_title(self): out = self.username receiving = self.get_dollars_receiving() giving = self.get_dollars_giving() - if (giving > receiving) and not self.anonymous: + if (giving > receiving) and not self.anonymous_giving: out += " gives $%.2f/wk" % giving - elif receiving > 0: + elif receiving > 0 and not self.anonymous_receiving: out += " receives $%.2f/wk" % receiving else: out += " is" diff --git a/gittip/testing/__init__.py b/gittip/testing/__init__.py index 099aa3d929..779f70b126 100644 --- a/gittip/testing/__init__.py +++ b/gittip/testing/__init__.py @@ -152,8 +152,12 @@ def make_participant(self, username, **kw): participant = Participant.with_random_username() participant.change_username(username) + return self.update_participant(participant, **kw) + + def update_participant(self, participant, **kw): if 'elsewhere' in kw or 'claimed_time' in kw: + username = participant.username platform = kw.pop('elsewhere', 'github') user_info = dict(login=username) self.seq += 1 diff --git a/gittip/utils/__init__.py b/gittip/utils/__init__.py index cfddc565f0..1ea281a918 100644 --- a/gittip/utils/__init__.py +++ b/gittip/utils/__init__.py @@ -365,8 +365,8 @@ def update_homepage_queries_once(db): cursor.execute("DELETE FROM homepage_top_givers") cursor.execute(""" - INSERT INTO homepage_top_givers - SELECT tipper AS username, anonymous, sum(amount) AS amount + INSERT INTO homepage_top_givers (username, anonymous, amount) + SELECT tipper, anonymous_giving, sum(amount) AS amount FROM ( SELECT DISTINCT ON (tipper, tippee) amount , tipper @@ -382,7 +382,7 @@ def update_homepage_queries_once(db): ) AS foo JOIN participants p ON p.username = tipper WHERE is_suspicious IS NOT true - GROUP BY tipper, anonymous + GROUP BY tipper, anonymous_giving ORDER BY amount DESC; """.strip()) @@ -408,8 +408,8 @@ def update_homepage_queries_once(db): cursor.execute("DELETE FROM homepage_top_receivers") cursor.execute(""" - INSERT INTO homepage_top_receivers - SELECT tippee AS username, claimed_time, sum(amount) AS amount + INSERT INTO homepage_top_receivers (username, anonymous, amount, claimed_time) + SELECT tippee, anonymous_receiving, sum(amount) AS amount, claimed_time FROM ( SELECT DISTINCT ON (tipper, tippee) amount , tippee @@ -424,7 +424,7 @@ def update_homepage_queries_once(db): ) AS foo JOIN participants p ON p.username = tippee WHERE is_suspicious IS NOT true - GROUP BY tippee, claimed_time + GROUP BY tippee, anonymous_receiving, claimed_time ORDER BY amount DESC; """.strip()) diff --git a/gittip/utils/fake_data.py b/gittip/utils/fake_data.py index 7fd8e499d1..299698c3a4 100644 --- a/gittip/utils/fake_data.py +++ b/gittip/utils/fake_data.py @@ -57,7 +57,7 @@ def fake_sentence(start=1, stop=100): return faker.sentence(random.randrange(start,stop)) -def fake_participant(db, number="singular", is_admin=False, anonymous=False): +def fake_participant(db, number="singular", is_admin=False): """Create a fake User. """ username = faker.first_name() + fake_text_id(3) @@ -70,7 +70,8 @@ def fake_participant(db, number="singular", is_admin=False, anonymous=False): , ctime=faker.date_time_this_year() , is_admin=is_admin , balance=fake_balance() - , anonymous=anonymous + , anonymous_giving=(random.randrange(5) == 0) + , anonymous_receiving=(random.randrange(5) == 0) , goal=fake_balance() , balanced_account_uri=faker.uri() , last_ach_result='' diff --git a/js/gittip/profile.js b/js/gittip/profile.js index a46ba6bfa2..da95f89f31 100644 --- a/js/gittip/profile.js +++ b/js/gittip/profile.js @@ -215,13 +215,34 @@ Gittip.profile.init = function() { // Wire up aggregate giving knob. // ============================== - $('.anonymous input').click(function() { + $('.anonymous-giving input').click(function() { jQuery.ajax( { url: 'anonymous.json' , type: 'POST' + , data: {toggle: 'giving'} , dataType: 'json' , success: function(data) { - $('.anonymous input').attr('checked', data.anonymous); + $('.anonymous-giving input').attr('checked', data.giving); + } + , error: function() { + alert("Failed to change your anonymity preference. Please try again."); + } + } + ); + }); + + + // Wire up aggregate receiving knob. + // ============================== + + $('.anonymous-receiving input').click(function() { + jQuery.ajax( + { url: 'anonymous.json' + , type: 'POST' + , data: {toggle: 'receiving'} + , dataType: 'json' + , success: function(data) { + $('.anonymous-receiving input').attr('checked', data.receiving); } , error: function() { alert("Failed to change your anonymity preference. Please try again."); diff --git a/js/gittip/tips.js b/js/gittip/tips.js index 877dbb02dd..4c49b6b0bf 100644 --- a/js/gittip/tips.js +++ b/js/gittip/tips.js @@ -85,11 +85,11 @@ Gittip.tips.init = function() { $myTip.change(); // update display - $('.total-giving').text(data.total_giving); + $('.my-total-giving').text('$'+data.total_giving); $('.total-receiving').text( // check and see if we are on our giving page or not new RegExp('/' + tippee + '/').test(window.location.href) ? - data.total_receiving_tippee : data.total_receiving); + '$'+data.total_receiving_tippee : '$'+data.total_receiving); // Increment an elsewhere receiver's "people ready to give" if(!oldAmount) diff --git a/templates/base.html b/templates/base.html index e10c2e1c8e..2db7768780 100644 --- a/templates/base.html +++ b/templates/base.html @@ -50,7 +50,10 @@