Revert "wired badge awarding into pledge modified and pledge complete signals"

This reverts commit 759e39f61d.
pull/1/head
eric 2012-10-03 08:56:29 -04:00
parent e4cccc277f
commit 863055c305
3 changed files with 8 additions and 47 deletions

View File

@ -956,18 +956,6 @@ 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')
@ -983,32 +971,16 @@ 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)
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)
goodreads_user_link = models.CharField(max_length=200, null=True, blank=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)
class Badge(models.Model):
name = models.CharField(max_length=72, blank=True)
description = models.TextField(default='', null=True)
@property
def pledge_count(self):
return self.user.transaction_set.exclude(status='NONE').exclude(status='Canceled',reason=None).exclude(anonymous=True).count()
def path(self):
return '/static/images/%s.png' % self.name
#class CampaignSurveyResponse(models.Model):
# # generic
# campaign = models.ForeignKey("Campaign", related_name="surveyresponse", null=False)

View File

@ -177,8 +177,6 @@ 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,
@ -192,10 +190,6 @@ 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

View File

@ -14,6 +14,7 @@ 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
@ -351,12 +352,6 @@ 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'))