Merge pull request #301 from Gluejar/t4u_download

T4u download
pull/1/head
Raymond Yee 2014-03-03 17:31:05 -08:00
commit 3fb757b390
59 changed files with 809 additions and 458 deletions

View File

@ -22,7 +22,7 @@
</p>
<p>
Works can be ordered by how often they've been wishlisted; append &amp;order_by=num_wishes (ascending) or &amp;order_by=-num_wishes (descending).
Works can be ordered by how often they've been favorited; append &amp;order_by=num_wishes (ascending) or &amp;order_by=-num_wishes (descending).
</p>
{% if user.is_authenticated %}

View File

@ -61,6 +61,7 @@ from regluit.core.parameters import (
BORROWED,
TESTING,
RESERVE,
THANKED,
)
@ -277,11 +278,18 @@ class Offer(models.Model):
def days_per_copy(self):
return Decimal(float(self.price) / self.work.last_campaign().dollar_per_day )
@property
def get_thanks_display(self):
if self.license == LIBRARY:
return 'Suggested contribution for libraries'
else:
return 'Suggested contribution for individuals'
class Acq(models.Model):
"""
Short for Acquisition, this is a made-up word to describe the thing you acquire when you buy or borrow an ebook
"""
CHOICES = ((INDIVIDUAL,'Individual license'),(LIBRARY,'Library License'),(BORROWED,'Borrowed from Library'), (TESTING,'Just for Testing'), (RESERVE,'On Reserve'),)
CHOICES = ((INDIVIDUAL,'Individual license'),(LIBRARY,'Library License'),(BORROWED,'Borrowed from Library'), (TESTING,'Just for Testing'), (RESERVE,'On Reserve'),(THANKED,'Already Thanked'),)
created = models.DateTimeField(auto_now_add=True)
expires = models.DateTimeField(null=True)
refreshes = models.DateTimeField(auto_now_add=True, default=now())
@ -671,10 +679,14 @@ class Campaign(models.Model):
active_claim = self.work.claim.filter(status="active")[0]
except IndexError, e:
raise UnglueitError(_('Campaign needs to have an active claim in order to be activated'))
if not self.launchable:
raise UnglueitError('Configuration issues need to be addressed before campaign is activated: %s' % unicode(self.problems[0]))
self.status= 'ACTIVE'
self.left = self.target
self.activated = datetime.today()
if self.type == THANKS:
# make ebooks from ebookfiles
self.work.make_ebooks_from_ebfs()
self.save()
action = CampaignAction( campaign = self, type='activated', comment = self.get_type_display())
ungluers = self.work.wished_by()
@ -730,6 +742,11 @@ class Campaign(models.Model):
active = self.transactions().filter(status=TRANSACTION_STATUS_ACTIVE).values_list('user', flat=True).distinct().count()
complete = self.transactions().filter(status=TRANSACTION_STATUS_COMPLETE).values_list('user', flat=True).distinct().count()
return active+complete
@property
def anon_count(self):
# avoid transmitting the whole list if you don't need to; let the db do the count.
complete = self.transactions().filter(status=TRANSACTION_STATUS_COMPLETE,user=None).count()
return complete
def transaction_to_recharge(self, user):
"""given a user, return the transaction to be recharged if there is one -- None otherwise"""
@ -1172,7 +1189,24 @@ class Work(models.Model):
def ebookfiles(self):
# filter out non-epub because that's what booxtream accepts now
return EbookFile.objects.filter(edition__work=self, format='epub').order_by('-created')
def make_ebooks_from_ebfs(self):
if self.last_campaign().type != THANKS: # just to make sure that ebf's can be unglued by mistake
return
ebfs=EbookFile.objects.filter(edition__work=self).order_by('-created')
done_formats= []
for ebf in ebfs:
if ebf.format not in done_formats:
ebook=Ebook.objects.create(
edition=ebf.edition,
format=ebf.format,
rights=self.last_campaign().license,
provider="Unglue.it",
url= ebf.file.url,
)
done_formats.append(ebf.format)
return
@property
def download_count(self):
dlc=0
@ -1337,6 +1371,14 @@ class Work(models.Model):
else:
return purchases[0]
@property
def thanked(self):
purchases = self.acqs.filter(license=THANKED)
if purchases.count()==0:
return None
else:
return purchases[0]
@property
def lib_acqs(self):
return self.acqs.filter(license=LIBRARY)
@ -1365,7 +1407,7 @@ class Work(models.Model):
""" This is all the acqs, wrapped in user_license object for the work, user(s) """
if user==None:
return None
if isinstance(user, User):
if hasattr(user, 'is_anonymous'):
if user.is_anonymous():
return None
return self.user_license(self.acqs.filter(user=user))

View File

@ -1,3 +1,3 @@
(REWARDS, BUY2UNGLUE, THANKS) = (1, 2, 3)
(INDIVIDUAL, LIBRARY, BORROWED, RESERVE) = (1, 2, 3, 4)
(INDIVIDUAL, LIBRARY, BORROWED, RESERVE, THANKED) = (1, 2, 3, 4, 5)
TESTING = 0

View File

