From 2da4ba6f961173a4a93384b1cf5fd3ae5265ab46 Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Fri, 31 Aug 2012 13:41:16 -0400 Subject: [PATCH 01/56] starting a notification for RHs when their books are wished for --- core/models.py | 3 +- core/signals.py | 73 ++++--------------- .../notification/new_wisher/full.txt | 4 + .../notification/new_wisher/notice.html | 9 +++ .../notification/new_wisher/notice.txt | 3 + .../notification/new_wisher/short.txt | 1 + 6 files changed, 35 insertions(+), 58 deletions(-) create mode 100644 frontend/templates/notification/new_wisher/full.txt create mode 100644 frontend/templates/notification/new_wisher/notice.html create mode 100644 frontend/templates/notification/new_wisher/notice.txt create mode 100644 frontend/templates/notification/new_wisher/short.txt diff --git a/core/models.py b/core/models.py index 48c83777..a6dd3940 100755 --- a/core/models.py +++ b/core/models.py @@ -819,7 +819,8 @@ class Wishlist(models.Model): w = Wishes.objects.get(wishlist=self,work=work) except: Wishes.objects.create(source=source,wishlist=self,work=work) - work.update_num_wishes() + work.update_num_wishes() + wishlist_added.send(sender=self, work=work, supporter=self.user) def remove_work(self, work): w = Wishes.objects.filter(wishlist=self, work=work) diff --git a/core/signals.py b/core/signals.py index 880c438e..3c2711f0 100644 --- a/core/signals.py +++ b/core/signals.py @@ -97,6 +97,7 @@ def create_notice_types(app, created_models, verbosity, **kwargs): notification.create_notice_type("rights_holder_claim_approved", _("Claim Accepted"), _("A claim you've entered has been accepted.")) 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_donation_credit", _("Donation Credit Balance"), _("You have a donation credit balance")) + notification.create_notice_type("new_wisher", _("New wisher"), _("Someone new has wished for a book that you're the rightsholder for")) signals.post_syncdb.connect(create_notice_types, sender=notification) @@ -213,60 +214,18 @@ def handle_wishlist_unsuccessful_amazon(campaign, **kwargs): amazon_suspension.connect(handle_wishlist_unsuccessful_amazon) -# The notification templates need some context; I'm making a note of that here -# This can be removed as the relevant functions are written -# RIGHTS_HOLDER_CLAIM_APPROVED: -# 'site': (site) -# 'claim': (claim) -# RIGHTS_HOLDER_CREATED: (no context needed) -# note -- it might be that wishlist_near_target and wishlist_near_deadline would -# both be triggered at about the same time -- do we want to prevent supporters -# from getting both within a small time frame? if so which supersedes? -# WISHLIST_NEAR_DEADLINE: -# 'site': (site) -# 'campaign': (the campaign) -# 'pledged': (true if the supporter has pledged, false otherwise) -# 'amount': (amount the supporter has pledged; only needed if pledged is true) -# WISHLIST_NEAR_TARGET: -# 'site': (site) -# 'campaign': (the campaign) -# 'pledged': (true if the supporter has pledged, false otherwise) -# 'amount': (amount the supporter has pledged; only needed if pledged is true) -# WISHLIST_PREMIUM_LIMITED_SUPPLY: -# (note we should not send this to people who have already claimed this premium) -# should we only send this to people who haven't pledged at all, or whose pledge -# is smaller than the amount of this premium? (don't want to encourage people to -# lower their pledge) -# the text assumes there is only 1 left -- if we're going to send at some other -# threshhold this will need to be revised -# 'campaign': (campaign) -# 'premium': (the premium in question) -# 'site': (site) -# WISHLIST_PRICE_DROP: -# 'campaign' -# 'pledged': (true if recipient has pledged to campaign, otherwise false) -# 'amount': (amount recipient has pledged, only needed if pledged=True) -# 'site' -# WISHLIST_SUCCESSFUL: -# 'pledged' -# 'campaign' -# 'site' -# WISHLIST_UNSUCCESSFUL: -# 'campaign' -# 'site' -# WISHLIST_UPDATED: -# I'd like to provide the actual text of the update in the message but I don't think -# we can reasonably do that, since campaign.description may contain HTML and we are -# sending notifications in plaintext. If we can send the update information in the -# email, though, let's do that. -# 'campaign' -# 'site' -# WISHLIST_WORK_CLAIMED -# does this trigger when someone claims a work, or when the claim is approved? -# I've written the text assuming it is the latter (sending notifications on the -# former seems too sausage-making, and might make people angry if they get -# notifications about claims they believe are false). If it's the former, the -# text should be revisited. -# 'claim' -# 'site' -# 'rightsholder' (the name of the rightsholder) \ No newline at end of file +wishlist_added = Signal(providing_args=["supporter", "work"]) + +def handle_wishlist_added(supporter, work, **kwargs): + """send notification to confirmed rights holder when someone wishes for their work""" + claim = work.claim.filter(status="active") + if claim: + notification.queue([claim.user], "new_wisher", { + 'supporter': supporter, + 'work': work + }, True) + + from regluit.core.tasks import emit_notifications + emit_notifications.delay() + +wishlist_added.connect(handle_wishlist_added) diff --git a/frontend/templates/notification/new_wisher/full.txt b/frontend/templates/notification/new_wisher/full.txt new file mode 100644 index 00000000..56b6fe04 --- /dev/null +++ b/frontend/templates/notification/new_wisher/full.txt @@ -0,0 +1,4 @@ +{{ supporter }} has wished for a work you hold rights to, {{ work.title }}. Hooray! There are now {{ work.num_wishes }} people wishing for this work. + + +The Unglue.it team \ No newline at end of file diff --git a/frontend/templates/notification/new_wisher/notice.html b/frontend/templates/notification/new_wisher/notice.html new file mode 100644 index 00000000..0a11d20c --- /dev/null +++ b/frontend/templates/notification/new_wisher/notice.html @@ -0,0 +1,9 @@ +{% extends "notification/notice_template.html" %} + +{% block comments_book %} + cover image for {{ work.title }} +{% endblock %} + +{% block comments_graphical %} + {{ supporter }} has wished for a work you hold rights to, {{ work.title }}. Hooray! +{% endblock %} \ No newline at end of file diff --git a/frontend/templates/notification/new_wisher/notice.txt b/frontend/templates/notification/new_wisher/notice.txt new file mode 100644 index 00000000..ebd00571 --- /dev/null +++ b/frontend/templates/notification/new_wisher/notice.txt @@ -0,0 +1,3 @@ +{{ supporter }} has wished for a work you hold rights to, {{ work.title }}. Hooray! There are now {{ work.num_wishes }} people wishing for this work. + + diff --git a/frontend/templates/notification/new_wisher/short.txt b/frontend/templates/notification/new_wisher/short.txt new file mode 100644 index 00000000..9233e50b --- /dev/null +++ b/frontend/templates/notification/new_wisher/short.txt @@ -0,0 +1 @@ +Someone new has wished for your work at Unglue.it \ No newline at end of file From 2216369bbfea9d38bfdddcd721d7aa5bf0ddd5d9 Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Tue, 18 Sep 2012 10:16:08 -0400 Subject: [PATCH 02/56] include clickable links, make grammar singular/plural sensitive --- core/signals.py | 3 ++- frontend/templates/notification/new_wisher/full.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/signals.py b/core/signals.py index 919289aa..ae82d8a3 100644 --- a/core/signals.py +++ b/core/signals.py @@ -222,7 +222,8 @@ def handle_wishlist_added(supporter, work, **kwargs): if claim: notification.queue([claim[0].user], "new_wisher", { 'supporter': supporter, - 'work': work + 'work': work, + 'base_url': settings.BASE_URL, }, True) from regluit.core.tasks import emit_notifications diff --git a/frontend/templates/notification/new_wisher/full.txt b/frontend/templates/notification/new_wisher/full.txt index 56b6fe04..c84f7c27 100644 --- a/frontend/templates/notification/new_wisher/full.txt +++ b/frontend/templates/notification/new_wisher/full.txt @@ -1,4 +1,4 @@ -{{ supporter }} has wished for a work you hold rights to, {{ work.title }}. Hooray! There are now {{ work.num_wishes }} people wishing for this work. +{{ supporter }} ({{ base_url }}{% url supporter supporter.username %}) has wished for a work you hold rights to, {{ work.title }} ({{ base_url }}{% url work work.id %}). Hooray! {% with work.num_wishes as num_wishes %}{% if num_wishes = 1 %}Your first ungluer!{% else %}There are now {{ num_wishes }} people wishing for this work.{% endif %}{% endwith %} The Unglue.it team \ No newline at end of file From f03855f2de7936be2ebe4108836b99e30096947d Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Tue, 18 Sep 2012 11:10:01 -0400 Subject: [PATCH 03/56] bugfix [#36104625] --- frontend/templates/work.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/templates/work.html b/frontend/templates/work.html index 36b1f1e2..5aaa6ef3 100644 --- a/frontend/templates/work.html +++ b/frontend/templates/work.html @@ -72,13 +72,19 @@ $j(document).ready(function(){ Campaign suspended.
See FAQ. {% else %}{% if status == 'WITHDRAWN' %} Campaign withdrawn.
See FAQ. + {% else %}{% if wishers == 0 %} + No ungluers are wishing yet. +
+ Be the first! {% else %}{% if wishers == 1 %} {{ wishers }} Ungluer is wishing +
+ You can too! {% else %} {{ wishers }} Ungluers are wishing +
+ You can too! {% endif %} -
- You can too! {% endif %}{% endif %}{% endif %}{% endif %} {% endif %} {% else %} From 35180252e0a50fd3932e7a0b4bac554a89e047cd Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Tue, 18 Sep 2012 11:10:53 -0400 Subject: [PATCH 04/56] bugfix [#36104625] --- frontend/templates/work.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/templates/work.html b/frontend/templates/work.html index 5aaa6ef3..a206aae2 100644 --- a/frontend/templates/work.html +++ b/frontend/templates/work.html @@ -84,8 +84,7 @@ $j(document).ready(function(){ {{ wishers }} Ungluers are wishing
You can too! - {% endif %} - {% endif %}{% endif %}{% endif %}{% endif %} + {% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %} {% endif %} {% else %} From 33ef8f68445799a6310952185778cfdf45154511 Mon Sep 17 00:00:00 2001 From: thatandromeda Date: Tue, 18 Sep 2012 12:45:36 -0300 Subject: [PATCH 05/56] Update frontend/templates/press.html --- frontend/templates/press.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/templates/press.html b/frontend/templates/press.html index 537c9369..0e43ed9a 100644 --- a/frontend/templates/press.html +++ b/frontend/templates/press.html @@ -181,6 +181,10 @@ Creative Commons offers a variety of other licenses, many of them with even less

Blog Coverage (Highlights)

+
+ First Book Comes Unglued
+ Open Folklore - September 12, 2012
+
First Book Comes Unglued
The Digital Shift (Library Journal/School Library Journal) - September 12, 2012
From b0c2f0926b28ed30323e27955df846b98b07215c Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Tue, 18 Sep 2012 12:12:50 -0400 Subject: [PATCH 06/56] whoops there are other cases --- frontend/templates/work.html | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/frontend/templates/work.html b/frontend/templates/work.html index a206aae2..4e2840b2 100644 --- a/frontend/templates/work.html +++ b/frontend/templates/work.html @@ -88,14 +88,21 @@ $j(document).ready(function(){ {% endif %} {% else %} - {% if wishers == 1 %} + {% if wishers == 0 %} + No ungluers are wishing yet. +
+ Be the first! + {% else %}{% if wishers == 1 %} {{ wishers }} Ungluer is wishing + +
+ You can too! {% else %} {{ wishers }} Ungluers are wishing - {% endif %} - -
- You can too! + +
+ You can too! + {% endif %}{% endif %} {% endif %}{% endif %}
From 82f6ceffd429fdd16aab1ecf062c92d23ca949b5 Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Tue, 18 Sep 2012 13:09:19 -0400 Subject: [PATCH 07/56] addressing comment --- frontend/templates/work.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/templates/work.html b/frontend/templates/work.html index 4e2840b2..26f462a9 100644 --- a/frontend/templates/work.html +++ b/frontend/templates/work.html @@ -87,24 +87,26 @@ $j(document).ready(function(){ {% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %} {% endif %} {% else %} - {% if wishers == 0 %} - No ungluers are wishing yet. + + No ungluers are wishing yet. +
Be the first! {% else %}{% if wishers == 1 %} - {{ wishers }} Ungluer is wishing + + {{ wishers }} Ungluer is wishing
You can too! {% else %} - {{ wishers }} Ungluers are wishing + + {{ wishers }} Ungluers are wishing
You can too! {% endif %}{% endif %} {% endif %}{% endif %} -
{% include "explore.html" %} From 0de46d0bb607c6255991263375196104cc9e6bd2 Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Tue, 18 Sep 2012 13:35:14 -0400 Subject: [PATCH 08/56] DRM-free logo --- frontend/templates/download.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/templates/download.html b/frontend/templates/download.html index e8b6506b..861d7dc1 100644 --- a/frontend/templates/download.html +++ b/frontend/templates/download.html @@ -51,8 +51,8 @@ {% if unglued_ebooks or other_ebooks %}
-

How to download

-

Ebooks you find at Unglue.it may be read on any device, and you're welcome to convert them to whatever electronic format is most useful to you. While we can't cover every possible combination of readers, software, and formats you might use, here's some help for the most common cases.

+ DefectiveByDesign.org

How to download

+

Ebooks you find at Unglue.it may be read on any device, and you're welcome to convert them to whatever electronic format is most useful to you. While we can't cover every possible combination of readers, software, and formats you might use, here's some help for the most common cases.

Any device

You may already have an app which reads our ebook formats. If so, when you download the file, you will be given an option to open the file using that app. You're done!

@@ -114,9 +114,11 @@

Need help with something not listed here? Email us at support@gluejar.com.

{% else %} -

There are no freely available downloads of {{ work.title }} right now. {% if not work in request.user.wishlist.works.all %}Would you like there to be? Add this book to your wishlist.{% else %}Ask your friends to add it to their wishlists!{% endif %}

- -

If you know of a Creative-Commons-licensed or US public domain edition of this book, you can add it through the Rights tab of the book page.

+
+

There are no freely available downloads of {{ work.title }} right now. {% if not work in request.user.wishlist.works.all %}Would you like there to be? Add this book to your wishlist.{% else %}Ask your friends to add it to their wishlists!{% endif %}

+ +

If you know of a Creative-Commons-licensed or US public domain edition of this book, you can add it through the Rights tab of the book page.

+
{% endif %} From f581dd354b2b398175e262a548283c88520379e4 Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Tue, 18 Sep 2012 13:40:52 -0400 Subject: [PATCH 09/56] readmill support --- frontend/templates/download.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/templates/download.html b/frontend/templates/download.html index 861d7dc1..b5b57f58 100644 --- a/frontend/templates/download.html +++ b/frontend/templates/download.html @@ -52,13 +52,25 @@ {% if unglued_ebooks or other_ebooks %}
DefectiveByDesign.org

How to download

-

Ebooks you find at Unglue.it may be read on any device, and you're welcome to convert them to whatever electronic format is most useful to you. While we can't cover every possible combination of readers, software, and formats you might use, here's some help for the most common cases.

+

Ebooks you find at Unglue.it may be read on any device, and you're welcome to convert them to whatever electronic format is most useful to you. While we can't cover every possible combination of readers, software, and formats you might use, here's some help for the most common cases.

Any device

You may already have an app which reads our ebook formats. If so, when you download the file, you will be given an option to open the file using that app. You're done!

If this doesn't work, use the instructions below for your device.

+

Readmill users

+

If you're a Readmill member, you can send unglued ebooks to your iPad with one click. Here you go:

+
+ + +

Android devices

From f2e4647e737c3ba250ac5a73a4c02a4d29714943 Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Tue, 18 Sep 2012 14:16:06 -0400 Subject: [PATCH 10/56] lockss needs a page listing the books unglued in each year to crawl --- frontend/templates/base.html | 8 +++++++- frontend/templates/lockss_manifest.html | 14 ++++++++++++++ frontend/urls.py | 1 + frontend/views.py | 20 ++++++++++++++++++-- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 frontend/templates/lockss_manifest.html diff --git a/frontend/templates/base.html b/frontend/templates/base.html index a8fa40be..6fe18f87 100644 --- a/frontend/templates/base.html +++ b/frontend/templates/base.html @@ -99,12 +99,16 @@
+{% block news %}
It's here: our first unglued edition. You can now download Oral Literature in Africa.

Campaigns to unglue more books will relaunch soon.
+{% endblock %} + {% block topsection %}{% endblock %} {% block content %}{% endblock %} +{% block footer %} +{% endblock %} {% block counter %} {% endblock %} + +{% endblock %} diff --git a/frontend/templates/lockss_manifest.html b/frontend/templates/lockss_manifest.html new file mode 100644 index 00000000..79dcf934 --- /dev/null +++ b/frontend/templates/lockss_manifest.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block news %} +{% endblock %} + +{% block content %} +Books unglued in {{ year }} for the LOCKSS harvester to crawl.

+ {% for ebook in ebooks %} +
{{ ebook.work.title }}
+ {% endfor %} +{% endblock %} + +{% block footer %} +{% endblock %} \ No newline at end of file diff --git a/frontend/urls.py b/frontend/urls.py index d63d2765..4a5421bb 100644 --- a/frontend/urls.py +++ b/frontend/urls.py @@ -44,6 +44,7 @@ urlpatterns = patterns( url(r"^work/(?P\d+)/preview/$", "work", {'action': 'preview'}, name="work_preview"), url(r"^work/(?P\d+)/acks/$", "work", {'action': 'acks'}, name="work_acks"), url(r"^work/(?P\d+)/lockss/$", "lockss", name="lockss"), + url(r"^lockss/(?P\d+)/$", "lockss_manifest", name="lockss_manifest"), url(r"^work/(?P\d+)/download/$", "download", name="download"), url(r"^work/\d+/acks/images/(?P[\w\.]*)$", "static_redirect_view",{'dir': 'images'}), url(r"^work/(?P\d+)/librarything/$", "work_librarything", name="work_librarything"), diff --git a/frontend/views.py b/frontend/views.py index 5cdb3580..8febed4c 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -4,7 +4,7 @@ import json import logging import urllib -from datetime import timedelta +from datetime import timedelta, date from regluit.utils.localdatetime import now, date_today from random import randint @@ -2047,7 +2047,7 @@ def campaign_archive_js(request): def lockss(request, work_id): """ - manifest pages for lockss harvester + manifest pages for lockss harvester -- individual works """ work = safe_get_work(work_id) try: @@ -2058,6 +2058,22 @@ def lockss(request, work_id): return render(request, "lockss.html", {'work':work, 'ebooks':ebooks, 'authors':authors}) +def lockss_manifest(request, year): + """ + manifest pages for lockss harvester -- yearly indices + (lockss needs pages listing all books unglued by year, with + programmatically determinable URLs) + """ + year = int(year) + start_date = date(year, 1, 1) + end_date = date(year, 12, 31) + try: + ebooks = models.Edition.objects.filter(unglued=True).filter(created__range=(start_date, end_date)) + except: + ebooks = None + + return render(request, "lockss_manifest.html", {'ebooks':ebooks, 'year': year}) + def download(request, work_id): context = {} work = safe_get_work(work_id) From efa3187535e8dc03924c32028bc96c5ef858e29b Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Wed, 19 Sep 2012 10:25:23 -0400 Subject: [PATCH 11/56] dynamically generate the readmill download url don't hardcode it you moron --- frontend/templates/download.html | 2 +- frontend/views.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/templates/download.html b/frontend/templates/download.html index b5b57f58..518b3b38 100644 --- a/frontend/templates/download.html +++ b/frontend/templates/download.html @@ -61,7 +61,7 @@

Readmill users

If you're a Readmill member, you can send unglued ebooks to your iPad with one click. Here you go:

-
+
+ {% endblock %} {% block content %} @@ -61,16 +61,8 @@

Readmill users

If you're a Readmill member, you can send unglued ebooks to your iPad with one click. Here you go:

-
+
- -

Android devices

diff --git a/frontend/templates/work.html b/frontend/templates/work.html index 36b1f1e2..9b1ae1d3 100644 --- a/frontend/templates/work.html +++ b/frontend/templates/work.html @@ -7,14 +7,14 @@ {% endblock %} -{% block base_js %} - +{% block extra_js %} + -