Merge branch 'master' into relaunch_ry

pull/1/head
Raymond Yee 2012-10-04 09:35:54 -07:00
commit 5df3ab23ab
20 changed files with 221 additions and 66 deletions

View File

@ -99,7 +99,15 @@
"model": "core.badge",
"fields": {
"name": "pledger",
"description": "has made a pledge in at least one ungluing campaign"
"description": "a pledger"
}
},
{
"pk": 2,
"model": "core.badge",
"fields": {
"name": "pledger2",
"description": "a repeat pledger"
}
}
]

View File

@ -5,6 +5,6 @@ from django.contrib.auth.models import User
class OwnerLookup(ModelLookup):
model = User
search_field = 'username__icontains'
search_fields = ('username__icontains',)
registry.register(OwnerLookup)

View File

@ -0,0 +1,34 @@
"""
set the 'pledged' badge for people who've pledged
"""
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from regluit.core.models import Badge
from regluit.payment.models import Transaction
class Command(BaseCommand):
help = "for people who've pledged, give them a badge!"
def handle(self, **options):
pledger= Badge.objects.get(name='pledger')
pledger2= Badge.objects.get(name='pledger2')
print 'start'
print 'pledger badges: %s' % pledger.holders.all().count()
print 'pledger2 badges: %s' % pledger2.holders.all().count()
pledges=Transaction.objects.exclude(status='NONE').exclude(status='Canceled',reason=None).exclude(anonymous=True)
for pledge in pledges:
if pledge.user.profile.badges.all().count():
if pledge.user.profile.badges.all()[0].id == pledger.id:
pledge.user.profile.badges.remove(pledger)
pledge.user.profile.badges.add(pledger2)
else:
pledge.user.profile.badges.add(pledger)
print 'end'
print 'pledger badges: %s' % pledger.holders.all().count()
print 'pledger2 badges: %s' % pledger2.holders.all().count()

View File

@ -957,6 +957,25 @@ 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
def pledger():
if not pledger.instance:
pledger.instance = Badge.objects.get(name='pledger')
return pledger.instance
pledger.instance=None
def pledger2():
if not pledger2.instance:
pledger2.instance = Badge.objects.get(name='pledger2')
return pledger2.instance
pledger2.instance=None
class UserProfile(models.Model):
created = models.DateTimeField(auto_now_add=True)
user = models.OneToOneField(User, related_name='profile')
@ -972,12 +991,23 @@ 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)
class Badge(models.Model):
name = models.CharField(max_length=72, blank=True)
description = models.TextField(default='', null=True)
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())
@property
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)

View File