@ -20,6 +20,7 @@ from django.db.models.signals import post_save
from django.db.utils import DatabaseError
from django.dispatch import Signal
from django.utils.translation import ugettext_noop as _
from django.template.loader import render_to_string
from notification import models as notification
from social_auth.signals import pre_update
@ -30,7 +31,7 @@ regluit imports
"""
from regluit.payment.signals import transaction_charged, transaction_failed, pledge_modified, pledge_created
from regluit.utils.localdatetime import now, date_today
from regluit.core.parameters import REWARDS, BUY2UNGLUE, LIBRARY, RESERVE
from regluit.core.parameters import REWARDS, BUY2UNGLUE, THANKS, LIBRARY, RESERVE, THANKED
from regluit.libraryauth.models import Library, LibraryUser
logger = logging.getLogger(__name__)
@ -72,18 +73,18 @@ post_save.connect(create_api_key, sender=User)
def create_notice_types(app, created_models, verbosity, **kwargs):
notification.create_notice_type("comment_on_commented", _("Comment on Commented Work"), _("A comment has been received on a book that you've commented on."))
notification.create_notice_type("wishlist_comment", _("Book List Comment"), _("A comment has been received on one of your books."), default = 1)
notification.create_notice_type("wishlist_official_comment", _("Book List Comment"), _("The author or publisher, or and Unglue.it staffer, has commented on one of your books."))
notification.create_notice_type("wishlist_work_claimed", _("Rights Holder is Active"), _("A rights holder has shown up for a book that you want unglued."), default = 1)
notification.create_notice_type("wishlist_active", _("New Campaign"), _("A book you've wishlisted has a newly launched campaign."))
notification.create_notice_type("wishlist_official_comment", _("Book List Comment"), _("The author or publisher, or and Unglue.it staffer, has commented on one of your faves."))
notification.create_notice_type("wishlist_work_claimed", _("Rights Holder is Active"), _("A rights holder has shown up for a book that you've faved."), default = 1)
notification.create_notice_type("wishlist_active", _("New Campaign"), _("A book you've favorited has a newly launched campaign."))
notification.create_notice_type("wishlist_near_target", _("Campaign Near Target"), _("A book you want is near its ungluing target."))
notification.create_notice_type("wishlist_near_deadline", _("Campaign Near Deadline"), _("A book you want is almost out of time."))
notification.create_notice_type("wishlist_premium_limited_supply", _("Only a Few Premiums Left"), _("A limited edition premium is running out on a book you like."))
notification.create_notice_type("wishlist_successful", _("Successful Campaign"), _("An ungluing campaign that you have supported or followed has succeeded."))
notification.create_notice_type("wishlist_premium_limited_supply", _("Only a Few Premiums Left"), _("A limited edition premium is running out on a book you've faved."))
notification.create_notice_type("wishlist_successful", _("Successful Campaign"), _("An ungluing campaign that you have supported or faved has succeeded."))
notification.create_notice_type("wishlist_unsuccessful", _("Unsuccessful Campaign"), _("An ungluing campaign that you supported didn't succeed this time."))
notification.create_notice_type("wishlist_updated", _("Campaign Updated"), _("An ungluing campaign you support has been updated."), default = 1)
notification.create_notice_type("wishlist_message", _("Campaign Communication"), _("You have a private message from unglue.it staff or the rights holder about a book on your wishlist."))
notification.create_notice_type("wishlist_price_drop", _("Campaign Price Drop"), _("An ungluing campaign you're interested in has a reduced target."), default = 1)
notification.create_notice_type("wishlist_unglued_book_released", _("Unglued Book!"), _("A book you wanted is now available to be downloaded."))
notification.create_notice_type("wishlist_message", _("Campaign Communication"), _("You have a private message from unglue.it staff or the rights holder about a book you've faved."))
notification.create_notice_type("wishlist_price_drop", _("Campaign Price Drop"), _("An ungluing campaign you've faved has a reduced target."), default = 1)
notification.create_notice_type("wishlist_unglued_book_released", _("Unglued Book!"), _("A book you've faved is now available to be downloaded."))
notification.create_notice_type("pledge_you_have_pledged", _("Thanks For Your Pledge!"), _("Your ungluing pledge has been entered."))
notification.create_notice_type("pledge_status_change", _("Your Pledge Has Been Modified"), _("Your ungluing pledge has been modified."))
notification.create_notice_type("pledge_charged", _("Your Pledge has been Executed"), _("You have contributed to a successful ungluing campaign."))
@ -92,7 +93,7 @@ def create_notice_types(app, created_models, verbosity, **kwargs):
notification.create_notice_type("rights_holder_claim", _("Claim Entered"), _("A claim has been entered."))
notification.create_notice_type("wishlist_unsuccessful_amazon", _("Campaign shut down"), _("An ungluing campaign that you supported had to be shut down due to an Amazon Payments policy change."))
notification.create_notice_type("pledge_gift_credit", _("Gift Credit Balance"), _("You have a gift credit balance"))
notification.create_notice_type("new_wisher", _("New wisher"), _("Someone new has wished for a book that you're the rightsholder for"))
notification.create_notice_type("new_wisher", _("New wisher"), _("Someone new has faved a book that you're the rightsholder for"))
notification.create_notice_type("account_expiring", _("Credit Card Expiring Soon"), _("Your credit card is about to expire."))
notification.create_notice_type("account_expired", _("Credit Card Has Expired"), _("Your credit card has expired."))
notification.create_notice_type("account_active", _("Credit Card Number Updated"), _("Payment method updated."), default = 1)
@ -165,7 +166,7 @@ def handle_transaction_charged(sender,transaction=None, **kwargs):
transaction._current_total = None
if transaction.campaign.type is REWARDS:
notification.send([transaction.user], "pledge_charged", {'transaction':transaction}, True)
else:
elif transaction.campaign.type is BUY2UNGLUE:
# provision the book
Acq = get_model('core', 'Acq')
if transaction.offer.license == LIBRARY:
@ -185,8 +186,18 @@ def handle_transaction_charged(sender,transaction=None, **kwargs):
watermark_acq.delay(new_acq)
if transaction.campaign.cc_date < date_today() :
transaction.campaign.update_status(send_notice=True)
from regluit.core.tasks import emit_notifications
emit_notifications.delay()
elif transaction.campaign.type is THANKS:
if transaction.user:
Acq = get_model('core', 'Acq')
new_acq = Acq.objects.create(user=transaction.user, work=transaction.campaign.work, license=THANKED)
notification.send([transaction.user], "purchase_complete", {'transaction':transaction}, True)
elif transaction.receipt:
from regluit.core.tasks import send_mail_task
message = render_to_string("notification/purchase_complete/full.txt",{'transaction':transaction,'current_site':Site.objects.get_current()})
send_mail_task.delay('unglue.it transaction confirmation', message, 'notices@gluejar.com', [transaction.receipt])
if transaction.user:
from regluit.core.tasks import emit_notifications
emit_notifications.delay()
transaction_charged.connect(handle_transaction_charged)
@ -308,7 +319,6 @@ def notify_supporter_message(sender, work, supporter, msg, **kwargs):
"""send notification in of supporter message"""
logger.info('received supporter_message signal for {0}'.format(supporter))
site = Site.objects.get_current()
notification.send( [supporter], "wishlist_message", {'work':work, 'msg':msg}, True, sender)
from regluit.core.tasks import emit_notifications
emit_notifications.delay()

View File

@ -496,7 +496,7 @@ class CampaignTests(TestCase):
c1.save()
self.assertEqual(c1.status, 'INITIALIZED')
# ACTIVATED
c2 = Campaign(target=D('1000.00'),deadline=datetime(2013,1,1),work=w)
c2 = Campaign(target=D('1000.00'),deadline=datetime(2013,1,1),work=w,description='dummy description')
c2.save()
self.assertEqual(c2.status, 'INITIALIZED')
u = User.objects.create_user('claimer', 'claimer@example.org', 'claimer')
@ -519,7 +519,7 @@ class CampaignTests(TestCase):
# should not let me suspend a campaign that hasn't been initialized
self.assertRaises(UnglueitError, c1.suspend, "for testing")
# UNSUCCESSFUL
c3 = Campaign(target=D('1000.00'),deadline=now() - timedelta(days=1),work=w2)
c3 = Campaign(target=D('1000.00'),deadline=now() - timedelta(days=1),work=w2,description='dummy description')
c3.save()
c3.activate()
self.assertEqual(c3.status, 'ACTIVE')
@ -539,7 +539,7 @@ class CampaignTests(TestCase):
# SUCCESSFUL
c4 = Campaign(target=D('1000.00'),deadline=now() - timedelta(days=1),work=w)
c4 = Campaign(target=D('1000.00'),deadline=now() - timedelta(days=1),work=w,description='dummy description')
c4.save()
c4.activate()
t = Transaction()
@ -554,7 +554,7 @@ class CampaignTests(TestCase):
self.assertEqual(c4.status, 'SUCCESSFUL')
# WITHDRAWN
c5 = Campaign(target=D('1000.00'),deadline=datetime(2013,1,1),work=w)
c5 = Campaign(target=D('1000.00'),deadline=datetime(2013,1,1),work=w,description='dummy description')
c5.save()
c5.activate().withdraw('testing')
self.assertEqual(c5.status, 'WITHDRAWN')
@ -562,7 +562,7 @@ class CampaignTests(TestCase):
# testing percent-of-goal
w2 = Work()
w2.save()
c6 = Campaign(target=D('1000.00'),deadline=now() + timedelta(days=1),work=w2)
c6 = Campaign(target=D('1000.00'),deadline=now() + timedelta(days=1),work=w2,description='dummy description')
c6.save()
cl = Claim(rights_holder = rh, work = w2, user = u, status = 'active')
cl.save()
@ -852,6 +852,7 @@ class EbookFileTests(TestCase):
target = 1000,
deadline = datetime(2020,1,1),
license = 'CC BY',
description = "dummy description",
)
# download the test epub into a temp file
temp = NamedTemporaryFile(delete=False)
@ -883,6 +884,11 @@ class EbookFileTests(TestCase):
url= acq.get_watermarked().download_link_epub
self.assertRegexpMatches(url,'github.com/eshellman/42_ebook/blob/master/download/42')
#self.assertRegexpMatches(url,'booxtream.com/')
with self.assertRaises(UnglueitError) as cm:
c.activate()
off = Offer(price=10.00, work=w, active=True)
off.save()
c.activate()
#flip the campaign to success
c.cc_date_initial= datetime(2012,1,1)

View File

@ -571,6 +571,20 @@ class CampaignPurchaseForm(forms.Form):
pe.extra['copies']=self.cleaned_data.get('copies',1)
return pe
class CampaignThanksForm(forms.Form):
anonymous = forms.BooleanField(required=False, label=_("Make this contribution anonymous, please"))
preapproval_amount = forms.DecimalField(
required = False,
min_value=D('1.00'),
max_value=D('2000.00'),
decimal_places=2,
label="Pledge Amount",
)
@property
def trans_extra(self):
pe = PledgeExtra( anonymous=self.cleaned_data['anonymous'] )
class CampaignPledgeForm(forms.Form):
preapproval_amount = forms.DecimalField(
required = False,
@ -628,8 +642,7 @@ class CampaignPledgeForm(forms.Form):
class PlainCCForm(forms.Form):
stripe_token = forms.CharField(required=False, widget=forms.HiddenInput())
class CCForm(PlainCCForm):
username = forms.CharField(max_length=30, required=True, widget=forms.HiddenInput())
class BaseCCForm(PlainCCForm):
work_id = forms.IntegerField(required=False, widget=forms.HiddenInput())
preapproval_amount= forms.DecimalField(
required=False,
@ -639,6 +652,12 @@ class CCForm(PlainCCForm):
label="Amount",
)
class AnonCCForm(BaseCCForm):
email = forms.CharField(max_length=30, required=False, widget=forms.TextInput())
class CCForm(BaseCCForm):
username = forms.CharField(max_length=30, required=True, widget=forms.HiddenInput())
class DonateForm(forms.Form):
preapproval_amount = forms.DecimalField( widget=forms.HiddenInput() )
username = forms.CharField(max_length=30, required=True, widget=forms.HiddenInput() )

View File

@ -86,7 +86,7 @@
</li>
</ul>
<ul id="user_menu">
<li><a href="{% url supporter user %}">My Books</a></li>
<li><a href="{% url supporter user %}">My Faves</a></li>
<li>
<a href="/notification"><span>Notices</span>
{% if unseen_count %}

View File

@ -13,7 +13,7 @@
{% with work.id as workid %}
{% with request.user.wishlist.works.all as wishlist %}
{% purchased %}{% lib_acqs %}{% bookpanel %}
<div class="thewholebook listview tabs {% if first_ebook or status == 'SUCCESSFUL' %}tabs-1{% else %}{% if status == 'ACTIVE' %}tabs-2{% else %}tabs-3{% endif %}{% endif %}">
<div class="thewholebook listview tabs {% if tab_override %}{{tab_override}}{% else %}{% if first_ebook or status == 'SUCCESSFUL' %}tabs-1{% else %}{% if status == 'ACTIVE' %}tabs-2{% else %}tabs-3{% endif %}{% endif %}{% endif %}">
<div class="listview book-list">
<div class="listview panelback side2">
{% comment %} hover state of panel {% endcomment %}
@ -46,13 +46,19 @@
{% else %}
<div class="unglued_white">
<b>UNGLUED!</b>
<p><b>On:</b> {{ deadline|date:"M d, Y" }}</p>
<p><b>Raised:</b> {{ work.last_campaign.current_total|floatformat:0|intcomma }}</p>
{% ifequal work.last_campaign.type 3 %}
<p><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b> of thanks</p>
<p> from <b>{{ work.last_campaign.supporters_count }}</b> ungluers</p>
<p> and <b>{{ work.last_campaign.anon_count }}</b> others</p>
{% else %}
<p><b>On:</b> {{ deadline|date:"M d, Y" }}</p>
<p><b>Raised:</b> {{ work.last_campaign.current_total|floatformat:0|intcomma }}</p>
{% endifequal %}
</div>
{% endif %}{% endif %}{% endif %}
</div>
<div class="add_button">
{% include "book_panel_addbutton.html" %}
{% include "book_panel_addbutton.html" %}
</div>
<div class="white_text bottom_button" >
{% if purchased %}
@ -92,11 +98,15 @@
<p><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b> raised</p>
<p><b>${{ work.last_campaign.target|floatformat:0|intcomma }}</b> needed</p>
<p>by {{ deadline|naturalday:"M d, Y" }}</p>
{% else %}
{% else %}{% ifequal work.last_campaign.type 2 %}
<p><b>${{ work.last_campaign.left|floatformat:0|intcomma }}</b> needed</p>
<p>will unglue on </p>
<p>{{ work.last_campaign.cc_date|naturalday:"M d, Y" }}</p>
{% endifequal %}
{% else %}{% ifequal work.last_campaign.type 3 %}
<p><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b> of thanks</p>
<p> from <b>{{ work.last_campaign.supporters_count }}</b> ungluers</p>
<p> and <b>{{ work.last_campaign.anon_count }}</b> others</p>
{% else %}Never.{% endifequal %}{% endifequal %}{% endifequal %}
{% endif %}
</div>
</div>
@ -111,13 +121,15 @@
<div class="white_text bottom_button" >
{% ifequal work.last_campaign.type 1 %}
<a href="{% url pledge work_id=workid %}"><span class="read_itbutton pledge button_text"><span>Pledge</span></span></a>
{% else %}
{% else %}{% ifequal work.last_campaign.type 2 %}
{% if in_library %}
<a href="{% url purchase work_id=workid %}"><span class="read_itbutton pledge button_text"><span>Reserve It</span></span></a>
{% else %}
<a href="{% url purchase work_id=workid %}"><span class="read_itbutton pledge button_text"><span>Purchase</span></span></a>
{% endif %}
{% endifequal %}
{% else %}{% ifequal work.last_campaign.type 3 %}
<a href="{% url thank workid %}" class="hijax"><span class="read_itbutton button_text"><span>Read it Now</span></span></a>
{% endifequal %}{% endifequal %}{% endifequal %}
</div>
{% endif %}
@ -143,10 +155,11 @@
<p>{{ deadline }}</p>
<p>Watch for a new campaign.</p>
{% endif %}{% endif %}{% endif %}{% endif %}
</div>
{% include "book_panel_addbutton.html" %}
</div>
</div>
<div class="white_text bottom_button">
{% include "book_panel_addbutton.html" %}
{% include "num_wishes.html" %}
</div>
{% endif %}{% endif %}
{% else %}
@ -164,19 +177,19 @@
{% if first_ebook %}
<b>AVAILABLE!</b>
<div class="add_button">
{% include "book_panel_addbutton.html" %}
{% include "book_panel_addbutton.html" %}
</div>
{% else %}
<p>No campaign yet.</p><br /><p>But if lots of ungluers wishlist this book, maybe there will be!</p>
<p>No campaign yet.</p><br /><p>But if lots of ungluers fave this book, maybe there will be!</p>
{% endif %}
{% include "book_panel_addbutton.html" %}
</div>
</div>
<div class="white_text bottom_button">
{% if first_ebook %}
<a href="{% url download workid %}" class="hijax"><span class="read_itbutton button_text"><span>Read it Now</span></span></a>
{% else %}
{% include "book_panel_addbutton.html" %}
{% include "num_wishes.html" %}
{% endif %}
</div>
@ -206,13 +219,13 @@
</div>
{% else %}{% if request.user.is_anonymous %}
<div class="listview panelfront side1 create-account">
<span title="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}">Login to Add</span>
<span title="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}">Login to Fave</span>
</div>
{% else %}{% if work in wishlist %}
{% ifequal supporter request.user %}
{% comment %} used only on your own supporter page. {% endcomment %}
<div class="listview panelfront side1 remove-wishlist">
<span id="l{{ workid }}">Un-list</span>
<span id="l{{ workid }}">Un-Fave</span>
</div>
{% else %}
<div class="listview panelfront side1 on-wishlist">
@ -223,40 +236,56 @@
{% else %}{% if request.user.id in supporters %}
<span>Pledged!</span>
{% else %}
<span>On My List!</span>
<span>Faved!</span>
{% endif %}{% endif %}{% endif %}
</div>
{% endifequal %}
{% else %}
<div class="listview panelfront side1 add-wishlist">
{% if on_search_page %}
<span class="gb_id" id="l{{ googlebooks_id }}">Add to My List</span>
<span class="gb_id" id="l{{ googlebooks_id }}">Fave</span>
{% else %}
<span class="work_id" id="l{{ workid }}">Add to My List</span>
<span class="work_id" id="l{{ workid }}">Fave</span>
{% endif %}
</div>
{% endif %}{% endif %}{% endif %}{% endif %}
<div class="listview panelfront side1 booklist-status">
{% ifequal status "ACTIVE" %}
{% if in_library %}
{% if borrowed %}
<span class="booklist-status-text">{{ borrowed.expires|date:"M j, Y" }}</span>
{% else %}
<span class="booklist-status-text" style="line-height:19px">available<br />{{ next_acq.refreshes|date:"M j, Y" }}</span>
{% endif %}
{% else %}{% ifequal work.last_campaign.type 1 %}
<span class="booklist-status-text"><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b>/<b>${{ work.last_campaign.target|floatformat:0|intcomma }}</b></span>
{% else %}
<span class="booklist-status-text"><b>${{ work.last_campaign.left|floatformat:0|intcomma }}</b> to go</span>
{% endifequal %}{% endif %}
{% ifequal work.last_campaign.type 1 %}
<div class="booklist-status-label">{{ work.percent_of_goal }}%</div>
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
{% if in_library %}
{% if borrowed %}
<span class="booklist-status-text">{{ borrowed.expires|date:"M j, Y" }}</span>
{% else %}
<span class="booklist-status-text" style="line-height:19px">available<br />
{% if next_acq.refreshes %}
{{ next_acq.refreshes|date:"M j, Y" }}
{% else %}
now
{% endif %}
</span>
{% endif %}
{% else %}
<div class="booklist-status-label"><b>{{ work.percent_of_goal }}%</b> of goal</div>
{% endif %}
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
{% include 'num_wishes.html' %}
{% endifequal %}
{% else %}{% ifequal status "INITIALIZED" %}
<span class="booklist-status-label">Status:&nbsp;</span><span class="booklist-status-text">Coming soon!</span>
{% else %}{% ifequal status "SUCCESSFUL" %}
{% if not first_ebook %}
<span class="booklist-status-text">Ebook coming soon</span>
{% else %}
<span class="booklist-status-label"></span>
{% include 'num_wishes.html' %}
{% endif %}
{% else %}
{% if first_ebook %}
{% include 'num_wishes.html' %}
{% endif %}
{% endifequal %}{% endifequal %}{% endifequal %}
</div>
@ -283,11 +312,7 @@
<div class="booklist-status-label panel">{{ work.percent_of_goal }}%</div>
{% endif %}
{% else %}
{% if work.num_wishes %}
<a href="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="panelnope">Listed by&nbsp;</span>{{ work.num_wishes }}</span></span></a>
{% else %}
<a href="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="panelnope">Listed by&nbsp;</span>0</span></span></a>
{% endif %}
{% include "num_wishes.html" %}
{% endif %}{% endif %}{% endif %}{% endif %}
</div>

View File

@ -10,7 +10,7 @@
{% endcomment %}
{% if request.user.is_anonymous %}
<div class="moreinfo create-account">
<span title="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}">Login to Add</span>
<span title="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}">Login to Fave</span>
</div>
{% else %}{% if request.user.id in supporters %}
<div class="moreinfo on-wishlist">
@ -19,24 +19,24 @@
{% else %}{% ifequal supporter request.user %}
{% if wishlist %}
<div class="moreinfo remove-wishlist">
<span id="p{{ workid }}">Un-list</span>
<span id="p{{ workid }}">Un-Fave</span>
</div>
{% else %}
{% comment %} on the empty-wishlist slideshow {% endcomment %}
<div class="moreinfo add-wishlist">
<span class="work_id" id="p{{ workid }}">Add&nbsp;to&nbsp;My&nbsp;List</span>
<span class="work_id" id="p{{ workid }}">Add&nbsp;to&nbsp;My&nbsp;Faves</span>
</div>
{% endif %}
{% else %}{% if work in wishlist %}
<div class="moreinfo on-wishlist">
<a href="/#">On My List!</a>
<a href="/#">A Fave!</a>
</div>
{% else %}
<div class="moreinfo add-wishlist">
{% if on_search_page %}
<span class="gb_id" id="p{{ googlebooks_id }}">Add&nbsp;to&nbsp;My&nbsp;List</span>
<span class="gb_id" id="p{{ googlebooks_id }}">Add&nbsp;to&nbsp;My&nbsp;Faves</span>
{% else %}
<span class="work_id" id="p{{ workid }}">Add&nbsp;to&nbsp;My&nbsp;List</span>
<span class="work_id" id="p{{ workid }}">Add&nbsp;to&nbsp;My&nbsp;Faves</span>
{% endif %}
</div>
{% endif %}{% endifequal %}{% endif %}{% endif %}

View File

@ -28,9 +28,9 @@ location.hash = "#2";
<div class="js-topnews3">
<div class="user-block">
<div id="user-block1">
<div id="block-intro-text"><span class="special-user-name">{{ facet|capfirst }} Campaigns</span></div>
<div id="block-intro-text"><span class="special-user-name">Active Campaigns</span></div>
</div>
<div class="user-block2">With your help we're raising money to give these {% if pub_lang %}{{pub_lang|ez_lang_name}} language {% endif %}books to the world.
<div class="user-block2">With your help we're raising money to make these {% if pub_lang %}{{pub_lang|ez_lang_name}} language {% endif %}books free to the world.
</div>
<div class="user-block3">
</div>
@ -56,10 +56,6 @@ location.hash = "#2";
<div class="js-maincol-inner">
<div id="content-block">
<div class="content-block-heading ungluing" id="tabs">
<ul class="tabs">
<li class="tabs2 active"><a href="#">Active<br />({{ campaign_list.count }})</a></li>
</ul>
<ul class="book-list-view">
<li>View As:</li>
<li class="view-list">

View File

@ -0,0 +1,72 @@
{% load humanize %}
{% if request.user.profile.account %}
<div id="authorize" {% if nonprofit.is_on %}class="off clearfix"{% else %}class="clearfix"{% endif %}>
<h3>{{ action|capfirst }} by Credit Card</h3>
<p>Unglue.it has a {{ request.user.profile.account.card_type }} credit card on file for you (we use <a href="https://stripe.com/">Stripe</a> to keep your information secure).
The last four digits of the card are {{ request.user.profile.account.card_last4 }}.
</p>
<form action="#" method="POST" id="use-account-form">
<div class="innards">
{% csrf_token %}
{{ form.non_field_errors }}
{{ form.as_p }}
<input id="use_account_submit" name="use_account" type="submit" class="submit-button loader-gif" value="Complete {{ action|capfirst }}" />
</div>
</form>
</div>
<br />
<p>Want to use a different card? You can change your credit card info on your <a href="{% url manage_account %}?next={{ request.get_full_path|urlencode }}#your_payment_info">Account &amp; Pledges page</a>.
</p>
{% else %}
<div id="authorize" {% if nonprofit.is_on %}class="off clearfix"{% else %}class="clearfix"{% endif %}>
<h3>{{ action|capfirst }} by Credit Card</h3>
<p>Unglue.it uses <a href="https://stripe.com/">Stripe</a> to securely manage your credit card information.
</p>
{% if form.email %}<p>Enter your email address to get a confirmation of your {{action }}.</p>{% endif %}
<div id="cc_pledge">
<form action="" method="POST" id="payment-form">
<div class="innards">
<div class="clearfix">
{{ form.as_p }}
{% csrf_token %}
{{ form.non_field_errors }}
</div>
<div class="form-row clearfix">
<label>Card Number:</label>
<input id="card_Number" type="text" class="card-number" />
</div>
<div class="form-row clearfix cvc">
<label>CVC:</label>
<input id="card_CVC" type="password" size="4" autocomplete="off" class="card-cvc" /> <span id="cvc_help">(what is this?)</span>
<div id="cvc_answer"><img src="/static/images/cvcimage.jpeg" alt="a typical credit card with CVC">For most cards, this is a 3-digit number at the end of the signature strip on the back. For American Express, it's a four-digit number in small print on the front.</div>
</div>
<div class="form-row clearfix initial_values">
<label>Expiration:</label>
<input id="card_ExpiryMonth" type="text" size="2" value="MM" class="card-expiry-month" />
<input id="card_ExpiryYear" type="text" size="4" value="YYYY" class="card-expiry-year" />
</div>
<div class="form-row clearfix">
<label>Name:</label>
<input id="card_Name" type="text" class="address" />
</div>
<div class="form-row clearfix">
<label>State/Province :</label>
<input id="card_AddressState" type="text" class="address" />
</div>
<div class="form-row clearfix">
<label>ZIP/Postal Code:</label>
<input id="card_AddressZip" type="text" class="address" />
</div>
<div class="form-row clearfix">
<label>Country:</label>
<input id="card_AddressCountry" type="text" class="address" />
</div>
</div>
<div class="payment-errors"></div>
<input id="cc_submit" type="submit" class="submit-button loader-gif" value="Complete {{ action|capfirst }}" />
</form>
</div>
</div>
{% endif %}

View File

@ -0,0 +1,50 @@
<script type="text/javascript" src="/static/js/loader-gif.js"></script>
<script type="application/x-javascript">
var $j = jQuery.noConflict();
$j(document).ready(function() {
// don't let users modify their pledge amount on this page; it's just here for reference
// if they modified it here we'd have to faff about with validating premiums
$j('#id_preapproval_amount').prop('disabled', true);
{% if nonprofit.is_on %}
// make the donate/pledge buttons pretty
$j("#pledge_option").click(function() {
$j("#authorize").show();
});
$j("#donate_area").mouseenter(function() {
$j("#donate_explanation").addClass("highlight");
});
$j("#donate_area").mouseleave(function() {
$j("#donate_explanation").removeClass("highlight");
});
$j("#donate_explanation").mouseenter(function() {
$j("#donate_explanation").addClass("highlight");
});
$j("#donate_explanation").mouseleave(function() {
$j("#donate_explanation").removeClass("highlight");
});
$j("#pledge_area").mouseenter(function() {
$j("#pledge_explanation").addClass("highlight");
});
$j("#pledge_area").mouseleave(function() {
$j("#pledge_explanation").removeClass("highlight");
});
$j("#pledge_explanation").mouseenter(function() {
$j("#pledge_explanation").addClass("highlight");
});
$j("#pledge_explanation").mouseleave(function() {
$j("#pledge_explanation").removeClass("highlight");
});
{% endif %}
});
</script>

View File

@ -23,7 +23,7 @@
<div id="user-block1">
<div id="block-intro-text"><span class="special-user-name">Latest Comments</span></div>
</div>
<div class="user-block24"><span class="user-short-info">Ungluers have a lot to say about their books.</span>
<div class="user-block24"><span class="user-short-info">Here's what Ungluers are saying about their books.</span>
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
{% extends "base.html" %}
{% load humanize %}
{% with work.title as title %}
{% block title %}
&mdash; Downloads for {{ work.title }}
@ -21,8 +21,47 @@ $j(document).ready(function() {
{% block content %}
<div class="download_container">
<div id="lightbox_content">
{% if show_beg %}
<div class="border" style="padding: 10px;">
<div id="begblock" class="rh_beg">
<div>Please help us thank the creators for making this book free. The amount is up to you.</div>
<form class="begform" method="POST" action="{% url thank work.id %}#">
{% csrf_token %}
{{ form.non_field_errors }}
<div class="contrib_amount">Amount: {{ form.preapproval_amount.errors }}${{ form.preapproval_amount }}</div>
<div style="text-align: center;"><input name="pledge" type="submit" value="Say Thank You" id="contribsubmit" class="loader-gif" /></div>
<div id="anoncontribbox"><I>{{ form.anonymous.label_tag }}</I> {{ form.anonymous.errors }}{{ form.anonymous }}</div>
{% if request.user.credit.available > 0 %}
<div > You have an available credit of ${{ request.user.credit.available|intcomma }} which will be applied to your contribution.</div>
{% endif %}
</form>
</div>
<div class="rh_beg" style="">
{{ work.last_campaign.description|safe }}
</div>
</div>
{% endif %}
{% if user_license.thanked %}
<div style="text-align: center; padding: 20px;">
<div style="background: #edf3f4; padding: 10px; width:35%; display: inline; ">
You have supported this free book!
</div>
</div>
{% endif %}
{% if amount %}
<div style="text-align: center; padding: 20px;">
<div style="background: #edf3f4; padding: 10px; width:35%; display: inline; ">
Your contribution of ${{amount}} is confirmed.
{% if request.session.receipt %}
A confirmation is being sent to {{ request.session.receipt }}.
{% endif %}
</div>
</div>
{% endif %}
<div class="border">
<h2>Downloads for <I><a href="{% url work work.id %}">{{ work.title }}</a></i></h2>
<h2 style="width:60%">Downloads for <I><a href="{% url work work.id %}">{{ work.title }}</a></i></h2>
<div class="sharing ebook_download_container">
<h3 class="jsmod-title"><span>Share</span></h3>
<ul class="social menu">
@ -30,7 +69,7 @@ $j(document).ready(function() {
<a href="https://www.facebook.com/sharer.php?u=https://{{ site.domain }}{% url work work.id|urlencode:"" %}"><li class="facebook first"><span>Facebook</span></li></a>
<a href="https://twitter.com/intent/tweet?url={{ request.build_absolute_uri|urlencode:"" }}&amp;text=I%27m%20enjoying%20{{ work.title|urlencode }}%2C%20a%20free%2C%20non%2DDRM%20ebook%2E%20You%20can%20too%21"><li class="twitter"><span>Twitter</span></li></a>
{% endwith %}
{% if request.user.is_authenticated %}<a href="{% url emailshare '' %}?next={% url work work.id %}"><li class="email"><span>Email</span></li></a>{% endif %}
{% if request.user.is_authenticated %}<a href="{% url emailshare 'downloaded' %}?next={% url work work.id %}"><li class="email"><span>Email</span></li></a>{% endif %}
<a id="embed2"><li class="embed"><span>Embed</span></li></a>
<div id="widgetcode2">Copy/paste this into your site:<br /><textarea rows="7" cols="22">&lt;iframe src="https://{{ request.META.HTTP_HOST }}/api/widget/{{ work.first_isbn_13 }}/" width="152" height="325" frameborder="0"&gt;&lt;/iframe&gt;</textarea></div>
</ul>
@ -111,7 +150,7 @@ $j(document).ready(function() {
{% endif %}
{% else %}
<div class="border">
<p id="content-block">There are no freely available downloads of <I>{{ work.title }}</I> right now. {% if not work in request.user.wishlist.works.all %}Would you like there to be? <a class="add-wishlist"><span class="work_id" id="w{{ work.id }}">Add this book to your wishlist.</span></a>{% else %}Ask your friends to add it to their wishlists!{% endif %}</p>
<p id="content-block">There are no freely available downloads of <I>{{ work.title }}</I> right now. {% if not work in request.user.wishlist.works.all %}Would you like there to be? <a class="add-wishlist"><span class="work_id" id="w{{ work.id }}">Add this book to your wishlist.</span></a>{% else %}Ask your friends to add it to their favorites!{% endif %}</p>
<p>If you know of a Creative-Commons-licensed or US public domain edition of this book, you can add it through the <a href="{% url work work.id %}?tab=4">More... tab of the book page</a>.</p>
</div>

View File

@ -1,4 +1,6 @@
I just pledged to unglue one of my favorite books, "{{ work.title }}", on Unglue.it:
I just {{ action }} one of my favorite books, "{{ work.title }}", on Unglue.it:
https://{{site}}{% url work work.id %}.
If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth. Will you join me?
{% ifequal work.last_campaign.type 1 %}If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth.{% endifequal %}{% ifequal work.last_campaign.type 2 %}If enough of us buy this book, the ebook will become free to everyone on earth.{% endifequal %}{% ifequal work.last_campaign.type 3 %}Creators of free ebooks need support if we want there to be more of them.{% endifequal %}
Will you join me?

View File

@ -1,4 +1,4 @@
Help me unglue one of my favorite books, "{{ work.title }}" on Unglue.it:
https://{{site}}{% url work work.id %}
If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth.
{% ifequal work.last_campaign.type 1 %}If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth.{% endifequal %}{% ifequal work.last_campaign.type 2 %}If enough of us buy this book, the ebook will become free to everyone on earth.{% endifequal %}{% ifequal work.last_campaign.type 3 %}Creators of free ebooks need support if we want there to be more of them.{% endifequal %}

View File

@ -1,4 +1,4 @@
Help me unglue one of my favorite books, "{{ work.title }}" on Unglue.it:
https://{{site}}{% url work work.id %}
If enough of us wishlist this book, Unglue.it may start a campaign to pay the creator and make the ebook free to everyone on earth.
If enough of us fave this book, Unglue.it may start a campaign to pay the creator and make the ebook free to everyone on earth.

View File

@ -9,7 +9,7 @@
<span>Show me...</span>
<ul class="menu level2">
{% if not request.user.is_anonymous %}
<li class="first"><a href="/"><span>My Books</span></a></li>
<li class="first"><a href="/"><span>My Faves</span></a></li>
{% for library in request.user.profile.libraries %}
<li><a href="{% url library library.user %}"><span>{{ library }}</span></a></li>
{% endfor %}
@ -19,9 +19,9 @@
{% endif %}
<a href="{% url campaign_list 'ending' %}"><span>Active Campaigns</span></a></li>
<li><a href="{% url comment %}"><span>Latest Comments</span></a></li>
<li><a href="{% url work_list 'popular' %}"><span>Most Listed</span></a></li>
<li><a href="{% url work_list 'new' %}"><span>Newly Listed</span></a></li>
<li><a href="{% url work_list 'recommended' %}"><span>Noteworthy</span></a></li>
<li><a href="{% url work_list 'popular' %}"><span>Site Favorites</span></a></li>
<li><a href="{% url work_list 'new' %}"><span>Latest Favorites</span></a></li>
<!--<li><a href="{% url work_list 'recommended' %}"><span>Noteworthy</span></a></li>-->
<li><a href="{% url unglued_list '' %}"><span>Ready to Read</span></a></li>
<li class="last"><a href="{% url cc_list%}">Latest Creative Commons</a></li>
{% if pubname %}

View File

@ -97,7 +97,7 @@ If you believe you are a rights holder and would like to your works to be unglue
<dt>I know a book that should be unglued.</dt>
<dd>Great! Find it in our database (using the search box above) and add it to your list, so we know it should be on our list, too. And encourage your friends to add it to their wishlists. The more wishlists a book is on, the more appealing it is for authors and publishers to launch an ungluing campaign. You can also contact us at <a href="mailto:rights@gluejar.com">rights@gluejar.com</a>.</dd>
<dd>Great! Find it in our database (using the search box above) and add it to your favorites, so we know it should be on our list, too. And encourage your friends to add it to their favorites. The more people that fave a book on Unglue.it, the more attractive it will be for authors and publishers to launch an ungluing campaign. You can also contact us at <a href="mailto:rights@gluejar.com">rights@gluejar.com</a>.</dd>
<dt>I know a book that should be unglued, and I own the commercial rights.</dt>
@ -126,7 +126,7 @@ Click on this <a href="{% url django.contrib.auth.views.password_reset %}">forgo
<dt>Why should I connect those accounts?</dt>
<dd>If you connect your Facebook or Twitter accounts, we'll use your user pics from those sites for your avatar here. If you connect to LibraryThing or GoodReads, you can import your books there onto your wishlist here, using the My Profile area. And we'll display book-specific and you-specific links to those sites for you.</dd>
<dd>If you connect your Facebook or Twitter accounts, we'll use your user pics from those sites for your avatar here. If you connect to LibraryThing or GoodReads, you can import your books there onto your favorites list here, using the My Profile area. And we'll display book-specific and you-specific links to those sites for you.</dd>
<dt>I don't want to connect my accounts. Do I have to?</dt>
@ -306,7 +306,7 @@ What does this mean for you? If you're a book lover, you can read unglued ebook
<dt>Will Unglue.it have campaigns for all kinds of books?</dt>
<dd>Yes. You choose what books to wishlist and what books to support. </dd>
<dd>Yes. You choose what books to support. </dd>
<dt>Does an unglued book have to be out-of-print?</dt>

View File

@ -5,57 +5,7 @@
{% block extra_extra_head %}
{% include "stripe_stuff.html" %}
<script type="text/javascript" src="/static/js/loader-gif.js"></script>
<script type="application/x-javascript">
var $j = jQuery.noConflict();
$j(document).ready(function() {
// don't let users modify their pledge amount on this page; it's just here for reference
// if they modified it here we'd have to faff about with validating premiums
$j('#id_preapproval_amount').prop('disabled', true);
{% if nonprofit.is_on %}
// make the donate/pledge buttons pretty
$j("#pledge_option").click(function() {
$j("#authorize").show();
});
$j("#donate_area").mouseenter(function() {
$j("#donate_explanation").addClass("highlight");
});
$j("#donate_area").mouseleave(function() {
$j("#donate_explanation").removeClass("highlight");
});
$j("#donate_explanation").mouseenter(function() {
$j("#donate_explanation").addClass("highlight");
});
$j("#donate_explanation").mouseleave(function() {
$j("#donate_explanation").removeClass("highlight");
});
$j("#pledge_area").mouseenter(function() {
$j("#pledge_explanation").addClass("highlight");
});
$j("#pledge_area").mouseleave(function() {
$j("#pledge_explanation").removeClass("highlight");
});
$j("#pledge_explanation").mouseenter(function() {
$j("#pledge_explanation").addClass("highlight");
});
$j("#pledge_explanation").mouseleave(function() {
$j("#pledge_explanation").removeClass("highlight");
});
{% endif %}
});
</script>
{% include "cardscripts.html" %}
{% endblock %}
{% block news %}
@ -101,76 +51,8 @@ $j(document).ready(function() {
</div>
{% endif %}
{% if request.user.profile.account %}
<div id="authorize" {% if nonprofit.is_on %}class="off clearfix"{% else %}class="clearfix"{% endif %}>
<h3>{{ action|capfirst }} by Credit Card</h3>
<p>Unglue.it has a {{ request.user.profile.account.card_type }} credit card on file for you (we use <a href="https://stripe.com/">Stripe</a> to keep your information secure).
The last four digits of the card are {{ request.user.profile.account.card_last4 }}.
</p>
<form action="#" method="POST" id="use-account-form">
<div class="innards">
{% csrf_token %}
{{ form.non_field_errors }}
{{ form.as_p }}
<input id="use_account_submit" name="use_account" type="submit" class="submit-button loader-gif" value="Complete {{ action|capfirst }}" />
</div>
</form>
</div>
<br />
<p>Want to use a different card? You can change your credit card info on your <a href="{% url manage_account %}?next={{ request.get_full_path|urlencode }}#your_payment_info">Account &amp; Pledges page</a>.
</p>
{% else %}
<div id="authorize" {% if nonprofit.is_on %}class="off clearfix"{% else %}class="clearfix"{% endif %}>
<h3>{{ action|capfirst }} by Credit Card</h3>
<p>Unglue.it uses <a href="https://stripe.com/">Stripe</a> to securely manage your credit card information.
</p>
<div id="cc_pledge">
<form action="" method="POST" id="payment-form">
<div class="innards">
<div class="clearfix">
{% csrf_token %}
{{ form.non_field_errors }}
{{ form.as_p }}
</div>
<div class="form-row clearfix">
<label>Card Number:</label>
<input id="card_Number" type="text" class="card-number" />
</div>
<div class="form-row clearfix cvc">
<label>CVC:</label>
<input id="card_CVC" type="password" size="4" autocomplete="off" class="card-cvc" /> <span id="cvc_help">(what is this?)</span>
<div id="cvc_answer"><img src="/static/images/cvcimage.jpeg" alt="a typical credit card with CVC">For most cards, this is a 3-digit number at the end of the signature strip on the back. For American Express, it's a four-digit number in small print on the front.</div>
</div>
<div class="form-row clearfix initial_values">
<label>Expiration:</label>
<input id="card_ExpiryMonth" type="text" size="2" value="MM" class="card-expiry-month" />
<input id="card_ExpiryYear" type="text" size="4" value="YYYY" class="card-expiry-year" />
</div>
<div class="form-row clearfix">
<label>Name:</label>
<input id="card_Name" type="text" class="address" />
</div>
<div class="form-row clearfix">
<label>State/Province :</label>
<input id="card_AddressState" type="text" class="address" />
</div>
<div class="form-row clearfix">
<label>ZIP/Postal Code:</label>
<input id="card_AddressZip" type="text" class="address" />
</div>
<div class="form-row clearfix">
<label>Country:</label>
<input id="card_AddressCountry" type="text" class="address" />
</div>
</div>
<div class="payment-errors"></div>
<input id="cc_submit" type="submit" class="submit-button loader-gif" value="Complete {{ action|capfirst }}" />
</form>
</div>
</div>
{% endif %}
{% include 'cardform.html' %}
</div>
</div>

View File

@ -5,7 +5,6 @@
{% 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 type="text/css" rel="stylesheet" href="/static/css/pledge.css" />
{{ transfer_form.media.css }}
<script type="text/javascript" src="{{ jquery_ui_home }}" ></script>
{{ transfer_form.media.js }}

View File

@ -80,7 +80,7 @@
<form id="load_shelf_form" method="post" action="#">
{{gr_shelf_load_form.as_p}}
<input type="submit" value="Load the books from your Goodreads shelf to your wishlist" />
<input type="submit" value="Load the books from your Goodreads shelf to your faves" />
</form>
{% else %}
@ -90,10 +90,10 @@
<hr />
<p><a href="#" id="test_click">Click here to update the number of books on your wishlist:</a></p>
<div id="gr_status"><p>Number of books on your wishlist: <span id="number_of_books_on_wishlist">{{user.wishlist.works.all|length}}</span> (as of <span id="num_books_update_time"></span>)</p></div>
<p><a href="#" id="test_click">Click here to update the number of books on your favorites list:</a></p>
<div id="gr_status"><p>Number of books on your favorites list: <span id="number_of_books_on_wishlist">{{user.wishlist.works.all|length}}</span> (as of <span id="num_books_update_time"></span>)</p></div>
<form id="clear_wishlist_form" method="post" action="#">
<input type="submit" value="Empty your wishlist" />
<input type="submit" value="Empty your faves" />
</form>
<!-- list user's books -->

View File

@ -82,7 +82,7 @@ function put_un_in_cookie2(){
</div>
<div class="spacer"></div>
<h3 class="featured_books">Most Listed</h3>
<h3 class="featured_books">Site Faves</h3>
<div>
{% for work in most_wished %}
{% with work.googlebooks_id as googlebooks_id %}
@ -162,6 +162,7 @@ function put_un_in_cookie2(){
<li>
{% with event.1 as object %}
{% ifequal event.2 "pledge" %}
{% if object.user%}
<span class="user-avatar">
<a href="{% url supporter object.user.username %}"><img src="{{ object.user.profile.avatar_url }}" width="43" height="43" title="{{ object.user.username }}" alt="Avatar for {{ object.user.username }}" /></a>
</span>
@ -172,9 +173,22 @@ function put_un_in_cookie2(){
{% endifequal %}
{% ifequal object.campaign.type 2 %}
bought a copy of
{% endifequal %}
{% ifequal object.campaign.type 3 %}
supported
{% endifequal %}<br />
<a class="user-book-name" href="{% url work object.campaign.work.id %}">{{ object.campaign.work.title }}</a>
</span>
{% else %}
<span class="user-avatar">
<img src="/static/images/header/anonuser.png" width="43" height="43" title="Anonymous User" alt="Avatar for Anonymous User" />
</span>
<span class="user-book-info">
Anonymous User<br />
supported <br />
<a class="user-book-name" href="{% url work object.campaign.work.id %}">{{ object.campaign.work.title }}</a>
</span>
{% endif %}
{% else %}{% ifequal event.2 "comment" %}
<span class="user-avatar">
<a href="{% url supporter object.user.username %}"><img src="{{ object.user.profile.avatar_url }}" width="43" height="43" title="{{ object.user.username }}" alt="Avatar for {{ object.user.username }}" /></a>
@ -190,7 +204,7 @@ function put_un_in_cookie2(){
</span>
<span class="user-book-info">
<a href="{% url supporter object.wishlist.user.username %}">{{ object.wishlist.user.username }}</a><br />
added to list<br />
faved<br />
<a class="user-book-name" href="{% url work object.work.id %}">{{ object.work.title }}</a>
</span>
{% endifequal %}{% endifequal %}{% endifequal %}

View File

@ -156,9 +156,9 @@ function highlightTarget(targetdiv) {
{% if not works_active.count and not works_unglued.count %}
{% ifequal request.user supporter %}
<div class="empty-wishlist">
<h2 style="padding-left:35px;">Your Unglue.it books will be listed here.</h2>
<h2 style="padding-left:35px;">Your Unglue.it faves will be listed here.</h2>
<p>The "Available" tab will show all the books you have licensed though Unglue.it.
The "Unglued" tab will show public domain, creative commons, and unglued titles that you add to your list of books</p>
The "Unglued" tab will show public domain, creative commons, and unglued titles that you add to your list of faves</p>
</div>
{% else %}
<div class="empty-wishlist">

View File

@ -83,7 +83,7 @@ Please fix the following before launching your campaign:
{% ifequal work.last_campaign.type 1 %}
{{ work.last_campaign.supporters_count }} Ungluers have pledged ${{ work.last_campaign.current_total|intcomma }}
{% else %}
Total revenue: ${{ work.last_campaign.current_total|intcomma }} from {{ work.last_campaign.supporters_count }} Ungluers
Total revenue: ${{ work.last_campaign.current_total|intcomma }} from {{ work.last_campaign.supporters_count }} Ungluers and {{ work.last_campaign.anon_count }} others
{% endifequal %}
</div>
<div class="status">

View File

@ -59,20 +59,20 @@
</li>
</ul>
</dd>
<dt> How often have the works been listed?</dt>
<dt> How often have the works been faved?</dt>
<dd>
<ul class="terms">
<li>{{ works.wishedby100.count }} have been listed by more than 100 ungluers.
<li>{{ works.wishedby100.count }} have been faved by more than 100 ungluers.
</li>
<li>{{ works.wishedby50.count }} have been listed by more than 50 ungluers.
<li>{{ works.wishedby50.count }} have been faved by more than 50 ungluers.
</li>
<li>{{ works.wishedby20.count }} have been listed by more than 20 ungluers.
<li>{{ works.wishedby20.count }} have been faved by more than 20 ungluers.
</li>
<li>{{ works.wishedby10.count }} have been listed by more than 10 ungluers.
<li>{{ works.wishedby10.count }} have been faved by more than 10 ungluers.
</li>
<li>{{ works.wishedby5.count }} have been listed by more than 5 ungluers.
<li>{{ works.wishedby5.count }} have been faved by more than 5 ungluers.
</li>
<li>{{ works.wishedby2.count }} have been listed by more than 2 ungluers.
<li>{{ works.wishedby2.count }} have been faved by more than 2 ungluers.
</li>
</ul>
</dd>

View File

@ -3,13 +3,14 @@
{% ifequal transaction.offer.license 2 %}If you have not already done so, download your ebook at
https://{{ current_site.domain }}{% url download transaction.campaign.work.id %}
{% endifequal %}Thanks to you and other ungluers, {{ transaction.campaign.work.title }} will be eventually be released to the world in an unglued ebook edition. Thanks to your purchase, the ungluing date advanced {{ transaction.offer.days_per_copy|floatformat }}{% ifnotequal transaction.extra.copies 1 %} x {{ transaction.extra.copies }}{% endifnotequal %} days to {{ transaction.campaign.cc_date }}.
{% endifequal %}{% ifequal transaction.campaign.type 2 %}Thanks to you and other ungluers, {{ transaction.campaign.work.title }} will be eventually be released to the world in an unglued ebook edition. Thanks to your purchase, the ungluing date advanced {{ transaction.offer.days_per_copy|floatformat }}{% ifnotequal transaction.extra.copies 1 %} x {{ transaction.extra.copies }}{% endifnotequal %} days to {{ transaction.campaign.cc_date }}.
{% ifequal transaction.offer.license 1 %}
This ebook is licensed to you personally, and your personal license has been embedded in the ebook file. You may download as many times as you need to, but you can't make copies for the use of others until the ungluing date. You can make that date come sooner by encouraging your friends to buy a copy.
{% else %}
This ebook {% ifnotequal transaction.extra.copies 1 %}({{ transaction.extra.copies }} copies){% endifnotequal %} is licensed to your library and its license has been embedded in the ebook file. If you'd like to be the first to use it, please get your copy now at
https://{{ current_site.domain }}{% url borrow transaction.campaign.work.id %}
After an hour, the ebook will be available to all of your library's users on a one-user-per two weeks basis until the ungluing date, when it will be free to all. You can make that date come sooner by encouraging your friends to buy a copy.{% endifequal %}
After an hour, the ebook will be available to all of your library's users on a one-user-per two weeks basis until the ungluing date, when it will be free to all. You can make that date come sooner by encouraging your friends to buy a copy.{% endifequal %}{% endifequal %}{% ifequal transaction.campaign.type 3 %}The creators of {{ transaction.campaign.work.title }} would like to thank you for showing your appreciation for making it free.{% endifequal %}
For more information about the book, visit the book's unglue.it page at
https://{{ current_site.domain }}{% url work transaction.campaign.work.id %}

View File

@ -26,12 +26,18 @@ If you have not already done so, download your ebook at <a href="{% url download
{% endblock %}
{% block comments_textual %}
<p>Thanks to you and other ungluers, {{ transaction.campaign.work.title }} will be eventually be released to the world in an unglued ebook edition. Thanks to your purchase, the ungluing date advanced {{ transaction.offer.days_per_copy|floatformat }}{% ifnotequal transaction.extra.copies 1 %} x {{ transaction.extra.copies }}{% endifnotequal %} days to {{ transaction.campaign.cc_date }}.</p>
{% ifequal transaction.campaign.type 2 %}
<p>Thanks to you and other ungluers, <i>{{ transaction.campaign.work.title }}</i> will be eventually be released to the world in an unglued ebook edition. Thanks to your purchase, the ungluing date advanced {{ transaction.offer.days_per_copy|floatformat }}{% ifnotequal transaction.extra.copies 1 %} x {{ transaction.extra.copies }}{% endifnotequal %} days to {{ transaction.campaign.cc_date }}.</p>
{% ifequal transaction.offer.license 1 %}
{% ifequal transaction.offer.license 1 %}
<p>This ebook is licensed to you personally, and your personal license has been embedded in the ebook file. You may download as many times as you need to, but you can't make copies for the use of others until the ungluing date. You can make that date come sooner by encouraging your friends to buy a copy.</p>
{% else %}
{% else %}
<p>This ebook {% ifnotequal transaction.extra.copies 1 %}({{ transaction.extra.copies }} copies){% endifnotequal %} is licensed to your library and its license has been embedded in the ebook file. If you'd like to be the first to use it, please <a href="{% url borrow transaction.campaign.work.id %}">get your copy now</a>. After an hour, the ebook will be available to all of your library's users on a one-user-per two weeks basis until the ungluing date, when it will be free to all. You can make that date come sooner by encouraging your friends to buy a copy.</p>
{% endifequal %}
{% endifequal %}
{% ifequal transaction.campaign.type 3 %}
<p>The creators of <i>{{ transaction.campaign.work.title }}</i> would like to thank you for showing your appreciation for making it free.
</p>
{% endifequal %}
<p>For more information about the book, visit the <a href="{% url work transaction.campaign.work.id %}">book's unglue.it page</a>.
</p>

View File

@ -1 +1 @@
You have purchased {{transaction.campaign.work.title}}{% ifequal transaction.offer.license 2 %} for your library{% endifequal %}.
{% ifequal transaction.campaign.type 2 %}You have purchased {{transaction.campaign.work.title}}{% ifequal transaction.offer.license 2 %} for your library{% endifequal %}.{% endifequal %}{% ifequal transaction.campaign.type 3 %}You have supported {{ transaction.campaign.work.title }}, a free ebook.{% endifequal %}

View File

@ -1,5 +1,5 @@
<ul>
{% if request.user.is_authenticated %}<a href="{% url emailshare 'pledge' %}?next={{ work_url|urlencode:"" }}"><li>Email it!</li></a>{% endif %}
{% if request.user.is_authenticated %}<a href="{% url emailshare 'pledged' %}?next={{ work_url|urlencode:"" }}"><li>Email it!</li></a>{% endif %}
<a href="https://twitter.com/intent/tweet?url=https://{{ current_site.domain }}{{ work_url|urlencode:"" }}&text=I%27m%helping%20to%20unglue%20{{ title|urlencode }}%20at%20%40unglueit.%20Will%20you%20join%20me%3F"><li>Tweet it!</li></a>
<a href="https://www.facebook.com/sharer.php?u=https://{{ current_site.domain }}{{ work_url|urlencode:"" }}"><li>Share it on Facebook.</li></a>
<li>Best idea: talk about it with those you love.</li>

View File

@ -3,12 +3,16 @@
You can help!
Pledge toward ungluing. https://{{ current_site.domain }}{% url pledge work_id=campaign.work.id %}
{% else %}Great, you wished for it, and now there is a campaign for {{ campaign.work.title }} to be unglued. Someday, the book will be released under a Creative Commons license for everyone to enjoy. Every copy purchased until then brings that day {{ campaign.day_per_copy|floatformat }} days sooner.
{% endifequal %}{% ifequal campaign.type 2 %}Great, you wished for it, and now there is a campaign for {{ campaign.work.title }} to be unglued. Someday, the book will be released under a Creative Commons license for everyone to enjoy. Every copy purchased until then brings that day {{ campaign.day_per_copy|floatformat }} days sooner.
You can help!
Buy a copy to help unglue the book. https://{{ current_site.domain }}{% url purchase work_id=campaign.work.id %}
{% endifequal %}{% ifequal campaign.type 3 %}There is a new "Thanks for Ungluing" campaign for {{ campaign.work.title }} one of your Creative Commons license favorites.
Join us in thanking the creators! Download a copy and leave a contribution. https://{{ current_site.domain }}{% url download work_id=campaign.work.id %}
{% endifequal %}
Tell your friends -- there are handy share options on the campaign page. There's even a widget you can put on your blog or home page. https://{{ current_site.domain }}{% url work campaign.work.id %}

View File

@ -13,8 +13,13 @@
{% ifequal campaign.type 1 %}
<div>Congratulations! You wished for a campaign, and here it is. If ungluers like you pledge {{ campaign.target|intcomma }} by {{ campaign.deadline|date:"M d, Y" }}, <I>{{ campaign.work.title }}</i> will be released under a <a href="http://creativecommons.org">Creative Commons</a> license for all to enjoy.</div>
<div>You can help! <a href="{% url pledge campaign.work.id %}">Pledge</a> any amount, and use the sharing options on the <a href="{% url work campaign.work.id %}">campaign page</a> to tell your friends.</a></div>
{% else %}
{% endifequal %}
{% ifequal campaign.type 2 %}
<div>Great! You wished for a campaign, and here it is. Someday, the book will be released under a <a href="http://creativecommons.org">Creative Commons license</a> for everyone to enjoy. Every copy purchased brings that day {{ campaign.days_per_copy|floatformat }} days sooner.</div>
<div>You can help! <a href="{% url purchase campaign.work.id %}">Purchase</a> a copy, and use the sharing options on the <a href="{% url work campaign.work.id %}">campaign page</a> to tell your friends.</a></div>
{% endifequal %}
{% ifequal campaign.type 3 %}
<div>There is a new "Thanks for Ungluing" campaign for {{ campaign.work.title }} one of your Creative Commons license favorites.</div>
<div>Please join us! <a href="{% url download campaign.work.id %}">Download</a> a copy, leave a contribution, and use the sharing options on the <a href="{% url work campaign.work.id %}">campaign page</a> to tell your friends.</a></div>
{% endifequal %}
{% endblock %}

View File

@ -1,4 +1,4 @@
{% load humanize %}{% if campaign.left > 0 %} The campaign to unglue a book you've wishlisted, {{ campaign.work.title}}, is almost out of time. We need to raise ${{ campaign.left|intcomma }} more by {{ campaign.deadline }} in order to give this book to the world.
{% load humanize %}{% if campaign.left > 0 %} The campaign to unglue a book you've faved, {{ campaign.work.title}}, is almost out of time. We need to raise ${{ campaign.left|intcomma }} more by {{ campaign.deadline }} in order to give this book to the world.
{% if pledged %}
Your pledge is helping {{ campaign.work.title }} to reach its goal, but we can only unglue this book if the campaign succeeds. You can help your pledge go farther by sharing the campaign ({{ domain }}{% url work work_id=campaign.work.id %}) with your friends through your favorite media: tweet, Facebook, Tumblr, blog, G+, Pinterest, email, carrier pigeon, or good old-fashioned conversation.
@ -11,7 +11,7 @@
Thank you!
{% else %}
The campaign to unglue a book you've wishlisted, {{ campaign.work.title}}, is on track to succeed! It has met its target price of {{ campaign.target|intcomma }} and will close soon.
The campaign to unglue a book you've faved, {{ campaign.work.title}}, is on track to succeed! It has met its target price of {{ campaign.target|intcomma }} and will close soon.
{% if pledged %}
Your pledge is helping us give this book to the world. Thank you! When the campaign closes, we'll be in touch about how and when you'll receive your premiums.

View File

@ -1,4 +1,4 @@
{% load humanize %}The campaign to unglue a book you've wishlisted, {{ campaign.work.title}}, is close to succeeding! We only need to raise ${{ campaign.left|intcomma }} more by {{ campaign.deadline }} in order to give this book to the world.
{% load humanize %}The campaign to unglue a book you've faved, {{ campaign.work.title}}, is close to succeeding! We only need to raise ${{ campaign.left|intcomma }} more by {{ campaign.deadline }} in order to give this book to the world.
{% if pledged %}
Your pledge of {{ amount|intcomma }} is helping {{ campaign.work.title }} to reach its goal, but we can only unglue this book if the campaign succeeds. You can tip the balance by sharing the campaign (https://{{ current_site.domain }}{% url work work_id=campaign.work.id %}) with your friends through your favorite media: tweet, Facebook, Tumblr, blog, G+, Pinterest, email, carrier pigeon, or good old-fashioned conversation.

View File

@ -7,7 +7,7 @@
{% block comments_graphical %}
<img src="/static/images/images/icon-book-37by25-{{ campaign.work.percent_unglued }}.png" alt="almost-unglued icon" title="almost-unglued icon" />
<span>The campaign to unglue a book you've wishlisted, {{ campaign.work.title}}, is close to succeeding!</span>
<span>The campaign to unglue a book you've faved, {{ campaign.work.title}}, is close to succeeding!</span>
{% endblock %}
{% block comments_textual %}

View File

@ -11,7 +11,7 @@
{% block comments_textual %}
If you pledged toward this work, your pledge will expire shortly and your credit card will not be charged, nor will you receive any premiums.
Still want to give {{ campaign.work.title }} to the world? Don't despair. Keep it on your wishlist and tell everyone why you love this book. The rights holder, {{ campaign.rightsholder }}, may run a campaign with different terms in the future. With your help, we may yet be able to unglue {{ campaign.work.title }}.
Still want to give {{ campaign.work.title }} to the world? Don't despair. Keep it on your faves and tell everyone why you love this book. The rights holder, {{ campaign.rightsholder }}, may run a campaign with different terms in the future. With your help, we may yet be able to unglue {{ campaign.work.title }}.
There are also <a href="https://unglue.it/campaigns/ending">other books with active campaigns</a> that need your help.

View File

@ -11,7 +11,7 @@
{% block comments_textual %}
Because we cannot process payments at this time, we have closed our active campaigns. If you have pledged to this campaign, your pledge will expire shortly and your credit card will not be charged, nor will you receive any premiums.
Still want to give {{ campaign.work.title }} to the world? Don't despair. Keep it on your wishlist and tell everyone why you love this book. Encourage your friends to sign up for Unglue.it and add it to their wishlists. We are hard at work on payment alternatives and intend to reopen campaigns as soon as possible. With your help, we may yet be able to unglue {{ campaign.work.title }}.
Still want to give {{ campaign.work.title }} to the world? Don't despair. Keep it on your faves and tell everyone why you love this book. Encourage your friends to sign up for Unglue.it and add it to their wishlists. We are hard at work on payment alternatives and intend to reopen campaigns as soon as possible. With your help, we may yet be able to unglue {{ campaign.work.title }}.
You can also comment and ask us questions at <a href="http://wp.me/p2omBl-3B">our blog</a>, on <a href="https://www.facebook.com/unglueit">our Facebook page</a>, or on Twitter with the hashtag #unglueit.

View File

@ -0,0 +1,9 @@
{% if work.last_campaign.type == 3 %}
<a href="{% url work workid %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="">Thanked by&nbsp;</span>{{ work.last_campaign.supporters_count }}</span></span></a>
{% else %}
{% if work.num_wishes %}
<a href="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="">Faved by&nbsp;</span>{{ work.num_wishes }}</span></span></a>
{% else %}
<a href="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="">No Faves</span></a>
{% endif %}
{% endif %}

View File

@ -35,6 +35,12 @@
<div><a href="{% url download work.id %}" class="fakeinput" style="float:left">Download Now</a> </div>
<div style="height:75px;"></div>
{% endifequal %}
{% ifequal campaign.type 3 %}
<p class="pledge_complete">You've just contributed ${{ transaction.amount|intcomma }} to the creators of <I><a href="{% url work work.id %}">{{ work.title }}</a></I> to thank them for making it free to the world.</p>
<div><a href="{% url download work.id %}" class="fakeinput" style="float:left">Download Now</a> </div>
<div style="height:75px;"></div>
{% endifequal %}
<div class="modify_notification clearfix">
{% include "trans_summary.html" %}
@ -46,7 +52,7 @@
<ul class="social menu pledge">
<a href="https://www.facebook.com/sharer.php?u=https://{{ site.domain }}{% url work work.id|urlencode:"" %}"><li class="facebook first"><span>Facebook</span></li></a>
<a href="https://twitter.com/intent/tweet?url=https://{{ site.domain }}{% url work work.id|urlencode:"" %}&amp;text=I%20just%20supported%20{{ work.title|urlencode }}%20at%20%40unglueit.%20Will%20you%20join%20me%3F"><li class="twitter"><span>Twitter</span></li></a>
{% if request.user.is_authenticated %}<a href="{% url emailshare 'pledge' %}?next={% url work work.id|urlencode:"" %}"><li class="email"><span>Email</span></li></a>{% endif%}
{% if request.user.is_authenticated %}<a href="{% url emailshare 'pledged' %}?next={% url work work.id|urlencode:"" %}"><li class="email"><span>Email</span></li></a>{% endif%}
<a href="#" id="embed"><li class="embed"><span>Embed</span></li></a>
</ul>
</div>

View File

@ -136,7 +136,7 @@ Creative Commons offers a variety of other licenses, many of them with even less
</div>
<div class="outer">
<div><a href="/static/images/supporter_listview.png"><img src="/static/images/supporter_listview_thumb.png" class="screenshot" alt="screenshot" /></a></div>
<div class="text"><p>300 ppi screenshot of a supporter page. Supporters can readily see all the books on their wishlist and filter for active or successful campaigns. Icons show how many other ungluers have wishlisted a book or, for active campaigns, their progress toward completion. Unglued and public domain books have links to freely available copies. Numbered badges show how many successful, active, and wishlisted books a user is supporting. Supporters can link to their home page and accounts on Facebook, Twitter, GoodReads, and LibraryThing (note icons in upper right), as well as import books from their GoodReads and LibraryThing accounts to their wishlist.</p></div>
<div class="text"><p>300 ppi screenshot of a supporter page. Supporters can readily see all the books on their faves list and filter for active or successful campaigns. Icons show how many other ungluers have faved a book or, for active campaigns, their progress toward completion. Unglued and public domain books have links to freely available copies. Supporters can link to their home page and accounts on Facebook, Twitter, GoodReads, and LibraryThing (note icons in upper right), as well as import books from their GoodReads and LibraryThing accounts to their wishlist.</p></div>
</div>
<div class="outer">
<div><a href="/static/images/supporter_panelview.png"><img src="/static/images/supporter_panelview_thumb.png" class="screenshot" alt="screenshot" /></a></div>

View File

@ -12,7 +12,7 @@
</div>
<br />
<div class="welcomealternatives">
Or you can <a href="{% url regluit.frontend.views.edit_user %}">change your username</a> &#151; <a href="{% url work_list 'popular' %}">see the most wishlisted books</a> &#151; <a href="/feedback/">send us feedback</a> &#151; <a href="{% url notification_notice_settings %}">manage your contact preferences</a>
Or you can <a href="{% url regluit.frontend.views.edit_user %}">change your username</a> &#151; <a href="{% url work_list 'popular' %}">see the site's favorite books</a> &#151; <a href="/feedback/">send us feedback</a> &#151; <a href="{% url notification_notice_settings %}">manage your contact preferences</a>
</div>
{% endblock %}

View File

@ -68,7 +68,7 @@ Any questions not covered here? Please email us at <a href="mailto:rights@gluej
<b>Thanks-for-Ungluing Campaign</b><br />
Campaign status: {{ campaign.status }} <br />
Created: {{ campaign.created }}<br />
${{ campaign.current_total }} raised from {{ campaign.supporters_count }} supporters.
${{ campaign.current_total }} raised from {{ campaign.supporters_count }} ungluers, {{ campaign.anon_count }} others.
{% with campaign.work.preferred_edition as edition %}
<a href="{% url new_edition edition.work.id edition.id %}"> Edit </a> the preferred edition<br />
You can also <a href="{% url edition_uploads edition.id %}"> Load a file</a> for this edition.<br />

View File

@ -263,7 +263,7 @@ function highlightTarget(targetdiv) {
<ul class="tabs">
<li class="tabs1"><a href="#">Unglued</a></li>
<li class="tabs2"><a href="#">Active</a></li>
<li class="tabs3"><a href="#">Wishlisted</a></li>
<li class="tabs3"><a href="#">Not Yet</a></li>
</ul>
<ul class="book-list-view">
@ -357,9 +357,9 @@ function highlightTarget(targetdiv) {
{% lazy_paginate 20 works_active using "works_active" %}
{% for work in works_active %}
<div class="{% cycle 'row1' 'row2' %}">
{% with work.googlebooks_id as googlebooks_id %}
{% with work.googlebooks_id as googlebooks_id %}{% with 'tabs-2' as tab_override %}
{% include "book_panel.html" %}
{% endwith %}
{% endwith %}{% endwith %}
</div>
{% endfor %}
<div class="pagination content-block-heading tabs-2">

View File

@ -102,33 +102,50 @@
</div>
</div>
{% ifequal status 'ACTIVE' %}
<div class="thermometer" title="{{ work.percent_of_goal }}% of goal">
<div class="cover" style="width: {{ cover_width }}%;">
{% ifnotequal work.last_campaign.type 3 %}
<div class="thermometer" title="{{ work.percent_of_goal }}% of goal">
<div class="cover" style="width: {{ cover_width }}%;">
</div>
<span>{{ work.percent_of_goal }}% of goal</span>
</div>
<span>{{ work.percent_of_goal }}% of goal</span>
</div>
{% endifnotequal %}
<div class="pledged-info noborder">
<div class="campaign-status-info">
{% ifequal work.last_campaign.type 1 %}
<span>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</span> pledged
{% else %}
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
current ungluing date:
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
<span>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</span> of thanks from
{% endifequal %}
</div>
<div class="campaign-status-info explainer">
{% ifequal work.last_campaign.type 1 %}
<span>${{ work.last_campaign.target|floatformat:0|intcomma }}</span> goal
{% else %}
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
<span class="current_cc_date ">{{ work.last_campaign.cc_date|date:"M j, Y" }}</span>
<span class="explanation">After {{ work.last_campaign.cc_date|date:"M j, Y" }} this book will be available for free to anyone, anywhere. Every purchase before then brings that date closer.</span>
{% endifequal %}
{% endifequal %}
{% ifnotequal work.last_campaign.type 3 %}
</div>
<div class="campaign-status-info">
{% endifnotequal %}
{% if work.last_campaign.supporters_count == 1 %}
<span>1</span> ungluer
{% else %}
<span>{{ work.last_campaign.supporters_count }}</span> ungluers
{% endif %}
{% ifequal work.last_campaign.type 3 %}
<br />
{% if work.last_campaign.anon_count == 1 %}
<span>1</span> other
{% else %}
<span>{{ work.last_campaign.anon_count }}</span> others
{% endif %}
{% endifequal %}
</div>
{% ifequal work.last_campaign.type 2 %}
<div class="campaign-status-info">
@ -139,14 +156,16 @@
{% endif %}
</div>
{% endifequal %}
<div class="campaign-status-info explainer">
{% ifequal work.last_campaign.type 1 %}
<span>{{ work.last_campaign.countdown }}</span> to go
{% else %}
<span>${{ work.last_campaign.left|floatformat:0|intcomma }}</span> to go
<span class="explanation">${{ work.last_campaign.left|floatformat:0|intcomma }} is the amount it would take to make this ebook free to the world tomorrow.</span>
{% endifequal %}
</div>
{% ifnotequal work.last_campaign.type 3 %}
<div class="campaign-status-info explainer">
{% ifequal work.last_campaign.type 1 %}
<span>{{ work.last_campaign.countdown }}</span> to go
{% else %}
<span>${{ work.last_campaign.left|floatformat:0|intcomma }}</span> to go
<span class="explanation">${{ work.last_campaign.left|floatformat:0|intcomma }} is the amount it would take to make this ebook free to the world tomorrow.</span>
{% endifequal %}
</div>
{% endifnotequal %}
</div>
{% else %}
{% ifequal status 'SUCCESSFUL' %}
@ -178,7 +197,7 @@
1 Ungluer has
{% else %}
{{ wishers }} Ungluers have
{% endif %} Listed this Work
{% endif %} Faved this Work
</div>
{% endifequal %}
<div class="find-book">
@ -204,19 +223,19 @@
<div class="btn_wishlist" id="wishlist_actions">
{% if request.user.is_anonymous %}
<div class="create-account">
<span title="{% url work work_id %}">Login to Add</span>
<span title="{% url work work_id %}">Login to Fave</span>
</div>
{% else %}{% if request.user.id in work.last_campaign.supporters %}
<div class="add-wishlist">
<span class="on-wishlist">On My List!</span>
<span class="on-wishlist">Faved!</span>
</div>
{% else %}{% if work in request.user.wishlist.works.all %}
<div class="remove-wishlist-workpage">
<span id="w{{ work_id }}">Remove from My List</span>
<span id="w{{ work_id }}">Remove from My Faves</span>
</div>
{% else %}
<div class="add-wishlist">
<span class="work_id" id="w{{ work_id }}">Add to My List</span>
<span class="work_id" id="w{{ work_id }}">Add to My Faves</span>
</div>
{% endif %}{% endif %}{% endif %}
</div>
@ -235,13 +254,17 @@
<div id="content-block-content">
<div id="tabs-1" class="tabs {% if activetab == '1' %}active{% endif %}">
<div class="tabs-content">
{% if status == 'ACTIVE' or status == 'SUCCESSFUL' %}
<div itemprop="description">{{ work.last_campaign.description|safe }}</div>
<div itemprop="description">
{% if status == 'ACTIVE' %}
{% if work.last_campaign.type != 3 %}
{{ work.last_campaign.description|safe }}
{% else %}
{{ work.description|safe }}
{% endif %}
{% else %}
<h3 class="tabcontent-title">{{work.title}}</h3>
<p itemprop="description">{{ work.description|safe }}
</p>
{{ work.description|safe }}
{% endif %}
</div>
</div>
</div>
<div id="tabs-2" class="tabs {% if activetab == '2' %}active{% endif %}">
@ -303,7 +326,7 @@
<div id="tabs-4" class="tabs {% if activetab == '4' %}active{% endif %}">
<div class="tabs-content">
{% if status == 'ACTIVE' %}
{% ifequal work.last_campaign 1 %}
{% ifequal work.last_campaign.type 1 %}
<h3 class="tabcontent-title">A campaign is running to unglue <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
@ -312,7 +335,8 @@
{% endfor %}
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) if ungluers can join together to raise ${{ work.last_campaign.target|floatformat:0|intcomma }} by {{ work.last_campaign.deadline }}.
You can help!</p>
{% else %}
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
<h3 class="tabcontent-title">A Buy-to-Unglue Campaign is running to unglue <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
@ -322,6 +346,16 @@
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) on {{ work.last_campaign.cc_date }}. For every copy that ungluers purchase, that date gets sooner. ${{ work.last_campaign.left|floatformat:0|intcomma }} of sales will unglue the book <i>TODAY</i>.
You can help!</p>
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
<h3 class="tabcontent-title">A Thanks-for-Ungluing Campaign is running to reward the creators of <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has released <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) .
You can help us say "Thank You!" so that other creators will do the same.</p>
{% endifequal %}
<h4>Campaign details: the fine print</h4>
{{ work.last_campaign.details|safe }}
{% endif %}
@ -474,6 +508,11 @@
{% else %}
<div class="btn_support"><form action="{% url pledge work_id %}" method="get"><input type="submit" value="Pledge" /></form></div>
{% endif %}
{% else %}{% if work.last_campaign.type == 3 %}
<div class="btn_support">
<a href="{% url download work_id %}" class="hijax"><span>Download</span></a>
</div>
<div style="text-align: center;">... and thank the creators!</div>
{% else %}
{% if license_is_active %}
<div class="btn_support">
@ -484,7 +523,7 @@
{% else %}
<div class="btn_support"><form action="{% url purchase work_id %}" method="get"><input type="submit" value="{% if next_acq %}{% if on_hold %}On Hold{% else %}Reserve{% endif %}{% else %}Purchase{% endif %}" /></form></div>
{% endif %}{% endif %}
{% endif %}
{% endif %}{% endif %}
{% else %}
{% if work.first_ebook %}
<div class="btn_support">
@ -618,7 +657,8 @@
{% endif %}
</ul>
</div>
{% else %}
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
{% if lib_licenses.available %}
<h3 class="jsmod-title"><span>Borrow</span></h3>
<div class="jsmod-content">
@ -672,6 +712,32 @@
</div>
{% endif %}
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
<h3 class="jsmod-title"><span>Thank the Creators</span></h3>
<div class="jsmod-content">
<ul class="support menu">
{% if purchased %}
<li class="first no_link">
<span class="menu-item-desc">You're welcome!</span>
</li>
{% else %}
<li class="first last">
{% if request.user.library %}
<a href="{% url thank work_id %}?offer_id={{work.last_campaign.library_offer.id}}">
<span class="menu-item-price">${{ work.last_campaign.library_offer.price|floatformat:0|intcomma }}</span>
<span class="menu-item-desc">{{ work.last_campaign.library_offer.get_thanks_display }}</span>
</a>
{% else %}
<a href="{% url thank work_id %}?offer_id={{work.last_campaign.individual_offer.id}}">
<span class="menu-item-price">${{ work.last_campaign.individual_offer.price|floatformat:0|intcomma }}</span>
<span class="menu-item-desc">{{ work.last_campaign.individual_offer.get_thanks_display }}</span>
</a>
{% endif %}
</li>
{% endif %}
</ul>
</div>
{% endifequal %}
</div>
{% endif %}
</div>

View File

@ -62,8 +62,8 @@
<div class="content-block-heading wantto" id="tabs">
<ul class="tabs">
<li class="tabs1"><a href="#">Unglued<br />({{ counts.unglued }})</a></li>
<li class="tabs2"><a href="#">Active<br />({{ counts.unglueing }})</a></li>
<li class="tabs3"><a href="#">Unglue It!<br />({{ counts.wished }})</a></li>
<li class="tabs2"><a href="#">Ungluing<br />({{ counts.unglueing }})</a></li>
<li class="tabs3"><a href="#">Not Yet<br />({{ counts.wished }})</a></li>
</ul>
<ul class="book-list-view">
<li>View As:</li>

View File

@ -109,7 +109,7 @@ class CampaignUiTests(TestCase):
self.work = Work(title="test Work")
self.work.save()
self.campaign = Campaign(target=D('1000.00'), deadline=now() + timedelta(days=180),
work=self.work)
work=self.work, description='dummy description')
self.campaign.save()
rh = RightsHolder(owner = self.user, rights_holder_name = 'rights holder name')
@ -162,7 +162,7 @@ class PledgingUiTests(TestCase):
# load a Work and a Campaign to create a Pledge page
self.work = self.user.wishlist.works.all()[0]
self.campaign = Campaign(target=D('1000.00'), deadline=now() + timedelta(days=180),
work=self.work)
work=self.work, description='dummy description')
self.campaign.save()
rh = RightsHolder(owner = self.user, rights_holder_name = 'rights holder name')

View File

@ -38,6 +38,7 @@ from regluit.frontend.views import (
send_to_kindle,
MARCUngluifyView,
MARCConfigView,
DownloadView,
)
urlpatterns = patterns(
@ -88,7 +89,8 @@ urlpatterns = patterns(
url(r"^work/(?P<work_id>\d+)/acks/$", "work", {'action': 'acks'}, name="work_acks"),
url(r"^work/(?P<work_id>\d+)/lockss/$", "lockss", name="lockss"),
url(r"^lockss/(?P<year>\d+)/$", "lockss_manifest", name="lockss_manifest"),
url(r"^work/(?P<work_id>\d+)/download/$", "download", name="download"),
url(r"^work/(?P<work_id>\d+)/download/$", DownloadView.as_view(), name="download"),
url(r"^work/(?P<work_id>\d+)/download/$", DownloadView.as_view(), name="thank"),
url(r"^work/(?P<work_id>\d+)/unglued/(?P<format>\w+)/$", "download_campaign", name="download_campaign"),
url(r"^work/(?P<work_id>\d+)/borrow/$", "borrow", name="borrow"),
url(r"^work/(?P<work_id>\d+)/reserve/$", "reserve", name="reserve"),
@ -107,10 +109,10 @@ urlpatterns = patterns(
url(r"^gift/credit/(?P<token>.+)/$", login_required(GiftCredit.as_view()), name="gift_credit"),
url(r"^pledge/(?P<work_id>\d+)/$", login_required(PledgeView.as_view(),login_url='/accounts/login/pledge/'), name="pledge"),
url(r"^pledge/cancel/(?P<campaign_id>\d+)$", login_required(PledgeCancelView.as_view()), name="pledge_cancel"),
url(r"^fund/complete/$", login_required(FundCompleteView.as_view()), name="pledge_complete"),
url(r"^fund/complete/$", FundCompleteView.as_view(), name="pledge_complete"),
url(r"^pledge/modified/$", login_required(PledgeModifiedView.as_view()), name="pledge_modified"),
url(r"^pledge/modify/(?P<work_id>\d+)$", login_required(PledgeView.as_view()), name="pledge_modify"),
url(r"^payment/fund/(?P<t_id>\d+)$", login_required(FundView.as_view()), name="fund" ),
url(r"^payment/fund/(?P<t_id>\d+)$", FundView.as_view(), name="fund" ),
url(r"^pledge/recharge/(?P<work_id>\d+)$", login_required(PledgeRechargeView.as_view()), name="pledge_recharge"),
url(r"^purchase/(?P<work_id>\d+)/$", login_required(PurchaseView.as_view(),login_url='/accounts/login/purchase/'), name="purchase"),
url(r"^purchase/(?P<work_id>\d+)/download/$", "download_purchased", name="download_purchased"),

View File

@ -29,7 +29,7 @@ from django.contrib import messages
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.contrib.auth.views import login,password_reset
from django.contrib.auth.views import login,password_reset, redirect_to_login
from django.contrib.comments import Comment
from django.contrib.sites.models import Site
from django.core import signing
@ -83,6 +83,7 @@ from regluit.frontend.forms import (
ProfileForm,
CampaignPledgeForm,
CampaignPurchaseForm,
CampaignThanksForm,
GoodreadsShelfLoadingForm,
RightsHolderForm,
UserClaimForm,
@ -102,6 +103,7 @@ from regluit.frontend.forms import (
PledgeCancelForm,
getTransferCreditForm,
CCForm,
AnonCCForm,
CloneCampaignForm,
PlainCCForm,
WorkForm,
@ -342,14 +344,8 @@ def work(request, work_id, action='display'):
except:
pledged = None
logger.info("pledged: {0}".format(pledged))
cover_width_number = 0
try:
assert not (work.last_campaign_status() == 'ACTIVE' and work.first_ebook())
except:
logger.warning("Campaign running for %s when ebooks are already available: why?" % work.title )
if work.last_campaign_status() == 'ACTIVE':
cover_width_number = cover_width(work)
@ -1177,8 +1173,9 @@ class PurchaseView(PledgeView):
return {'initial':self.data}
def get_preapproval_amount(self):
self.offer_id = self.request.REQUEST.get('offer_id', None)
if not self.offer_id:
if not self.offer_id and self.work.last_campaign() and self.work.last_campaign().individual_offer:
self.offer_id = self.work.last_campaign().individual_offer.id
preapproval_amount = None
if self.offer_id != None:
@ -1203,21 +1200,30 @@ class PurchaseView(PledgeView):
logger.error("Attempt to produce transaction id {0} failed".format(t.id))
return HttpResponse("Our attempt to enable your transaction failed. We have logged this error.")
class FundView(FormView):
template_name="fund_the_pledge.html"
form_class = CCForm
transaction = None
action = None
def get_form_class(self):
if self.request.user.is_anonymous():
return AnonCCForm
else:
return CCForm
def get_form_kwargs(self):
kwargs = super(FundView, self).get_form_kwargs()
assert self.request.user.is_authenticated()
#assert self.request.user.is_authenticated()
if self.transaction is None:
self.transaction = get_object_or_404(Transaction, id=self.kwargs["t_id"])
self.action = 'pledge' if self.transaction.campaign.type == REWARDS else 'purchase'
if self.transaction.campaign.type == REWARDS:
self.action = 'pledge'
elif self.transaction.campaign.type == THANKS:
self.action = 'contribution'
else:
self.action = 'purchase'
if kwargs.has_key('data'):
data = kwargs['data'].copy()
@ -1226,7 +1232,7 @@ class FundView(FormView):
data.update(
{'preapproval_amount':self.transaction.needed_amount,
'username':self.request.user.username,
'username':self.request.user.username if self.request.user.is_authenticated else None,
'work_id':self.transaction.campaign.work.id,
'title':self.transaction.campaign.work.title}
)
@ -1250,40 +1256,42 @@ class FundView(FormView):
donate_args['data']['preapproval_amount']=self.transaction.needed_amount
context['donate_form'] = DonateForm(**donate_args)
return context
def post(self, request, *args, **kwargs):
logger.info('request.POST: {0}'.format(request.POST))
return super(FundView, self).post(request, *args, **kwargs)
def form_valid(self, form):
""" note desire to pledge; make sure there is a credit card to charge"""
if self.transaction.user.id != self.request.user.id:
# trouble!
return render(self.request, "pledge_user_error.html", {'transaction': self.transaction, 'action': self.action })
p = PaymentManager()
# if the user has active account, use it. Otherwise...
if not self.request.user.profile.account:
stripe_token = form.cleaned_data["stripe_token"]
# if we get a stripe_token, create a new stripe account for the user
if stripe_token:
try:
p.make_account(user=self.request.user, host=settings.PAYMENT_PROCESSOR, token=stripe_token)
except baseprocessor.ProcessorError as e:
return render(self.request, "pledge_card_error.html", {'transaction': self.transaction, 'exception':e })
else: # empty token
e = baseprocessor.ProcessorError("Empty token")
return render(self.request, "pledge_card_error.html", {'transaction': self.transaction, 'exception':e })
self.transaction.host = settings.PAYMENT_PROCESSOR
# with the Account in hand, now do the transaction
def form_valid(self, form):
p = PaymentManager()
stripe_token = form.cleaned_data["stripe_token"]
self.transaction.host = settings.PAYMENT_PROCESSOR
return_url = "%s?tid=%s" % (reverse('pledge_complete'),self.transaction.id)
if self.action == 'pledge':
t, url = p.authorize(self.transaction, return_url = return_url )
if self.transaction.campaign.type == THANKS and self.transaction.user == None:
#anonymous user, just charge the card!
# if there's an email address, put it in the receipt column, so far unused.
self.transaction.receipt = form.cleaned_data["email"]
t, url = p.charge(self.transaction, return_url = return_url, token=stripe_token )
elif self.request.user.is_anonymous():
#somehow the user lost their login
return HttpResponseRedirect(reverse('superlogin'))
elif self.transaction.user.id != self.request.user.id:
# other sort of strange trouble!
return render(self.request, "pledge_user_error.html", {'transaction': self.transaction, 'action': self.action })
else:
t, url = p.charge(self.transaction, return_url = return_url )
# if the user has active account, use it. Otherwise...
if not self.request.user.profile.account:
# if we get a stripe_token, create a new stripe account for the user
if stripe_token:
try:
p.make_account(user=self.request.user, host=settings.PAYMENT_PROCESSOR, token=stripe_token)
except baseprocessor.ProcessorError as e:
return render(self.request, "pledge_card_error.html", {'transaction': self.transaction, 'exception':e })
else: # empty token
e = baseprocessor.ProcessorError("Empty token")
return render(self.request, "pledge_card_error.html", {'transaction': self.transaction, 'exception':e })
# with the Account in hand, now do the transaction
if self.action == 'pledge':
t, url = p.authorize(self.transaction, return_url = return_url )
else:
t, url = p.charge(self.transaction, return_url = return_url )
# redirecting user to pledge_complete/payment_complete on successful preapproval (in the case of stripe)
if url is not None:
@ -1434,15 +1442,22 @@ class FundCompleteView(TemplateView):
template_name="pledge_complete.html"
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
if context['campaign'].type == THANKS:
return DownloadView.as_view()(request, work=context['work'])
else:
if request.user.is_authenticated:
return self.render_to_response(context)
else:
return redirect_to_login(request.get_full_path())
def get_context_data(self):
# pick up all get and post parameters and display
context = super(FundCompleteView, self).get_context_data()
if self.request.user.is_authenticated():
user = self.request.user
else:
user = None
# pull out the transaction id and try to get the corresponding Transaction
transaction_id = self.request.REQUEST.get("tid")
transaction = Transaction.objects.get(id=transaction_id)
@ -1456,14 +1471,12 @@ class FundCompleteView(TemplateView):
work = None
# we need to check whether the user tied to the transaction is indeed the authenticated user.
try:
if user.id != transaction.user.id:
# should be 403 -- but let's try 404 for now -- 403 exception coming in Django 1.4
raise Http404
except Exception, e:
if transaction.campaign.type == THANKS and transaction.user == None:
pass
elif self.request.user.id != transaction.user.id:
# should be 403 -- but let's try 404 for now -- 403 exception coming in Django 1.4
raise Http404
# check that the user had not already approved the transaction
# do we need to first run PreapprovalDetails to check on the status
@ -1476,9 +1489,15 @@ class FundCompleteView(TemplateView):
# add the work corresponding to the Transaction on the user's wishlist if it's not already on the wishlist
# fire add-wishlist notification if needed
if user is not None and correct_transaction_type and (campaign is not None) and (work is not None):
if transaction.user is not None and correct_transaction_type and (campaign is not None) and (work is not None):
# ok to overwrite Wishes.source?
user.wishlist.add_work(work, 'pledging', notify=True)
transaction.user.wishlist.add_work(work, 'pledging', notify=True)
else:
#put info into session for download page to pick up.
self.request.session['amount']= transaction.amount
if transaction.receipt:
self.request.session['receipt']= transaction.receipt
context["transaction"] = transaction
context["work"] = work
@ -2466,44 +2485,25 @@ def emailshare(request, action):
work_id = next.split('/')[-2]
work_id = int(work_id)
work = models.Work.objects.get(pk=work_id)
if action == 'pledge':
message = render_to_string('emails/i_just_pledged.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
subject = "Help me unglue "+work.title
else:
try:
status = work.last_campaign().status
except:
status = None
# customize the call to action depending on campaign status
if status == 'SUCCESSFUL' or work.first_ebook():
message = render_to_string('emails/read_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
subject = 'I think you\'d like this book I\'m reading'
elif status == 'ACTIVE':
message = render_to_string('emails/pledge_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
subject = 'Please help me give this book to the world'
else:
message = render_to_string('emails/wish_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
subject = 'Come see one of my favorite books on Unglue.it'
form = EmailShareForm(initial={ 'next':next, 'subject': subject, 'message': message})
if not action:
status = work.last_campaign().status
except:
pass
if action == 'pledge':
message = render_to_string('emails/i_just_pledged.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
context = {'request':request,'work':work,'site': Site.objects.get_current(), 'action': action}
if work and action :
message = render_to_string('emails/i_just_pledged.txt', context)
subject = "Help me unglue "+work.title
else:
# customize the call to action depending on campaign status
if status == 'ACTIVE':
message = render_to_string('emails/pledge_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
message = render_to_string('emails/pledge_this.txt', context)
subject = 'Please help me give this book to the world'
elif work:
message = render_to_string('emails/wish_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
subject = 'Come see one of my favorite books on Unglue.it'
message = render_to_string('emails/wish_this.txt', context)
subject = 'This is one of my favorite books on Unglue.it'
else:
# for email shares not bound to a campaign or pledge
message = render_to_string('emails/join_me.txt',{'request':request,'site': Site.objects.get_current()})
message = render_to_string('emails/join_me.txt', context)
subject = "Help me give books to the world"
form = EmailShareForm(initial={ 'next':next, 'subject': subject, 'message': message})
@ -2596,81 +2596,134 @@ def lockss_manifest(request, year):
return render(request, "lockss_manifest.html", {'ebooks':ebooks, 'year': year})
def download(request, work_id):
context = {}
work = safe_get_work(work_id)
site = Site.objects.get_current()
context.update({'work': work, 'site': site})
class DownloadView(PurchaseView):
template_name="download.html"
form_class = CampaignThanksForm
def show_beg(self):
if not self.campaign or self.campaign.type != THANKS:
return False
elif self.user_license and self.user_license.thanked:
return self.request.REQUEST.has_key('offer_id')
else:
return True
def form_valid(self, form):
p = PaymentManager()
t, url = p.process_transaction('USD', form.cleaned_data["preapproval_amount"],
host = PAYMENT_HOST_NONE,
campaign=self.campaign,
user=self.request.user,
paymentReason="Unglue.it Contribution for {0}".format(self.campaign.name),
pledge_extra=form.trans_extra,
)
if url:
return HttpResponseRedirect(url)
else:
logger.error("Attempt to produce transaction id {0} failed".format(t.id))
return HttpResponse("Our attempt to set up your contribution failed. We have logged this problem.")
unglued_ebooks = work.ebooks().filter(edition__unglued=True)
other_ebooks = work.ebooks().filter(edition__unglued=False)
def get_form_kwargs(self):
if self.kwargs.has_key('work'):
self.work = self.kwargs["work"]
self.show_beg= lambda: False
else:
self.work = safe_get_work(self.kwargs["work_id"])
self.campaign = self.work.last_campaign()
self.user_license = self.work.get_user_license(self.request.user)
self.data = {
'preapproval_amount':self.get_preapproval_amount(),
'anonymous':True if self.request.user.is_anonymous() else self.request.user.profile.anon_pref,
}
if self.request.method == 'POST':
self.data.update(self.request.POST.dict())
if not self.request.POST.has_key('anonymous'):
del self.data['anonymous']
return {'data':self.data}
else:
return {'initial':self.data}
def get_context_data(self, **kwargs):
context = super(FormView, self).get_context_data(**kwargs)
# adapt funtion view to class view
work = self.work
request = self.request
site = Site.objects.get_current()
unglued_ebooks = work.ebooks().filter(edition__unglued=True)
other_ebooks = work.ebooks().filter(edition__unglued=False)
acq=None
formats = {} # a dict of format name and url
for ebook in work.ebooks().all():
formats[ebook.format] = reverse('download_ebook', args=[ebook.id] )
acq=None
formats = {} # a dict of format name and url
for ebook in work.ebooks().all():
formats[ebook.format] = reverse('download_ebook', args=[ebook.id] )
if request.user.is_authenticated():
all_acqs=request.user.acqs.filter(work=work).order_by('-created')
for an_acq in all_acqs:
if not an_acq.expired:
# prepare this acq for download
if not an_acq.watermarked or an_acq.watermarked.expired:
if not an_acq.on_reserve:
watermark_acq.delay(an_acq)
acq = an_acq
formats['epub']= reverse('download_acq', kwargs={'nonce':acq.nonce, 'format':'epub'})
formats['mobi']= reverse('download_acq', kwargs={'nonce':acq.nonce, 'format':'mobi'})
readmill_epub_url = settings.BASE_URL + formats['epub']
can_kindle = True
break
if request.user.is_authenticated():
all_acqs=request.user.acqs.filter(work=work).order_by('-created')
for an_acq in all_acqs:
if not an_acq.expired:
# prepare this acq for download
if not an_acq.watermarked or an_acq.watermarked.expired:
if not an_acq.on_reserve:
watermark_acq.delay(an_acq)
acq = an_acq
formats['epub']= reverse('download_acq', kwargs={'nonce':acq.nonce, 'format':'epub'})
formats['mobi']= reverse('download_acq', kwargs={'nonce':acq.nonce, 'format':'mobi'})
readmill_epub_url = settings.BASE_URL + formats['epub']
can_kindle = True
break
if not acq:
# google ebooks have a captcha which breaks some of our services
non_google_ebooks = work.ebooks().exclude(provider='Google Books')
if not acq:
# google ebooks have a captcha which breaks some of our services
non_google_ebooks = work.ebooks().exclude(provider='Google Books')
#send to kindle
#send to kindle
try:
non_google_ebooks.filter(format='mobi')[0]
can_kindle = True
except IndexError:
try:
non_google_ebooks.filter(format='pdf')[0]
non_google_ebooks.filter(format='mobi')[0]
can_kindle = True
except IndexError:
can_kindle = False
# configure the readmillurl
try:
readmill_epub_ebook = non_google_ebooks.filter(format='epub')[0]
if readmill_epub_ebook.url.startswith('https'):
readmill_epub_url = settings.BASE_URL_SECURE + reverse('download_ebook',args=[readmill_epub_ebook.id])
else:
readmill_epub_url = settings.BASE_URL + reverse('download_ebook',args=[readmill_epub_ebook.id])
#readmill_epub_url = readmill_epub_ebook.url
except:
readmill_epub_url = None
agent = request.META.get('HTTP_USER_AGENT','')
iOS = 'iPad' in agent or 'iPhone' in agent or 'iPod' in agent
iOS_app = iOS and not 'Safari' in agent
android = 'Android' in agent
desktop = not iOS and not android
context.update({
'unglued_ebooks': unglued_ebooks,
'other_ebooks': other_ebooks,
'formats': formats,
'readmill_epub_url': readmill_epub_url,
'can_kindle': can_kindle,
'base_url': settings.BASE_URL_SECURE,
'iOS': iOS,
'iOS_app': iOS_app,
'android': android,
'desktop': desktop,
'acq':acq,
})
return render(request, "download.html", context)
try:
non_google_ebooks.filter(format='pdf')[0]
can_kindle = True
except IndexError:
can_kindle = False
# configure the readmillurl
try:
readmill_epub_ebook = non_google_ebooks.filter(format='epub')[0]
if readmill_epub_ebook.url.startswith('https'):
readmill_epub_url = settings.BASE_URL_SECURE + reverse('download_ebook',args=[readmill_epub_ebook.id])
else:
readmill_epub_url = settings.BASE_URL + reverse('download_ebook',args=[readmill_epub_ebook.id])
#readmill_epub_url = readmill_epub_ebook.url
except:
readmill_epub_url = None
agent = request.META.get('HTTP_USER_AGENT','')
iOS = 'iPad' in agent or 'iPhone' in agent or 'iPod' in agent
iOS_app = iOS and not 'Safari' in agent
android = 'Android' in agent
desktop = not iOS and not android
context.update({
'unglued_ebooks': unglued_ebooks,
'other_ebooks': other_ebooks,
'formats': formats,
'readmill_epub_url': readmill_epub_url,
'can_kindle': can_kindle,
'base_url': settings.BASE_URL_SECURE,
'iOS': iOS,
'iOS_app': iOS_app,
'android': android,
'desktop': desktop,
'acq':acq,
'show_beg': self.show_beg,
'preapproval_amount': self.get_preapproval_amount(),
'work': work,
'site': site,
'action': "Contribution",
'user_license': self.user_license,
'amount': self.request.session.pop('amount') if self.request.session.has_key('amount') else None,
})
return context
@login_required
def borrow(request, work_id):

View File

@ -80,7 +80,7 @@ class Processor:
"""a function that returns for the given payment processor"""
requires_explicit_preapprovals=False
def make_account(self, user, token=None):
def make_account(self, user=None, token=None):
"""template function for return a payment.Account corresponding to the payment system"""
return None

View File

@ -617,7 +617,7 @@ class PaymentManager( object ):
logger.info("Authorize Error: " + p.error_string())
return transaction, None
def charge(self, transaction, return_url=None, paymentReason="unglue.it Purchase"):
def charge(self, transaction, return_url=None, paymentReason="unglue.it Purchase", token = None):
'''
charge
@ -643,7 +643,7 @@ class PaymentManager( object ):
if not success: #shouldn't happen
logger.error('could not use credit for transaction %s' % transaction.id)
charge_amount =transaction.max_amount
p = transaction.get_payment_class().Pay(transaction, amount=charge_amount, return_url=return_url, paymentReason=paymentReason)
p = transaction.get_payment_class().Pay(transaction, amount=charge_amount, return_url=return_url, paymentReason=paymentReason, token=token)
if p.success() and not p.error():
@ -706,7 +706,7 @@ class PaymentManager( object ):
)
t.save()
# does user have enough credit to transact now?
if user.credit.available >= amount :
if user.is_authenticated() and user.credit.available >= amount :
# YES!
return_path = "{0}?{1}".format(reverse('pledge_complete'),
urllib.urlencode({'tid':t.id}))
@ -956,7 +956,7 @@ class PaymentManager( object ):
logger.info("Refund Transaction " + str(transaction.id) + " Failed with error: " + p.error_string())
return False
def make_account(self, user, host, token=None):
def make_account(self, user=None, host=None, token=None):
"""delegate to a specific payment module the task of creating a payment account"""
mod = __import__("regluit.payment." + host, fromlist=[host])

View File

@ -122,6 +122,8 @@ class Transaction(models.Model):
@property
def needed_amount(self):
if self.user == None or self.user.is_anonymous():
return self.max_amount
if self.user.credit.available >= self.max_amount:
return 0
else:
@ -129,6 +131,8 @@ class Transaction(models.Model):
@property
def credit_amount(self):
if self.user == None or self.user.is_anonymous():
return 0
if self.user.credit.available >= self.max_amount:
return self.max_amount
return self.user.credit.available
@ -200,6 +204,8 @@ class Transaction(models.Model):
@classmethod
def create(cls,amount=0.00, host=PAYMENT_HOST_NONE, max_amount=0.00, currency='USD',
status=TRANSACTION_STATUS_NONE,campaign=None, user=None, pledge_extra=None):
if user and user.is_anonymous():
user = None
if pledge_extra:
t = cls.objects.create(amount=amount,
host=host,

View File

@ -563,7 +563,7 @@ class StripePaymentRequest(baseprocessor.BasePaymentRequest):
class Processor(baseprocessor.Processor):
def make_account(self, user, token=None):
def make_account(self, user=None, token=None, email=None):
"""returns a payment.models.Account based on stripe token and user"""
if token is None or len(token) == 0:
@ -573,8 +573,11 @@ class Processor(baseprocessor.Processor):
# create customer and charge id and then charge the customer
try:
customer = sc.create_customer(card=token, description=user.username,
if user:
customer = sc.create_customer(card=token, description=user.username,
email=user.email)
else:
customer = sc.create_customer(card=token, description='anonymous user', email=email)
except stripe.StripeError as e:
raise StripelibError(e.message, e)
@ -588,7 +591,7 @@ class Processor(baseprocessor.Processor):
card_country = customer.active_card.country,
user = user
)
if user.profile.account:
if user and user.profile.account:
user.profile.account.deactivate()
account.save()
account.recharge_failed_transactions()
@ -650,9 +653,10 @@ class Processor(baseprocessor.Processor):
'''
The pay function generates a redirect URL to approve the transaction
If the transaction has a null user (is_anonymous), then a token musr be supplied
'''
def __init__( self, transaction, return_url=None, amount=None, paymentReason=""):
def __init__( self, transaction, return_url=None, amount=None, paymentReason="", token=None):
self.transaction=transaction
self.url = return_url
@ -660,8 +664,11 @@ class Processor(baseprocessor.Processor):
transaction.date_authorized = now_val
# ASSUMPTION: a user has any given moment one and only one active payment Account
account = transaction.user.profile.account
if token:
# user is anonymous
account = transaction.get_payment_class().make_account(token = token, email = transaction.receipt)
else:
account = transaction.user.profile.account
if not account:
logger.warning("user {0} has no active payment account".format(transaction.user))
@ -704,7 +711,7 @@ class Processor(baseprocessor.Processor):
class Execute(StripePaymentRequest):
'''
The Execute function attempts to charge the credit card of stripe Customer associated with user connected to transaction
The Execute function attempts to charge the credit card of stripe Customer associated with user connected to transaction.
'''
def __init__(self, transaction=None):
@ -731,7 +738,7 @@ class Processor(baseprocessor.Processor):
# useful things to put in description: transaction.id, transaction.user.id, customer_id, transaction.amount
charge = sc.create_charge(transaction.amount, customer=customer_id,
description=json.dumps({"t.id":transaction.id,
"email":transaction.user.email,
"email":transaction.user.email if transaction.user else transaction.receipt,
"cus.id":customer_id,
"tc.id": transaction.campaign.id,
"amount": float(transaction.amount)}))

View File

@ -327,7 +327,7 @@ class TransactionTest(TestCase):
# valid card and Account
card0 = card()
stripe_processor = Processor()
account = stripe_processor.make_account(user,token=card0)
account = stripe_processor.make_account(user=user,token=card0)
w = Work()
w.save()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

BIN
static/images/header/anonuser.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -16,11 +16,11 @@ $j().ready(function() {
// actually perform action
if (id_type=='work_id'){
jQuery.post('/wishlist/', { 'add_work_id': id_val}, function(data) {
span.html('On Wishlist!').addClass('on-wishlist');
span.html('Faved!').addClass('on-wishlist');
});}
else if (id_type=='gb_id'){
jQuery.post('/wishlist/', { 'googlebooks_id': id_val}, function(data) {
span.html('On Wishlist!').addClass('on-wishlist');
span.html('Faved!').addClass('on-wishlist');
});}
else {
span.html('a type error occurred');
@ -80,7 +80,7 @@ $k(document).on("click", ".add-wishlist-workpage span", function() {
if (!work_id) return;
jQuery.post('/wishlist/', {'add_work_id': work_id}, function(data) {
span.fadeOut();
var newSpan = $k('<span class="on-wishlist">On Wishlist!</span>').hide();
var newSpan = $k('<span class="on-wishlist">Faved!</span>').hide();
span.replaceWith(newSpan);
newSpan.fadeIn('slow');
newSpan.removeAttr("id");

View File

@ -213,7 +213,7 @@ span.menu-item-price {
border-color: white;
}
&.address, &#card_Number {
&.address, &#card_Number, &#id_email {
width: 61%;
}
}

View File

@ -985,3 +985,33 @@ li.checked {
line-height: 30px;
font-size: 15px;
}
.contrib_amount {
padding: 10px;
font-size: @font-size-header;
text-align: center;
}
#id_preapproval_amount {
width: 50%;
line-height: 30px;
font-size: @font-size-larger;
}
#begblock {
float:right;
width:280px;
background: @pale-blue;
padding: 10px;
}
.rh_beg {
font-size: @font-size-larger;
}
#contribsubmit {
text-align: center;
font-size: @font-size-header;
margin: 0 0 10px;
cursor: pointer;
}
#anoncontribbox {
padding-bottom: 10px;
}