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 03e12c04..a6e0cae0 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: @@ -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 diff --git a/core/models.py b/core/models.py index e3957964..7e62c7f0 100755 --- a/core/models.py +++ b/core/models.py @@ -956,6 +956,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') @@ -971,16 +983,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 fdab4099..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 @@ -223,7 +229,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 diff --git a/frontend/templates/supporter.html b/frontend/templates/supporter.html index b7913dac..7082c3bd 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); }); 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')) diff --git a/static/images/pledger.png b/static/images/pledger.png index ea7a7574..2ad3c001 100644 Binary files a/static/images/pledger.png and b/static/images/pledger.png differ diff --git a/static/images/pledger2.png b/static/images/pledger2.png index ce2c30c5..4f0d8194 100644 Binary files a/static/images/pledger2.png and b/static/images/pledger2.png differ