@ -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,11 @@ pledge_modified.connect(handle_pledge_modified)
def handle_you_have_pledged(sender, transaction=None, **kwargs):
if transaction==None:
return
#give user a badge
if not transaction.anonymous:
transaction.user.profile.reset_pledge_badge()
notification.queue([transaction.user], "pledge_you_have_pledged", {
'site':Site.objects.get_current(),
'transaction': transaction

View File

@ -307,7 +307,7 @@ class CampaignPledgeForm(forms.Form):
decimal_places=2,
label="Pledge Amount",
)
anonymous = forms.BooleanField(required=False, label=_("Don't display my name in the acknowledgements"))
anonymous = forms.BooleanField(required=False, label=_("Make this pledge anonymous, please"))
ack_name = forms.CharField(required=False, max_length=64, label=_("What name should we display?"))
ack_dedication = forms.CharField(required=False, max_length=140, label=_("Your dedication:"))

View File

@ -214,13 +214,14 @@ Please fix the following before launching your campaign:
<p>{{ form.paypal_receiver.errors }}{{ form.paypal_receiver }}</p>
{% if not is_preview or request.user.is_staff %}
{% ifequal campaign_status 'ACTIVE' %}
{% ifequal campaign_status 'ACTIVE' %}
<div class="yikes">When you click this button, your changes will be visible to supporters immediately. Make sure to proofread!</div><br />
<input type="submit" name="save" value="Modify Campaign" />
{% else %}
{% else %}
<br /><br /><input type="submit" name="save" value="Save Campaign" />
{% endifequal %}
{% endifequal %}
{% if not is_preview or request.user.is_staff %}
{% if campaign_status == 'INITIALIZED' %}
<input id="campaign_launcher" type="submit" name="launch" value="Launch Campaign" />
{% endif %}
@ -240,7 +241,6 @@ Please fix the following before launching your campaign:
<span class="menu-item-price">${{ premium.amount|intcomma }}</span>
<span class="menu-item-desc">{{ premium.description }}</span>
</i>
{% if premium.type %}<span class="custom-premium"> <br />Type: {{ premium.get_type_display }}</span>{% endif %}
{% ifnotequal premium.limit 0 %}<br />Limit: {{ premium.limit }}{% endifnotequal %}
{% ifequal premium.type 'CU' %}<br />Deactivate? <input type="checkbox" name="premium_id" value="{{ premium.id }}" />{% endifequal %}
</li>
@ -251,9 +251,7 @@ Please fix the following before launching your campaign:
{% endif %}
</form>
</div>
<h4>Editing premiums</h4>
<p>At this time, you can't edit a premium you've created. But you can deactivate a premium and add a new one to replace it. So be sure to double-check your spelling before adding it.</p>
<h4>Add a custom premium for this campaign</h4>
<h4>Add a premium for this campaign</h4>
<form action="#" method="POST">
{% csrf_token %}
Pledge Amount: {{ premium_form.amount.errors }}${{ premium_form.amount }}<br />
@ -264,6 +262,8 @@ Please fix the following before launching your campaign:
<br />
<input type="submit" name="add_premium" value="Add Premium" />
</form>
<h4>Editing premiums</h4>
<p>At this time, you can't edit a premium you've created. But you can deactivate a premium and add a new one to replace it. So be sure to double-check your spelling before adding it.</p>
</div>
{% ifequal campaign_status 'INITIALIZED' %}

View File

@ -96,10 +96,11 @@
<div class="pledge_amount clearfix" id="mandatory_premiums">
<div>Depending on your pledge amount, you'll also get these acknowledgements.</div>
<div class="ack_active"><div class="ack_level">Any amount</div><div class="ack_header">The unglued ebook will be delivered to your inbox.</div></div>
<div id="ack_name" class="ack_inactive"><div class="ack_level">$25+</div><div class="ack_header">You'll be listed on the acknowledgements page of the unglued ebook<span id="ack_section"></span>.&nbsp;{{ form.ack_name.label_tag }} {{ form.ack_name.errors }}{{ form.ack_name }}<div id="anonbox"><I>{{ form.anonymous.label_tag }}</I> {{ form.anonymous.errors }}{{ form.anonymous }}</div></div></div>
<div id="ack_name" class="ack_inactive"><div class="ack_level">$25+</div><div class="ack_header">You'll be listed on the acknowledgements page of the unglued ebook<span id="ack_section"></span>.&nbsp;{{ form.ack_name.label_tag }} {{ form.ack_name.errors }}{{ form.ack_name }}</div></div>
<div id="ack_link" class="ack_inactive"><div class="ack_level">$50+</div><div class="ack_header">Your acknowledgement will link to your Unglue.it supporter page.{{ form.ack_link }}</div></div>
<div id="ack_dedication" class="ack_inactive"><div class="ack_level">$100+</div><div class="ack_header">Your acknowledgement can include a dedication (140 characters max).&nbsp;{{ form.ack_dedication.label_tag }} {{ form.ack_dedication.errors }}{{ form.ack_dedication }}</div></div>
</div>
<div id="anonbox"><I>{{ form.anonymous.label_tag }}</I> {{ form.anonymous.errors }}{{ form.anonymous }}</div>
<input name="pledge" type="submit" {% if faqmenu == 'modify' %}value="Modify Pledge"{% else %}value="Pledge Now"{% endif %} id="pledgesubmit" />
<input name="decoy" type="submit" id="fakepledgesubmit" disabled="disabled" />
{% comment %}

View File

@ -2,10 +2,10 @@
{% block title %}Tools for Rightsholders {% endblock %}
{% block extra_extra_head %}
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen">
<link href="/static/css/dj.selectable.css" type="text/css" media="all" rel="stylesheet" />
<link href="/static/selectable/css/dj.selectable.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="{{ jquery_home }}"></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<script type="text/javascript" src="/static/js/jquery.dj.selectable.js"></script>
<script type="text/javascript" src="/static/selectable/js/jquery.dj.selectable.js"></script>
{% endblock %}

View File

@ -22,8 +22,7 @@
var $j = jQuery.noConflict();
$j(document).ready(function(){
$j('#user-block-hide').hide();
$j('#user-block1 span').click(function() {
$j(this).toggleClass("active");
$j('#edit_profile').click(function() {
$j("#user-block-hide").slideToggle(300);
});
});
@ -66,8 +65,6 @@ function highlightTarget(targetdiv) {
{% comment %}
To do:
create topsection file for inclusion in multiple contexts, if needed
figure out how to configure date display
decide if we're even including date joined in profile
Goodreads
be sure words display correctlydja
do I need both add-wishlist and remove-wishlist classes? do they differ?
@ -91,46 +88,51 @@ there's no tab for seeing ALL my books, only the filters! huh.
<div class="js-topnews2">
<div class="js-topnews3">
<div class="user-block">
{% ifequal supporter request.user %}
<div id="user-block1">
<div class="block-inner">
<span class="my-setting">My Profile</span>
</div>
<div class="block-inner">
{% if supporter.profile.pic_url %}
<img class="user-avatar" src="{{ supporter.profile.pic_url }}" height="50" width="50" alt="Picture of {{ supporter }}" title="{{ supporter }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
<span class="user-name">
<a href="#">{{ supporter.username }}</a>
</span>
</div>
<span class="user-badges">
{% if supporter.profile.badges.all %}
{% for badge in supporter.profile.badges.all %}
<img src="{{ badge.path }}" alt="{{ badge.description }}" title="{{ badge.description }}" width="26px" height="26px" class="{{ badge.name }}" />
{% endfor %}
{% endif %}
</span>
</div>
<div class="user-block2">
{% if supporter.profile.pic_url %}
<img class="user-avatar" src="{{ supporter.profile.pic_url }}" height="50" width="50" alt="Picture of {{ supporter }}" title="{{ supporter }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
<span class="user-name"><a href="#">{{ supporter.username|truncatechars:20 }}</a></span>
<span class="user-date">{{ date }}</span>
<span class="user-short-info">{{ supporter.profile.tagline }}</span>
<span class="user-short-info">
{% with supporter.profile.tagline as tagline %}{% if tagline %}{{ tagline }}{% else %}&nbsp;{% endif %}{% endwith %}
</span>
</div>
{% else %}
<div id="user-block1">
<div class="block-inner">
{% if supporter.profile.pic_url %}
<img class="user-avatar" src="{{ supporter.profile.pic_url }}" height="50" width="50" alt="Picture of {{ supporter }}" title="{{ supporter }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
<span class="user-name"><a href="#">{{ supporter.username }}</a></span>
<span class="user-date">{{ date }}</span>
</div>
</div>
<div class="user-block2">
<span class="user-short-info">{% with supporter.profile.tagline as tagline %}{% if tagline %}{{ tagline }}{% else %}&nbsp;{% endif %}{% endwith %}</span>
</div>
{% endifequal %}
<div class="user-block3">
<div class="badges">
<span class="rounded"><span class="blue tabs1" {% ifequal request.user supporter %}title="I've unglued {{ backed }} {% if backed == 1 %}book{% else %}books{% endif %}."{% else %}title="{{ supporter }} has unglued {{ backed }} {% if backed == 1 %}book{% else %}books{% endif %}."{% endifequal %}><span class="hovertext">I've unglued&nbsp;</span>{{ backed }}</span></span>
<span class="rounded"><span class="orange tabs2" {% ifequal request.user supporter %}title="I'm supporting {{ backing }} {% if backing == 1 %}book{% else %}books{% endif %}."{% else %}title="{{ supporter }} is supporting {{ backing }} {% if backing == 1 %}book{% else %}books{% endif %}."{% endifequal %}><span class="hovertext">I'm ungluing&nbsp;</span>{{ backing }}</span></span>
<span class="rounded"><span class="grey tabs3" {% ifequal request.user supporter %}title="I'm wishing for {{ wished }} {% if wished == 1 %}book{% else %}books{% endif %}."{% else %}title="{{ supporter }} is wishing for {{ wished }} {% if wished == 1 %}book{% else %}books{% endif %}."{% endifequal %}><span class="hovertext">I'm wishing for&nbsp;</span>{{ wished }}</span></span>
{% ifequal request.user supporter %}
<span class="rounded"><span class="blue tabs1" title="I've unglued {{ backed }} {% if backed == 1 %}book{% else %}books{% endif %}."><span class="hovertext">I've unglued&nbsp;</span>{{ backed }}</span></span>
<span class="rounded"><span class="orange tabs2" title="I'm supporting {{ backing }} {% if backing == 1 %}book{% else %}books{% endif %}."><span class="hovertext">I'm ungluing&nbsp;</span>{{ backing }}</span></span>
<span class="rounded"><span class="grey tabs3" title="I'm wishing for {{ wished }} {% if wished == 1 %}book{% else %}books{% endif %}."><span class="hovertext">I'm wishing for&nbsp;</span>{{ wished }}</span></span>
{% else %}
<span class="rounded"><span class="blue tabs1" title="{{ supporter }} has unglued {{ backed }} {% if backed == 1 %}book{% else %}books{% endif %}."><span class="hovertext">has unglued&nbsp;</span>{{ backed }}</span></span>
<span class="rounded"><span class="orange tabs2" title="{{ supporter }} is supporting {{ backing }} {% if backing == 1 %}book{% else %}books{% endif %}."><span class="hovertext">is ungluing&nbsp;</span>{{ backing }}</span></span>
<span class="rounded"><span class="grey tabs3" title="{{ supporter }} is wishing for {{ wished }} {% if wished == 1 %}book{% else %}books{% endif %}."><span class="hovertext">is wishing for&nbsp;</span>{{ wished }}</span></span>
{% endifequal %}
</div>
</div>
<div class="user-block4">
{% ifequal request.user supporter %}
<div id="edit_profile">
<img src="/static/images/header/icon-edit.png" alt="Edit Your Profile" title="Edit Your Profile" />
</div>
{% endifequal %}
<div class="social">
{% if supporter.profile.home_url %}
<a href="{{ supporter.profile.home_url }}" class="nounderline">

View File

@ -422,7 +422,7 @@ def manage_campaign(request, id):
'form':form,
'problems': campaign.problems,
'alerts': alerts,
'premiums' : campaign.effective_premiums(),
'premiums' : campaign.custom_premiums(),
'premium_form' : new_premium_form,
'work': work,
'activetab': activetab,
@ -1349,8 +1349,6 @@ def supporter(request, supporter_username, template_name):
else:
activetab = "#3"
date = supporter.date_joined.strftime("%B %d, %Y")
# following block to support profile admin form in supporter page
if request.user.is_authenticated() and request.user.username == supporter_username:
@ -1406,7 +1404,6 @@ def supporter(request, supporter_username, template_name):
"backed": backed,
"backing": backing,
"wished": wished,
"date": date,
"profile_form": profile_form,
"ungluers": userlists.other_users(supporter, 5 ),
"goodreads_auth_url": reverse('goodreads_auth'),

View File

@ -351,6 +351,10 @@ 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')
p = PaymentManager()
results = p.query_campaign(c,campaign_total=True, summary=False)
self.assertEqual(results[0].amount, D('12.34'))

View File

@ -33,6 +33,12 @@ CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_CONFIGS = {
'default': {
'width': 700,
'toolbar': [
['Cut','Copy','Paste', 'PasteFromWord', '-', 'Undo', 'Redo', '-', 'Source'],
['Bold', 'Italic', '-', 'NumberedList','BulletedList', '-','Blockquote'],
['Find','Replace','-', 'Scayt'],
['Link', 'Unlink', '-', 'Image', 'HorizontalRule']
],
},
}
@ -286,4 +292,4 @@ MAINTENANCE_IGNORE_URLS = {}
class NONPROFIT:
is_on = True
name = 'Library Renewal'
link = 'http://127.0.0.1:8000/donate_to_campaign/'
link = 'http://127.0.0.1:8000/donate_to_campaign/'

View File

@ -213,3 +213,10 @@ span.menu-item-price {
border: none;
cursor: default;
}
#anonbox {
margin-top: 10px;
background: #edf3f4;
float: left;
width: 48%;
padding: 1%;
}

View File

@ -154,6 +154,7 @@
#user-block1 {
float: left;
width: 25%;
position: relative;
}
.user-block2 {
color: #6994a3;
@ -195,9 +196,34 @@ img.user-avatar {
-webkit-border-radius: 7px;
border-radius: 7px;
}
.user-badges {
position: absolute;
bottom: 0;
left: 60px;
}
.user-badges img {
vertical-align: text-bottom;
border: 1px solid #D4D4D4;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.social {
width: 100%;
}
#edit_profile {
float: right;
margin-top: -12px;
margin-right: -5px;
border: 2px solid white;
padding: 3px 2px 2px 3px;
}
#edit_profile:hover {
border: 2px solid #8dc63f;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
span.special-user-name {
display: block;
font-size: 19px;
@ -207,7 +233,6 @@ span.special-user-name {
height: 50px;
}
span.user-name,
span.user-date,
span.user-short-info {
display: block;
}
@ -313,10 +338,10 @@ span.my-setting {
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border-radius: 7px;
height: 50px;
line-height: 50px;
height: 40px;
line-height: 40px;
display: block;
padding: 0 0 0 10px;
padding: 0 0 10px 10px;
font-size: 19px;
font-weight: bold;
cursor: pointer;

BIN
static/images/pledger.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/images/pledger2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -142,4 +142,12 @@ span.menu-item-price {
#id_ack_link {
border: none;
cursor: default;
}
#anonbox {
margin-top: 10px;
background: @pale-blue;
float: left;
width: 48%;
padding: 1%;
}

View File

@ -77,6 +77,7 @@
#user-block1 {
float:left;
width:25%;
position: relative;
}
.user-block2 {
@ -121,10 +122,35 @@ img.user-avatar {
.one-border-radius(7px);
}
.user-badges {
position: absolute;
bottom: 0;
left: 60px;
img {
vertical-align:text-bottom;
border:1px solid #d4d4d4;
.one-border-radius(5px);
}
}
}
.social {
width:100%;
}
#edit_profile {
float: right;
margin-top: -12px;
margin-right: -5px;
border: 2px solid white;
padding: 3px 2px 2px 3px;
&:hover {
border: 2px solid @call-to-action;
.one-border-radius(5px);
}
}
span.special-user-name {
display: block;
font-size: @font-size-header;
@ -135,7 +161,6 @@ span.special-user-name {
}
span.user-name,
span.user-date,
span.user-short-info {
display: block;
}
@ -234,9 +259,9 @@ input.profile-save {
span.my-setting {
background:@blue-grey url("@{image-base}header/explane.png") 90% center no-repeat;
.one-border-radius(7px);
.height(50px);
.height(40px);
display:block;
padding:0 0 0 10px;
padding:0 0 10px 10px;
font-size: @font-size-header;
font-weight: bold;
cursor:pointer;

View File

@ -11,6 +11,7 @@
@bright-blue: #8ac3d7;
@alert: #e35351;
@orange: #e18551;
@yellow: #efd45e;
@image-base: "/static/images/";
@background-header: "@{image-base}bg.png";
@background-body: "@{image-base}bg-body.png";