From 51c86867a0f13c77af71bc2f9c5940f6049cca81 Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 27 Jun 2013 10:31:01 -0400 Subject: [PATCH 1/3] don't pop a param that isn't there --- frontend/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/views.py b/frontend/views.py index 3cca6b75..0308f3ad 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -2520,7 +2520,6 @@ def kindle_config(request, kindle_ebook_id=None): if form.is_valid(): request.user.profile.kindle_email = form.cleaned_data['kindle_email'] request.user.profile.save() - request.session.pop('kindle_email') template = "kindle_change_successful.html" else: form = KindleEmailForm() From 98ba975eec0089dd981a4a8616192dc193b88d5b Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 27 Jun 2013 12:00:47 -0400 Subject: [PATCH 2/3] remove conflicting "order by" --- frontend/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/views.py b/frontend/views.py index 3cca6b75..0464b459 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -681,7 +681,7 @@ class WorkListView(FilterableListView): context['ungluers'] = userlists.work_list_users(qs,5) context['facet'] = self.kwargs.get('facet','') works_unglued = qs.exclude(editions__ebooks__isnull=True).distinct() | qs.filter(campaigns__status='SUCCESSFUL').distinct() - context['works_unglued'] = works_unglued.order_by('-campaigns__status', 'campaigns__deadline', '-num_wishes')[:self.max_works] + context['works_unglued'] = works_unglued[:self.max_works] context['works_active'] = qs.filter(campaigns__status='ACTIVE').distinct()[:self.max_works] context['works_wished'] = qs.exclude(editions__ebooks__isnull=False).exclude(campaigns__status='ACTIVE').exclude(campaigns__status='SUCCESSFUL').distinct()[:self.max_works] From 9205dd6f3d3ece4776797544301e315eee41e1a5 Mon Sep 17 00:00:00 2001 From: Raymond Yee Date: Thu, 27 Jun 2013 14:14:54 -0700 Subject: [PATCH 3/3] patch to limit attempts to send to kindle files that are on the order of the size of OLA --> Amazon SES has 10 MB limit --- frontend/views.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/views.py b/frontend/views.py index 24543954..1634e429 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -2561,9 +2561,19 @@ def send_to_kindle(request, kindle_ebook_id, javascript='0'): title = ebook.edition.title title = title.replace(' ', '_') + # TO FIX rigorously: + # Amazon SES has a 10 MB size limit (http://aws.amazon.com/ses/faqs/#49) in messages sent + # to determine whether the file will meet this limit, we probably need to compare the + # size of the mime-encoded file to 10 MB. (and it's unclear exactly what the Amazon FAQ means precisely by + # MB either: http://en.wikipedia.org/wiki/Megabyte) + # http://www.velocityreviews.com/forums/t335208-how-to-get-size-of-email-attachment.html might help + + # for the moment, we will hardwire a 8x10^6 limit in filesize, which will properly block Oral Literature in Africa + # while leaving our other campaign-unglued books. + filehandle = urllib.urlopen(ebook.url) filesize = int(filehandle.info().getheaders("Content-Length")[0]) - if filesize > 26214400: + if filesize > 8000000: logger.info('ebook %s is too large to be emailed' % kindle_ebook_id) return local_response(request, javascript, 0)