From 2216369bbfea9d38bfdddcd721d7aa5bf0ddd5d9 Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Tue, 18 Sep 2012 10:16:08 -0400 Subject: [PATCH 1/6] include clickable links, make grammar singular/plural sensitive --- core/signals.py | 3 ++- frontend/templates/notification/new_wisher/full.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/signals.py b/core/signals.py index 919289aa..ae82d8a3 100644 --- a/core/signals.py +++ b/core/signals.py @@ -222,7 +222,8 @@ def handle_wishlist_added(supporter, work, **kwargs): if claim: notification.queue([claim[0].user], "new_wisher", { 'supporter': supporter, - 'work': work + 'work': work, + 'base_url': settings.BASE_URL, }, True) from regluit.core.tasks import emit_notifications diff --git a/frontend/templates/notification/new_wisher/full.txt b/frontend/templates/notification/new_wisher/full.txt index 56b6fe04..c84f7c27 100644 --- a/frontend/templates/notification/new_wisher/full.txt +++ b/frontend/templates/notification/new_wisher/full.txt @@ -1,4 +1,4 @@ -{{ 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 }} ({{ 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 %}{% if num_wishes = 1 %}Your first ungluer!{% else %}There are now {{ num_wishes }} people wishing for this work.{% endif %}{% endwith %} The Unglue.it team \ No newline at end of file From 22106d4112e8546abbb3543a77ed14d21ca5badf Mon Sep 17 00:00:00 2001 From: Raymond Yee Date: Sun, 30 Sep 2012 08:44:25 -0700 Subject: [PATCH 2/6] r.content already encoded --> so r.content.encode('utf-8') is wrong -- doesn't cause exception if sys default encoding is UTF-8 -- but problematic if default is ASCII --- core/goodreads.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/goodreads.py b/core/goodreads.py index 03e12c04..bd7a2e2a 100644 --- a/core/goodreads.py +++ b/core/goodreads.py @@ -168,7 +168,7 @@ class GoodreadsClient(object): if r.status_code != httplib.OK: raise GoodreadsException('Error in review_list_unauth, http status_code: {0}'.format(r.status_code)) else: - doc = ET.fromstring(r.content.encode('utf-8')) + doc = ET.fromstring(r.content) # for the moment convert to a iterable of book data presented as dict -- one the way to paging through all results reviews = doc.findall('reviews/review') for review in reviews: From 4a15cc5ce7ad04266ee8772ea9e9faca3e0eda44 Mon Sep 17 00:00:00 2001 From: eric Date: Sun, 30 Sep 2012 18:05:15 -0400 Subject: [PATCH 3/6] added documentation for mysql path, removed hard encoding from goodreads#253 --- README.md | 7 +++++++ core/goodreads.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 448d75d7..7b5aae1e 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,13 @@ Configure Terminal to automatically notice this at startup: Terminal –> Preferences –> Settings –> Shell Click "run command"; add `source ~/.bashrc` +If you get 'EnvironmentError: mysql_config not found' +edit the line ~/.virtualenvs/regluit/build/MySQL-python/setup_posix.py +1. mysql_config.path = "mysql_config" +to be (using a path that exists on your system) +1. mysql_config.path = "/usr/local/mysql-5.5.20-osx10.6-x86_64/bin/mysql_config" + + Selenium Install --------------- diff --git a/core/goodreads.py b/core/goodreads.py index bd7a2e2a..a6e0cae0 100644 --- a/core/goodreads.py +++ b/core/goodreads.py @@ -250,7 +250,7 @@ class GoodreadsClient(object): raise GoodreadsException('Error in shelves_list: %s ' % (r.headers)) else: logger.info('headers: %s' % (r.headers)) - doc = ET.fromstring(r.content.encode('utf-8')) + doc = ET.fromstring(r.content) shelves = doc.find('shelves') # do a simple parsing to a dictionary From bf212ed1653d15a938d805c6dd22dcb2ea369038 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 1 Oct 2012 15:10:45 -0400 Subject: [PATCH 4/6] prettier stars matching site colors --- static/images/pledger.png | Bin 1038 -> 1375 bytes static/images/pledger2.png | Bin 1948 -> 1393 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/static/images/pledger.png b/static/images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Ooho{B?dmLnD^} zDD~Y(RdopLt|?Kk`(6N)6e!TrBHG%eff@kZl?GT%a_QV2E)R5PI^2jzbeR6DJuC>W zU_s4`AU5#aZ+xj#O@B*^XwA(^Hzn|Rt$(4Kq{!)Tf#oi){IQqISI-iQXKrOt-)I_d z0O&ezCdU&^Jr}#^3!h^_a0T})eF>+-O*|1TTC>bw1@xK{KsTDl<0$3iPwx_mW*_0| zsHU{n8g>jG&zb%7_q)s2=%T+9i$|X9zVIXcgXi$L0>l$h#D8c+a{@Xn7ohLj#q7{= zUDICOuzldzbn_dYyLud`KeQ)Urz!ot(P(&e=HY`9Rsj1=2~2gb@S7<0`cpfu9h_-y zZe#@4eAgP-q(t6EvC?Sf>0?F#Wwi75#?ZBWg}nC}!qVQ+=HG_m`I+X)oqj$47cR%B VkH4?54gdfE00>D%PDHLkV1jE$t_=VH From 99c228323e8e66d141ad9c47ff78a59e66295d60 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 1 Oct 2012 15:24:11 -0400 Subject: [PATCH 5/6] fix double toggle when clicking on star --- frontend/templates/supporter.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/templates/supporter.html b/frontend/templates/supporter.html index 8c8d4675..b57bbf4f 100644 --- a/frontend/templates/supporter.html +++ b/frontend/templates/supporter.html @@ -22,7 +22,7 @@ var $j = jQuery.noConflict(); $j(document).ready(function(){ $j('#user-block-hide').hide(); - $j('#user-block1 span').click(function() { + $j('#user-block1 > div > span').click(function() { $j(this).toggleClass("active"); $j("#user-block-hide").slideToggle(300); }); From 759e39f61d069dc1f691197e3d8d020929ff6d59 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 1 Oct 2012 18:28:26 -0400 Subject: [PATCH 6/6] wired badge awarding into pledge modified and pledge complete signals --- core/models.py | 42 +++++++++++++++++++++++++++++++++++------- core/signals.py | 6 ++++++ payment/tests.py | 7 ++++++- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/core/models.py b/core/models.py index 3b8ac711..cf18449f 100755 --- a/core/models.py +++ b/core/models.py @@ -944,6 +944,18 @@ class Wishes(models.Model): class Meta: db_table = 'core_wishlist_works' +class Badge(models.Model): + name = models.CharField(max_length=72, blank=True) + description = models.TextField(default='', null=True) + + @property + def path(self): + return '/static/images/%s.png' % self.name + + +pledger= Badge.objects.get(name='pledger') +pledger2= Badge.objects.get(name='pledger2') + class UserProfile(models.Model): created = models.DateTimeField(auto_now_add=True) user = models.OneToOneField(User, related_name='profile') @@ -959,16 +971,32 @@ class UserProfile(models.Model): goodreads_user_name = models.CharField(max_length=200, null=True, blank=True) goodreads_auth_token = models.TextField(null=True, blank=True) goodreads_auth_secret = models.TextField(null=True, blank=True) - goodreads_user_link = models.CharField(max_length=200, null=True, blank=True) + goodreads_user_link = models.CharField(max_length=200, null=True, blank=True) + + def add_pledge_badge(self): + #give user a badge + if self.badges.all().count(): + if self.badges.all()[0].id == pledger.id: + self.badges.remove(pledger) + self.badges.add(pledger2) + else: + self.badges.add(pledger) -class Badge(models.Model): - name = models.CharField(max_length=72, blank=True) - description = models.TextField(default='', null=True) + def reset_pledge_badge(self): + #count user pledges + n_pledges = self.pledge_count + if self.badges.exists(): + self.badges.remove(pledger) + self.badges.remove(pledger2) + if n_pledges == 1: + self.badges.add(pledger) + elif n_pledges > 1: + self.badges.add(pledger2) @property - def path(self): - return '/static/images/%s.png' % self.name - + def pledge_count(self): + return self.user.transaction_set.exclude(status='NONE').exclude(status='Canceled',reason=None).exclude(anonymous=True).count() + #class CampaignSurveyResponse(models.Model): # # generic # campaign = models.ForeignKey("Campaign", related_name="surveyresponse", null=False) diff --git a/core/signals.py b/core/signals.py index 03e3f869..f55628d7 100644 --- a/core/signals.py +++ b/core/signals.py @@ -177,6 +177,8 @@ def handle_pledge_modified(sender, transaction=None, up_or_down=None, **kwargs): # up_or_down is 'increased', 'decreased', or 'canceled' if transaction==None or up_or_down==None: return + if up_or_down == 'canceled': + transaction.user.profile.reset_pledge_badge() notification.queue([transaction.user], "pledge_status_change", { 'site':Site.objects.get_current(), 'transaction': transaction, @@ -190,6 +192,10 @@ pledge_modified.connect(handle_pledge_modified) def handle_you_have_pledged(sender, transaction=None, **kwargs): if transaction==None: return + + #give user a badge + transaction.user.profile.add_pledge_badge() + notification.queue([transaction.user], "pledge_you_have_pledged", { 'site':Site.objects.get_current(), 'transaction': transaction diff --git a/payment/tests.py b/payment/tests.py index c0236d33..e3ed2f42 100644 --- a/payment/tests.py +++ b/payment/tests.py @@ -14,7 +14,6 @@ from regluit.payment.models import Transaction from regluit.core.models import Campaign, Wishlist, Work from regluit.core.signals import handle_transaction_charged from regluit.payment.parameters import * -from regluit.payment.paypal import * import traceback from django.core.validators import URLValidator from django.core.exceptions import ValidationError @@ -352,6 +351,12 @@ class TransactionTest(TestCase): t.user = user t.save() + #test pledge adders + user.profile.reset_pledge_badge() + self.assertEqual(user.profile.badges.all()[0].name,'pledger') + user.profile.add_pledge_badge() + self.assertEqual(user.profile.badges.all()[0].name,'pledger2') + p = PaymentManager() results = p.query_campaign(c,campaign_total=True, summary=False) self.assertEqual(results[0].amount, D('12.34'))