From 4aeae6e67c45f6a129abefd162c01a05348ee1e7 Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 14 Dec 2017 16:24:26 -0500 Subject: [PATCH] implement donation options --- core/admin.py | 7 ++-- core/fixtures/basic_campaign_test.json | 2 +- core/fixtures/initial_data.json | 2 +- core/migrations/0012_campaign_charitable.py | 19 +++++++++++ core/models/__init__.py | 1 + core/tasks.py | 4 ++- frontend/forms/__init__.py | 5 +-- frontend/templates/book_panel.html | 14 ++++---- frontend/templates/book_panel_addbutton.html | 4 +-- frontend/templates/faq.html | 14 ++++++++ frontend/templates/faq_pledge.html | 29 ++++++++++++++--- frontend/templates/manage_campaign.html | 12 ++++++- .../notification/donation/notice.html | 4 +-- .../notification/pledge_charged/full.txt | 19 +++++++++-- .../notification/pledge_charged/notice.html | 30 ++++++++++++++++- .../notification/pledge_charged/short.txt | 2 +- .../notification/wishlist_successful/full.txt | 2 +- .../wishlist_unsuccessful/full.txt | 4 +-- .../wishlist_unsuccessful/notice.html | 8 ++--- frontend/templates/pledge.html | 19 +++++++---- frontend/templates/pledge_complete.html | 15 +++++---- frontend/templates/trans_summary.html | 19 ++++++----- frontend/templates/work_action.html | 6 ++-- frontend/templatetags/bookpanel.py | 12 +++---- frontend/views/__init__.py | 10 ++++-- payment/manager.py | 32 +++++++++++-------- .../migrations/0002_transaction_donation.py | 19 +++++++++++ payment/models.py | 31 ++++++++++-------- static/js/reconcile_pledge.js | 26 +++++++++++++++ static/scss/pledge.scss | 19 +++++++++++ 30 files changed, 291 insertions(+), 99 deletions(-) create mode 100644 core/migrations/0012_campaign_charitable.py create mode 100644 payment/migrations/0002_transaction_donation.py diff --git a/core/admin.py b/core/admin.py index f95d1612..77c24de1 100644 --- a/core/admin.py +++ b/core/admin.py @@ -68,6 +68,7 @@ class AcqAdmin(ModelAdmin): class PremiumAdmin(ModelAdmin): list_display = ('campaign', 'amount', 'description') date_hierarchy = 'created' + fields = ('type', 'amount', 'description', 'limit') class CampaignAdminForm(forms.ModelForm): managers = AutoCompleteSelectMultipleField( @@ -77,8 +78,10 @@ class CampaignAdminForm(forms.ModelForm): ) class Meta(object): model = models.Campaign - fields = ('managers', 'name', 'description', 'details', 'license', 'activated', 'paypal_receiver', - 'status', 'type', 'email', 'do_watermark', 'use_add_ask', ) + fields = ( + 'managers', 'name', 'description', 'details', 'license', 'paypal_receiver', + 'status', 'type', 'email', 'do_watermark', 'use_add_ask', 'charitable', + ) class CampaignAdmin(ModelAdmin): list_display = ('work', 'created', 'status') diff --git a/core/fixtures/basic_campaign_test.json b/core/fixtures/basic_campaign_test.json index 2ae09b46..cdc498a2 100644 --- a/core/fixtures/basic_campaign_test.json +++ b/core/fixtures/basic_campaign_test.json @@ -465,7 +465,7 @@ "pk": 150, "model": "core.premium", "fields": { - "description": "No premium, thanks! I just want to help unglue.", + "description": "Nothing extra, thanks! I just want to support this campaign.", "campaign": null, "created": "2011-11-17T22:03:37", "amount": "0", diff --git a/core/fixtures/initial_data.json b/core/fixtures/initial_data.json index 84efa3c8..e1a67274 100644 --- a/core/fixtures/initial_data.json +++ b/core/fixtures/initial_data.json @@ -98,7 +98,7 @@ "campaign": null, "amount": 0, "type": "00", - "description": "No premium, thanks! I just want to help unglue.", + "description": "Nothing extra, thanks! I just want to support this campaign", "created": "2011-11-17 22:03:37" } }, diff --git a/core/migrations/0012_campaign_charitable.py b/core/migrations/0012_campaign_charitable.py new file mode 100644 index 00000000..640c123c --- /dev/null +++ b/core/migrations/0012_campaign_charitable.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0011_auto_20171110_1253'), + ] + + operations = [ + migrations.AddField( + model_name='campaign', + name='charitable', + field=models.BooleanField(default=False), + ), + ] diff --git a/core/models/__init__.py b/core/models/__init__.py index 67bf0b67..37917b8b 100755 --- a/core/models/__init__.py +++ b/core/models/__init__.py @@ -400,6 +400,7 @@ class Campaign(models.Model): publisher = models.ForeignKey("Publisher", related_name="campaigns", null=True) do_watermark = models.BooleanField(default=True) use_add_ask = models.BooleanField(default=True) + charitable = models.BooleanField(default=False) def __init__(self, *args, **kwargs): self.problems = [] diff --git a/core/tasks.py b/core/tasks.py index 8d56f232..5240d98b 100644 --- a/core/tasks.py +++ b/core/tasks.py @@ -200,9 +200,11 @@ def notify_unclaimed_gifts(): unclaimed = Gift.objects.filter(used=None) for gift in unclaimed: """ - send notice every 7 days + send notice every 7 days, but stop at 10x """ unclaimed_duration = (now() - gift.acq.created ).days + if unclaimed_duration > 70: + return if unclaimed_duration > 0 and unclaimed_duration % 7 == 0 : # first notice in 7 days notification.send_now([gift.acq.user], "purchase_gift_waiting", {'gift':gift}, True) notification.send_now([gift.giver], "purchase_notgot_gift", {'gift':gift}, True) diff --git a/frontend/forms/__init__.py b/frontend/forms/__init__.py index be645eb0..88bfb719 100644 --- a/frontend/forms/__init__.py +++ b/frontend/forms/__init__.py @@ -385,12 +385,12 @@ class CampaignPledgeForm(forms.Form): min_value=D('1.00'), max_value=D('2000.00'), decimal_places=2, - label="Pledge Amount", + label="Support Amount", ) def amount(self): return self.cleaned_data["preapproval_amount"] if self.cleaned_data else None - anonymous = forms.BooleanField(required=False, label=_("Make this pledge anonymous, please")) + anonymous = forms.BooleanField(required=False, label=_("Make this support anonymous, please")) ack_name = forms.CharField( required=False, max_length=64, @@ -399,6 +399,7 @@ class CampaignPledgeForm(forms.Form): ack_dedication = forms.CharField(required=False, max_length=140, label=_("Your dedication:")) premium_id = forms.IntegerField(required=False) + donation = forms.BooleanField(required=False, label=_("Make this a donation, not a pledge.")) premium = None @property diff --git a/frontend/templates/book_panel.html b/frontend/templates/book_panel.html index 4058d33c..24dad3c4 100644 --- a/frontend/templates/book_panel.html +++ b/frontend/templates/book_panel.html @@ -3,7 +3,7 @@ {% load purchased %} {% load lib_acqs %} {% load bookpanel %} -{% with first_ebook=work.first_ebook supporters=work.last_campaign.supporters thumbnail=work.cover_image_thumbnail author=work.authors_short title=work.title last_campaign=work.last_campaign status=work.last_campaign.status deadline=work.last_campaign.deadline workid=work.id wishlist=request.user.wishlist.works.all %} +{% with first_ebook=work.first_ebook thumbnail=work.cover_image_thumbnail author=work.authors_short title=work.title last_campaign=work.last_campaign status=work.last_campaign.status deadline=work.last_campaign.deadline workid=work.id wishlist=request.user.wishlist.works.all %} {% purchased %}{% lib_acqs %}{% bookpanel %}
@@ -109,7 +109,7 @@ {% endif %}
- {% if request.user.id in supporters %} + {% if not supported %}
{% include "book_panel_addbutton.html" %}
@@ -119,7 +119,7 @@
{% if work.last_campaign.type == 1 %} - Pledge + Support {% elif work.last_campaign.type == 2 %} {% if in_library %} Reserve It @@ -217,9 +217,9 @@ Set {{setkw}}
{% endif %} - {% elif show_pledge %} + {% elif not supported %}
- Pledge + Support
{% elif show_purchase %}
@@ -241,8 +241,8 @@ {% if purchased.gifts.all.count %}A gift to you!{% else %}Purchased!{% endif %} {% elif borrowed %} Borrowed! ...until - {% elif request.user.id in supporters %} - Pledged! + {% elif supported %} + Supported! {% else %} Faved! {% endif %} diff --git a/frontend/templates/book_panel_addbutton.html b/frontend/templates/book_panel_addbutton.html index 02363cc5..e5196224 100644 --- a/frontend/templates/book_panel_addbutton.html +++ b/frontend/templates/book_panel_addbutton.html @@ -12,9 +12,9 @@ - {% elif request.user.id in supporters %} + {% elif supported %} {% elif supporter == request.user %} {% if wishlist %} diff --git a/frontend/templates/faq.html b/frontend/templates/faq.html index 0b13a6ba..8d244bce 100644 --- a/frontend/templates/faq.html +++ b/frontend/templates/faq.html @@ -385,6 +385,20 @@ If you want to find an interesting campaign and don't have a specific book in mi
You can offer anything you are capable of delivering, so long as it is not illegal or otherwise restricted in the United States. For instance, your premiums may not include alcohol, drugs, or firearms. For full details, consult our Terms of Use.
+
Is my campaign eligible for charitable donation support?
+ +
+The Free Ebook Foundation may provide support for some campaigns using donations. These campaigns are subject to the following guidelines: +
    +
  1. Proceeds of a campaign must not benefit a candidate for political office and books to be unglued shall not be primarily aimed at influencing legislation.
  2. +
  3. Proceeds of a campaign must not benefit organizations or individuals subject to regulation by the US Treasury’s Office of Foreign Assets Control.
  4. +
  5. Books to be unglued with Foundation support should clearly benefit the public at large - by advancing scholarship and learning, spreading scientific knowledge, achieving artistic, literary or cultural goals, educating students, promoting literacy and reading, documenting history, meeting the needs of underserved communities, raising awareness and understanding of the world around us.
  6. +
  7. The amount of support requested should be limited to the reasonable costs of producing the book and procuring associated rights. When a campaign is offered using a license with a “non-commercial” restriction, it is expected that the rights holders will bear part of these expenses themselves. When the campaign beneficiary is not a US-based non-profit, documentation of expenses may be requested.
  8. +
+ + +
+
Who is responsible for making sure a rights holder delivers premiums?
The rights holder.
diff --git a/frontend/templates/faq_pledge.html b/frontend/templates/faq_pledge.html index 5a9f5ab9..e08246fc 100644 --- a/frontend/templates/faq_pledge.html +++ b/frontend/templates/faq_pledge.html @@ -1,12 +1,26 @@
-

Pledging FAQs

+

Campaign Support FAQs

+ {% if campaign.charitable %} +
+ This campaign is eligible for charitable donation support. +
+ {% elif campaign.type == 1 %} +
+ If you believe your campaign meets the criteria for charitable donation support, use the feedback form to request a review by Free Ebook Foundation staff. +
+ {% endif %}
@@ -405,13 +414,14 @@ Please fix the following before launching your campaign:

A few things to keep in mind:

Acknowledgements

-

Your ungluers will also automatically receive the following acknowledgements:

+

Your ungluers (including thos who use donations, will also automatically receive the following acknowledgements: