Merge branch 'pledged_badges' of github.com:Gluejar/regluit into pledged_badges
commit
5b19d7e765
|
@ -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
|
||||
---------------
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
@ -973,13 +985,29 @@ class UserProfile(models.Model):
|
|||
goodreads_auth_secret = models.TextField(null=True, blank=True)
|
||||
goodreads_user_link = models.CharField(max_length=200, null=True, blank=True)
|
||||
|
||||
class Badge(models.Model):
|
||||
name = models.CharField(max_length=72, blank=True)
|
||||
description = models.TextField(default='', null=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)
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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'))
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.4 KiB |
Loading…
Reference in New Issue