Merge branch 'master' into ebook_selling
Resolved Conflicts: frontend/templates/download.html frontend/views.py static/css/enhanced_download.css static/css/enhanced_download_ie.css static/css/sitewide4.css static/js/download_page.js static/less/enhanced_download.less static/less/enhanced_download_ie.less static/less/sitewide4.lesspull/1/head
commit
2a7a42fbfe
|
@ -64,8 +64,8 @@ class BookLoaderTests(TestCase):
|
|||
# edition
|
||||
edition = bookloader.add_by_isbn('0441007465')
|
||||
self.assertEqual(edition.title, 'Neuromancer')
|
||||
self.assertEqual(edition.publication_date, u'2000-07-01')
|
||||
self.assertEqual(edition.publisher, u'Ace Trade')
|
||||
self.assertEqual(edition.publication_date, u'2000')
|
||||
self.assertEqual(edition.publisher, u'Penguin')
|
||||
self.assertEqual(edition.isbn_10, '0441007465')
|
||||
self.assertEqual(edition.isbn_13, '9780441007462')
|
||||
self.assertEqual(edition.googlebooks_id, 'IDFfMPW32hQC')
|
||||
|
@ -88,8 +88,8 @@ class BookLoaderTests(TestCase):
|
|||
self.assertEqual(edition.work.publishers().count(), 1)
|
||||
old_pub_name.publisher = pub
|
||||
old_pub_name.save()
|
||||
edition.set_publisher(u'Ace Trade')
|
||||
self.assertEqual(edition.publisher, u'test publisher name') # Ace Trade has been aliased
|
||||
edition.set_publisher(u'Penguin')
|
||||
self.assertEqual(edition.publisher, u'test publisher name') # Penguin has been aliased
|
||||
# locale in language
|
||||
edition = bookloader.add_by_isbn('9787500676911')
|
||||
self.assertEqual(edition.work.language, 'zh')
|
||||
|
@ -715,8 +715,8 @@ class DownloadPageTest(TestCase):
|
|||
|
||||
anon_client = Client()
|
||||
response = anon_client.get("/work/%s/download/" % w.id, follow=True)
|
||||
self.assertContains(response, "/download_ebook/%s/"% eb1.id, count=4) #the extra is readmill
|
||||
self.assertContains(response, "/download_ebook/%s/"% eb2.id, count=3)
|
||||
self.assertContains(response, "/download_ebook/%s/"% eb1.id, count=9)
|
||||
self.assertContains(response, "/download_ebook/%s/"% eb2.id, count=4)
|
||||
|
||||
|
||||
class LocaldatetimeTest(TestCase):
|
||||
|
|
|
@ -76,7 +76,7 @@ location.hash = "#2";
|
|||
</div>
|
||||
<div id="content-block-content">
|
||||
{% ifequal campaign_list.count 0 %}
|
||||
There aren't any {{ pub_lang|ez_lang_name }} ungluing campaigns active yet. If you're an author, publisher, or other rights holder, you can <a href="/faq/rightsholders">start one</a>.
|
||||
There aren't any {{ pub_lang|ez_lang_name }} ungluing campaigns active right now. If you're an author, publisher, or other rights holder, you can <a href="/faq/rightsholders">start one</a>.
|
||||
{% else %}
|
||||
{% lazy_paginate 20 campaign_list using "campaign_list" %}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ $j(document).ready(function() {
|
|||
<div id="lightbox_content">
|
||||
<div class="border">
|
||||
<h2>Downloads for <I><a href="{% url work work.id %}">{{ work.title }}</a></i></h2>
|
||||
<div class="sharing not_unglued">
|
||||
<div class="sharing ebook_download_container">
|
||||
<h3 class="jsmod-title"><span>Share</span></h3>
|
||||
<ul class="social menu">
|
||||
{% with site.domain as domain %}
|
||||
|
@ -31,43 +31,76 @@ $j(document).ready(function() {
|
|||
<a href="https://twitter.com/intent/tweet?url={{ request.build_absolute_uri|urlencode:"" }}&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 %}
|
||||
<a href="{% url emailshare '' %}?next={% url work work.id %}"><li class="email"><span>Email</span></li></a>
|
||||
<a href="#" id="embed2"><li class="embed"><span>Embed</span></li></a>
|
||||
<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"><iframe src="https://{{ request.META.HTTP_HOST }}/api/widget/{{ work.first_isbn_13 }}/" width="152" height="325" frameborder="0"></iframe></textarea></div>
|
||||
</ul>
|
||||
</div>
|
||||
{% if readmill_epub_url or kindle_ebook_id %}
|
||||
<div class="one_click clearfix">
|
||||
<h3>One-click options</h3>
|
||||
{% if kindle_ebook_id %}
|
||||
<div id="kindle_div">
|
||||
{% if request.user.is_authenticated and request.user.profile.kindle_email %}
|
||||
<div class="yes_js">
|
||||
<div id="kindle" class="btn_support authenticated" title="{{ kindle_ebook_id }}" >
|
||||
<a>Send to Kindle</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="no_js">
|
||||
<form method="POST" class="btn_support" action="{% url send_to_kindle kindle_ebook_id 0 %}">
|
||||
<input type="submit" value="Send to Kindle">
|
||||
</form>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="btn_support kindle">
|
||||
<a href="{% url kindle_config_download kindle_ebook_id %}">Set up Kindle </a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if readmill_epub_url %}
|
||||
<div id="readmill_div" class="yes_js">
|
||||
<div class="send-to-readmill" data-download-url="{{ readmill_epub_url }}" data-buy-url="{{ base_url }}{% url work work.id %}"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if not request.user.is_authenticated %}
|
||||
<div style="clear:left"> You'll need an unglue.it account to <i>Send to Kindle</i>.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if unglued_ebooks or other_ebooks %}
|
||||
<div class="ebook_download_container">
|
||||
{% endif %}
|
||||
{% if unglued_ebooks %}
|
||||
<div class="unglued">
|
||||
<h3>Read the unglued edition!</h3>
|
||||
<h3>Download the unglued edition</h3>
|
||||
<div class="ebook_download">
|
||||
{% for ebook in unglued_ebooks %}
|
||||
<a href="{% url download_ebook ebook.id %}">
|
||||
<img src="{{ ebook.rights_badge }}" alt="{{ ebook.rights}}" title="{{ ebook.rights}}" /></a>
|
||||
<a href="{% url download_ebook ebook.id %}"><img src="/static/images/{{ ebook.format }}32.png" height="32" alt="{{ ebook.format }}" title="{{ ebook.format }}" /></a>
|
||||
<a href="{% url download_ebook ebook.id %}">{{ ebook.format }}</a>
|
||||
{% ifequal ebook.format 'mobi' %} (use for Kindle){% endifequal %}
|
||||
{% ifequal ebook.format 'epub' %} (use for Nook, Apple, Sony){% endifequal %}
|
||||
{% if not forloop.last %}<br /><br />{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if other_ebooks %}
|
||||
<div class="not_unglued">
|
||||
{% if unglued_ebook %}
|
||||
<h4>Other freely available editions</h4>
|
||||
<h4>Download other freely available editions</h4>
|
||||
{% else %}
|
||||
<h4>Freely available editions</h4>
|
||||
<h4>Download freely available editions</h4>
|
||||
{% endif %}
|
||||
<div class="ebook_download">
|
||||
{% for ebook in other_ebooks %}
|
||||
<a href="{% url download_ebook ebook.id %}">
|
||||
<img src="{{ ebook.rights_badge }}" alt="{{ ebook.rights}}" title="{{ ebook.rights}}" /></a>
|
||||
<a href="{% url download_ebook ebook.id %}"><img src="/static/images/{{ ebook.format }}32.png" height="32" alt="{{ ebook.format }} at {{ebook.provider}}" title="{{ ebook.format }} at {{ebook.provider}}" /></a>
|
||||
<a href="{% url download_ebook ebook.id %}">{{ ebook.format }} at {{ ebook.provider }}</a>
|
||||
{% ifequal ebook.format 'mobi' %} (use for Kindle){% endifequal %}
|
||||
{% ifequal ebook.format 'epub' %} (use for Nook, Apple, Sony){% endifequal %}
|
||||
{% if not forloop.last %}<br /><br />{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if unglued_ebooks or other_ebooks %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
@ -77,23 +110,22 @@ $j(document).ready(function() {
|
|||
<div class="instructions">
|
||||
<div id="iOS_app_div"{% if iOS_app %} class="active"{% endif %}>
|
||||
<p>
|
||||
Looks like you're using an embedded browser in an iOS app (maybe you followed a link in Twitter or Facebook?).
|
||||
Looks like you're using an embedded browser inside an iOS app. (Maybe you followed a link in Twitter or Facebook?)
|
||||
</p>
|
||||
<p>
|
||||
{% if formats.epub %}
|
||||
Embedded browsers don't always know how to handle ebooks. We recommend downloading the <a href="{% url download_ebook formats.epub.id %}">epub file</a> using Safari.
|
||||
{% else %}{% if formats.pdf %}
|
||||
Embedded browsers don't always know how to handle ebooks. We recommend downloading the <a href="{% url download_ebook formats.pdf.id %}">pdf</a> file using Safari.
|
||||
{% if formats.epub or formats.mobi %}
|
||||
To read this ebook you should open this page in safari. <img width="500" height="403" src="/static/images/open_safari.png" alt="how to open in safari" /><br clear="left" />
|
||||
{% endif %}
|
||||
{% if formats.pdf %}
|
||||
You should also be able to use the <a href="{% url download_ebook formats.pdf.id %}">pdf</a> file.
|
||||
{% else %}{% if formats.html %}
|
||||
You can read the <a href="{% url download_ebook formats.html.id %}">HTML version</a> of this book right here in this browser.
|
||||
{% else %}{% if formats.text %}
|
||||
You can read the <a href="{% url download_ebook formats.text.id %}">text version</a> of this book right here in this browser.
|
||||
{% else %}
|
||||
This ebook is only available in .mobi. Your best bet is to download the Amazon Kindle app to this device and then use the Send-to-Kindle option above.
|
||||
{% endif %}{% endif %}{% endif %}{% endif %}
|
||||
{% endif %}{% endif %}{% endif %}
|
||||
</p>
|
||||
<p class="other_instructions_paragraph">
|
||||
Not on iOS? Try the instructions for <a href="#" id="android" class="other_instructions">Android</a>, <a href="#" id="desktop" class="other_instructions">desktop computers</a>, or <a href="#" id="ereader" class="other_instructions">ereaders (Kindle, Nook, Kobo, etc.)</a>.
|
||||
Not on iOS? Try the instructions for <a class="android other_instructions">Android</a>, <a class="desktop other_instructions">desktop computers</a>, or <a class="ereader other_instructions">ereaders (Kindle, Nook, Kobo, etc.)</a>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
@ -109,6 +141,12 @@ $j(document).ready(function() {
|
|||
<li>Download the <a href="{% url download_ebook formats.epub.id %}">epub file</a>.</li>
|
||||
<li>You will be given the option of opening the file in iBooks.</li>
|
||||
</ul>
|
||||
<p class="ebook_download logo"><img src="/static/images/readmill_logo.jpg" alt="iBooks Logo" />Readmill is another great option. </p>
|
||||
<ul>
|
||||
<li><a href="https://itunes.apple.com/us/app/readmill-book-reader-for-epub/id438032664?mt=8">Download the free Readmill app</a> from the App Store.</li>
|
||||
<li>Click the "Send to Readmill" button above.</li>
|
||||
<li>If you don't have a free Readmill account, you'll be given the option of creating one.</li>
|
||||
</ul>
|
||||
{% else %}{% if formats.pdf %}
|
||||
<p>
|
||||
You may already have an app which reads ebooks. Download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a> and see if you're offered an option for opening the file. If so, you're done! If not...
|
||||
|
@ -133,11 +171,11 @@ $j(document).ready(function() {
|
|||
</p>
|
||||
{% endif %}{% endif %}{% endif %}{% endif %}
|
||||
<p class="other_instructions_paragraph">
|
||||
Not on iOS? Try the instructions for <a href="#" id="android" class="other_instructions">Android</a>, <a href="#" id="desktop" class="other_instructions">desktop computers</a>, or <a href="#" id="ereader" class="other_instructions">ereaders (Kindle, Nook, Kobo, etc.)</a>.
|
||||
Not on iOS? Try the instructions for <a class="android other_instructions">Android</a>, <a class="desktop other_instructions">desktop computers</a>, or <a class="ereader other_instructions">ereaders (Kindle, Nook, Kobo, etc.)</a>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="android_div"{% if android %}class="active"{% endif %}>
|
||||
<div id="android_div"{% if android %} class="active"{% endif %}>
|
||||
<h4>Android devices</h4>
|
||||
{% if formats.epub %}
|
||||
<p>
|
||||
|
@ -175,12 +213,12 @@ $j(document).ready(function() {
|
|||
</p>
|
||||
{% endif %}{% endif %}{% endif %}{% endif %}
|
||||
<p class="other_instructions_paragraph">
|
||||
Not on Android? Try the instructions for <a href="#" id="ios" class="other_instructions">iPhone/iPad</a>, <a href="#" id="desktop" class="other_instructions">desktop computers</a>, or <a href="#" id="ereader" class="other_instructions">ereaders (Kindle, Nook, Kobo, etc.)</a>.
|
||||
Not on Android? Try the instructions for <a class="ios other_instructions">iPhone/iPad</a>, <a class="desktop other_instructions">desktop computers</a>, or <a class="ereader other_instructions">ereaders (Kindle, Nook, Kobo, etc.)</a>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="desktop_div"{% if desktop %} class="active"{% endif %}>
|
||||
<h4>PC, Mac, or Linux</h4>
|
||||
<h4>Reading on a PC, Mac, or Linux</h4>
|
||||
{% if formats.pdf %}
|
||||
<p>
|
||||
You probably already have an app which reads PDFs. Download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a> and open it.
|
||||
|
@ -209,20 +247,20 @@ $j(document).ready(function() {
|
|||
</p>
|
||||
{% endif %}{% endif %}{% endif %}{% endif %}
|
||||
<p class="other_instructions_paragraph">
|
||||
Not on a desktop computer? Try the instructions for <a href="#" id="ios" class="other_instructions">iPhone/iPad</a>, <a href="#" id="android" class="other_instructions">Android</a>, or <a href="#" id="ereader" class="other_instructions">ereaders (Kindle, Nook, Kobo, etc.)</a>.
|
||||
Not on a desktop computer, or want to "side-load" ebooks onto a device or app? Try the instructions for <a class="ios other_instructions">iPhone/iPad</a>, <a class="android other_instructions">Android</a>, or <a class="ereader other_instructions">ereaders (Kindle, Nook, Kobo, etc.)</a>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="ereader_div"{% if desktop %}class="active"{% endif %}>
|
||||
<div id="ereader_div"{% if desktop %} class="active"{% endif %}>
|
||||
<h4>Ereaders (Kindle, Nook, Kobo, etc.)</h4>
|
||||
|
||||
{% if formats.mobi or formats.pdf or formats.epub %}
|
||||
<ul>
|
||||
<li>
|
||||
{% if formats.mobi %}
|
||||
<b>Kindle</b>: download the <a href="{% url download_ebook formats.mobi.id %}">mobi file</a> to your computer.
|
||||
<b>Kindle</b>: download the <a href="{% url download_ebook formats.mobi.id %}">mobi file</a> to your computer, or use the <i>Send To Kindle</i> button above.
|
||||
{% else %}{% if formats.pdf %}
|
||||
<b>Kindle</b>: download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a> to your computer.
|
||||
<b>Kindle</b>: download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a> to your computer, or use the <i>Send To Kindle</i> button above.
|
||||
{% else %}
|
||||
<b>Kindle</b>: We're sorry; we don't have a version suitable for Kindle.
|
||||
{% endif %}{% endif %}
|
||||
|
@ -245,79 +283,11 @@ $j(document).ready(function() {
|
|||
</p>
|
||||
{% endif %}
|
||||
<p class="other_instructions_paragraph">
|
||||
Not using an ereader? Try the instructions for <a href="#" id="ios" class="other_instructions">iPhone/iPad</a>, <a href="#" id="android" class="other_instructions">Android</a>, or <a href="#" id="desktop" class="other_instructions">desktop computers</a>.
|
||||
Not using an ereader? Try the instructions for <a class="ios other_instructions">iPhone/iPad</a>, <a class="android other_instructions">Android</a>, or <a class="desktop other_instructions">desktop computers</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if kindle_ebook_id %}
|
||||
<div id="kindle_div">
|
||||
<h4>Send to Kindle</h4>
|
||||
{% if request.user.is_authenticated and request.user.profile.kindle_email %}
|
||||
<div class="yes_js">
|
||||
<p>Sending...<img src="/static/images/loading.gif"></p>
|
||||
<p>(For large files, this may take some time.)</p>
|
||||
<p>If your Kindle email has changed, you can <a href="{% url kindle_config %}">add the new one to Unglue.it here</a>.</p>
|
||||
</div>
|
||||
<div class="no_js">
|
||||
<p>
|
||||
<form method="POST" action="{% url send_to_kindle kindle_ebook_id 0 %}">
|
||||
<input type="submit" value="Send it!">
|
||||
</form>
|
||||
</p>
|
||||
<p>(For large files, this may take some time.)</p>
|
||||
<p>If your Kindle email has changed, you can <a href="{% url kindle_config %}">add the new one to Unglue.it here</a>.</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<ul>
|
||||
<li>
|
||||
Add kindle@gluejar.com to your approved personal document list under Personal Document Settings at your <a href="http://amazon.com/myk" target="_blank">Amazon Manage Your Kindle page</a>.
|
||||
</li>
|
||||
<li>
|
||||
Then, enter your Kindle address below.
|
||||
</li>
|
||||
</ul>
|
||||
<div class="yes_js">
|
||||
<form method="POST" action="{% url send_to_kindle kindle_ebook_id 1 %}">
|
||||
<label for="kindle_email">Your Kindle email address</label>
|
||||
<input type="text" name="kindle_email">
|
||||
<input type="submit" value="Send it!">
|
||||
</form>
|
||||
<p>
|
||||
(This may take a moment.)
|
||||
</p>
|
||||
</div>
|
||||
<div class="no_js">
|
||||
<form method="POST" action="{% url send_to_kindle kindle_ebook_id 0 %}">
|
||||
<label for="kindle_email">Your Kindle email address</label>
|
||||
<input type="text" name="kindle_email">
|
||||
<input type="submit" value="Send it!">
|
||||
</form>
|
||||
<p>
|
||||
(This may take a moment.)
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% comment %}
|
||||
will need to deal with readmill handling later
|
||||
|
||||
{% if readmill_epub_url %}
|
||||
<div id="readmill_div">
|
||||
<h4>Readmill users</h4>
|
||||
<p>
|
||||
If you're a <a href="http://readmill.com/">Readmill</a> member, you can send unglued ebooks to your iPad with one click. Here you go:
|
||||
</p>
|
||||
<div class="send-to-readmill" data-download-url="{{ readmill_epub_url }}" data-buy-url="{{ base_url }}{% url work work.id %}" data-display="small"></div>
|
||||
<p>
|
||||
If you're not, Readmill is a reading app designed for beauty, sharing, and conversation. You can <a href="https://readmill.com/">learn more and get Readmill here</a>.
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endcomment %}
|
||||
|
||||
{% comment %}
|
||||
If we're going to be providing mobi as the norm, let's not bother with these instructions.
|
||||
<div class="instructions">
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<ul>
|
||||
<li>Want to <a href="{% url auth_password_change %}">change your password</a>?</li>
|
||||
<li>... or <a href="{% url manage_account %}">manage your pledges and payment info</a>?</li>
|
||||
<li>... or <a href="{% url regluit.frontend.views.edit_user %}"">change your username</a>?</li>
|
||||
<li>... or <a href="{% url regluit.frontend.views.edit_user %}">change your username</a>?</li>
|
||||
<li>... or <a href="{% url notification_notice_settings %}">manage your contact preferences</a>?</li>
|
||||
<li>... or <a href="{% url kindle_config %}">add or change a Send-to-Kindle email?</a>?</li>
|
||||
</ul>
|
||||
|
|
|
@ -3,12 +3,37 @@
|
|||
|
||||
{% block title %}Kindle email change successful{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
<script>
|
||||
var $j = jQuery.noConflict();
|
||||
|
||||
$j(document).ready(function() {
|
||||
var kindle_ebook_id = {{ kindle_ebook_id }};
|
||||
if(kindle_ebook_id) {
|
||||
$j.post('/send_to_kindle/' + kindle_ebook_id + '/1/', function(data) {
|
||||
$j('#replace_me').html(data);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block ce_content %}
|
||||
<h2>Kindle email change successful</h2>
|
||||
<div id="content-main">
|
||||
<p>Hooray! We can now send unglued ebooks to you at {{ request.user.profile.kindle_email }}.</p>
|
||||
<p>Why not <a href="{% url unglued_list '' %}">start downloading free books</a>?
|
||||
{% if kindle_ebook_id %}
|
||||
<p>
|
||||
We're emailing you the ebook you wanted, <i><a href="{% url work work.id %}">{{ work.title }}</a></i>...
|
||||
</p>
|
||||
<span id="replace_me"><img src="{{ STATIC_URL }}images/loading.gif"></span>
|
||||
{% else %}
|
||||
<p>
|
||||
Why not <a href="{% url unglued_list '' %}">start downloading free books</a>?
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endwith %}
|
||||
|
|
|
@ -2,21 +2,60 @@
|
|||
|
||||
{% block title %}Add or change your Kindle email{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
<script>
|
||||
var $j = jQuery.noConflict();
|
||||
|
||||
$j(document).ready(function() {
|
||||
var kindle_ebook_id = {{ kindle_ebook_id }};
|
||||
if(kindle_ebook_id) {
|
||||
$j.post('/send_to_kindle/' + kindle_ebook_id + '/1/', function(data) {
|
||||
$j('#replace_me').html(data);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block ce_content %}
|
||||
{% with request.user.profile.kindle_email as kindle_email %}
|
||||
<h2>Add or change your Kindle email</h2>
|
||||
<div id="content-main">
|
||||
{% if kindle_email %}
|
||||
<p>You already have a Kindle email on file with Unglue.it: {{ kindle_email }} .</p>
|
||||
<p>You can change it below.</p>
|
||||
{% if kindle_ebook_id %}
|
||||
<p>
|
||||
Welcome back, {{ user.username }}! We're sending <I><a href="{% url work work.id %}">{{ work.title }}</a></I> to {{ kindle_email }}.
|
||||
</p>
|
||||
<span id="replace_me"><img src="{{ STATIC_URL }}images/loading.gif"></span>
|
||||
<p>
|
||||
(If you'd like to change your Kindle email, you can do so below. You'll need to download the book again.)
|
||||
</p>
|
||||
{% else %}
|
||||
<p>You already have a Kindle email on file with Unglue.it: {{ kindle_email }} .</p>
|
||||
<p>You can change it below.</p>
|
||||
<p>
|
||||
If you emailed yourself an Unglue.it ebook and got a message from Amazon that the sender is not in your approved email list, add <b>notices@gluejar.com</b> to your <a href="http://www.amazon.com/myk#pdocSettings">Approved Personal Document Email List</a> under Personal Document Settings.
|
||||
</p>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<p>Enter your Kindle email address below:</p>
|
||||
<p>
|
||||
Before your device or app can receive emails from Unglue.it, you'll have to add <b>notices@gluejar.com</b> to your <a href="http://www.amazon.com/myk#pdocSettings">Approved Personal Document Email List</a> under Personal Document Settings.
|
||||
</p>
|
||||
<p>Then, enter your Kindle email address below:</p>
|
||||
{% endif %}
|
||||
{% if kindle_ebook_id %}
|
||||
<form method="post" action="{% url kindle_config_download kindle_ebook_id %}">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="{% if kindle_email %}Change{% else %}Add{% endif %}" />
|
||||
</form>
|
||||
{% else %}
|
||||
<form method="post" action="{% url kindle_config %}">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="{% if kindle_email %}Change{% else %}Add{% endif %}" />
|
||||
</form>
|
||||
{% endif %}
|
||||
<form method="post" action="{% url kindle_config %}">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="{% if kindle_email %}Change{% else %}Add{% endif %}" />
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
document.getElementById('id_kindle_email').focus()
|
||||
</script>
|
||||
|
@ -24,11 +63,7 @@
|
|||
|
||||
<div>
|
||||
<p>Don't know the email address for your device or reading app? <a href="http://www.amazon.com/myk#manageDevices">Find it here</a>, under Manage Your Devices.</p>
|
||||
|
||||
{% if not kindle_email %}
|
||||
<p>Before your device or app can receive emails from Unglue.it, you'll have to add <b>kindle@gluejar.com</b> to your <a href="http://www.amazon.com/myk#pdocSettings">Approved Personal Document Email List</a> under Personal Document Settings.</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<p>Once we have your Kindle email, you'll be able to send unglued ebooks to your Kindle device or app with one click from any Unglue.it download page.</p>
|
||||
</div>
|
||||
{% endwith %}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
{% extends "registration/registration_base.html" %}
|
||||
|
||||
{% block doccontent %}
|
||||
{{ message }}
|
||||
{% include "kindle_response_message.html" %}
|
||||
|
||||
<p>
|
||||
You can <a href="{{ request.session.next_page }}download">go back</a> to the book you were downloading.
|
||||
</p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,8 @@
|
|||
{% ifequal message 0 %}This ebook is too big to be sent by email. Please download the file and then sideload it to your device using the instructions under Ereaders or Desktop.
|
||||
{% endifequal %}
|
||||
{% ifequal message 1 %}Well, this is awkward. We can't seem to email that. Please download it using the instructions for your device, and we'll look into the error.
|
||||
{% endifequal %}
|
||||
{% ifequal message 2 %}This book has been sent to your Kindle. Happy reading!<br />Difficulties? recheck your <a href="{% url kindle_config %}">setup</a>.
|
||||
{% endifequal %}
|
||||
{% ifequal message 3 %}Please <a href="{% url kindle_config %}">enter</a> a valid Kindle email.
|
||||
{% endifequal %}
|
|
@ -26,14 +26,14 @@ Make sure the username box has your <b>username, not your email</b> -- some brow
|
|||
<br />
|
||||
|
||||
|
||||
<a href="{% url auth_password_reset %}?next={% if request.session.next_page %}{{ request.session.next_page|urlencode }}{% else %}{% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}{% endif %}">Forgot</a> your password? <a href="{% url registration_register %}?next={% if request.session.next_page %}{{ request.session.next_page|urlencode }}{% else %}{% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}{% endif %}">Need an account</a>? <a href="/faq/basics/account">Other questions</a>?
|
||||
<a href="{% url auth_password_reset %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Forgot</a> your password? <a href="{% url registration_register %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Need an account</a>? <a href="/faq/basics/account">Other questions</a>?
|
||||
|
||||
|
||||
<br /><br />
|
||||
<div class="google_signup">
|
||||
<div {% if socials.google %}class="errorlist"{% endif %}>
|
||||
<div><a href="/socialauth/login/google?next={% if request.session.next_page %}{{ request.session.next_page|urlencode }}{% else %}{% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}{% endif %}"><img src="{{ STATIC_URL }}images/auth/google_32_noborder.png" alt="google" /></a></div>
|
||||
<div>Or: <a href="/socialauth/login/google?next={% if request.session.next_page %}{{ request.session.next_page|urlencode }}{% else %}{% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}{% endif %}">Sign in with Google</a></div>
|
||||
<div><a href="/socialauth/login/google?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}"><img src="{{ STATIC_URL }}images/auth/google_32_noborder.png" alt="google" /></a></div>
|
||||
<div>Or: <a href="/socialauth/login/google?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Sign in with Google</a></div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
|
|
|
@ -132,6 +132,7 @@ urlpatterns = patterns(
|
|||
url(r"^press/$","press", name="press"),
|
||||
url(r"^press_submitterator/$","press_submitterator", name="press_submitterator"),
|
||||
url(r"^accounts/edit/kindle_config/$", "kindle_config", name="kindle_config"),
|
||||
url(r"^accounts/edit/kindle_config/(?P<kindle_ebook_id>\d+)/$", "kindle_config", name="kindle_config_download"),
|
||||
url(r"^send_to_kindle/(?P<kindle_ebook_id>\d+)/(?P<javascript>\d)/$", "send_to_kindle", name="send_to_kindle"),
|
||||
url(r"^send_to_kindle/result/(?P<message>\d)/$", "send_to_kindle_graceful", name="send_to_kindle_graceful"),
|
||||
)
|
||||
|
|
|
@ -164,6 +164,7 @@ def process_kindle_email(request):
|
|||
if user.is_authenticated() and request.session.has_key('kindle_email'):
|
||||
user.profile.kindle_email = request.session['kindle_email']
|
||||
user.profile.save()
|
||||
request.session.pop('kindle_email')
|
||||
|
||||
def next(request):
|
||||
if request.COOKIES.has_key('next'):
|
||||
|
@ -2457,40 +2458,23 @@ def download(request, work_id):
|
|||
other_ebooks = work.ebooks().filter(edition__unglued=False)
|
||||
formats = {}
|
||||
|
||||
try:
|
||||
formats['epub'] = work.ebooks().filter(format='epub')[0]
|
||||
except IndexError:
|
||||
formats['epub'] = None
|
||||
try:
|
||||
formats['pdf'] = work.ebooks().filter(format='pdf')[0]
|
||||
except IndexError:
|
||||
formats['pdf'] = None
|
||||
try:
|
||||
formats['mobi'] = work.ebooks().filter(format='mobi')[0]
|
||||
except IndexError:
|
||||
formats['mobi'] = None
|
||||
try:
|
||||
formats['html'] = work.ebooks().filter(format='html')[0]
|
||||
except IndexError:
|
||||
formats['html'] = None
|
||||
try:
|
||||
formats['text'] = work.ebooks().filter(format='text')[0]
|
||||
except IndexError:
|
||||
formats['text'] = None
|
||||
for ebook in work.ebooks().all():
|
||||
formats[ebook.format] = ebook
|
||||
|
||||
if formats['mobi']:
|
||||
if formats.has_key('mobi'):
|
||||
kindle_ebook_id = formats['mobi'].id
|
||||
elif formats['pdf']:
|
||||
elif formats.has_key('pdf'):
|
||||
kindle_ebook_id = formats['pdf'].id
|
||||
else:
|
||||
kindle_ebook_id = None
|
||||
|
||||
try:
|
||||
readmill_epub_ebook = work.ebooks().filter(format='epub').exclude(provider='Google Books')[0]
|
||||
readmill_epub_url = settings.BASE_URL_SECURE + reverse('download_ebook',args=[readmill_epub_ebook.id])
|
||||
#readmill_epub_url = settings.BASE_URL_SECURE + reverse('download_ebook',args=[readmill_epub_ebook.id])
|
||||
readmill_epub_url = readmill_epub_ebook.url
|
||||
except:
|
||||
readmill_epub_url = None
|
||||
agent = request.META['HTTP_USER_AGENT']
|
||||
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
|
||||
|
@ -2568,39 +2552,47 @@ def press_submitterator(request):
|
|||
})
|
||||
|
||||
@login_required
|
||||
def kindle_config(request):
|
||||
def kindle_config(request, kindle_ebook_id=None):
|
||||
def get_title_from_kindle_id(kindle_ebook_id):
|
||||
# protect against user URL manipulation
|
||||
work = None
|
||||
if kindle_ebook_id:
|
||||
try:
|
||||
ebook = models.Ebook.objects.get(pk=kindle_ebook_id)
|
||||
work = ebook.edition.work
|
||||
except:
|
||||
kindle_ebook_id = None
|
||||
return work, kindle_ebook_id
|
||||
|
||||
(work, kindle_ebook_id) = get_title_from_kindle_id(kindle_ebook_id)
|
||||
template = "kindle_config.html"
|
||||
if request.method == 'POST':
|
||||
form = KindleEmailForm(request.POST)
|
||||
if form.is_valid():
|
||||
request.user.profile.kindle_email = form.cleaned_data['kindle_email']
|
||||
request.user.profile.save()
|
||||
return render(request, "kindle_change_successful.html")
|
||||
template = "kindle_change_successful.html"
|
||||
else:
|
||||
form = KindleEmailForm()
|
||||
|
||||
return render(request, "kindle_config.html", {'form': form})
|
||||
|
||||
kindle_response_params = [
|
||||
'This ebook is too big to be sent by email. Please download the file and then sideload it to your device using the instructions under Ereaders or Desktop.',
|
||||
"Well, this is awkward. We can't seem to email that. Please download it using the instructions for your device, and we'll look into the error.",
|
||||
'This book has been sent to your Kindle. Happy reading!',
|
||||
'Please enter a valid Kindle email.'
|
||||
]
|
||||
form = KindleEmailForm()
|
||||
return render(
|
||||
request,
|
||||
template,
|
||||
{'form': form, 'kindle_ebook_id': kindle_ebook_id, 'work': work}
|
||||
)
|
||||
|
||||
@require_POST
|
||||
@csrf_exempt
|
||||
def send_to_kindle(request, kindle_ebook_id, javascript='0'):
|
||||
# make sure to gracefully communicate with both js and non-js users
|
||||
# make sure to gracefully communicate with both js and non-js (kindle!) users
|
||||
def local_response(request, javascript, message):
|
||||
if javascript == '1':
|
||||
return HttpResponse(kindle_response_params[message])
|
||||
return render(request,'kindle_response_message.html',{'message': message} )
|
||||
else:
|
||||
# can't pass context with HttpResponseRedirect
|
||||
# must use an HttpResponse, not a render(), after POST
|
||||
return HttpResponseRedirect(reverse('send_to_kindle_graceful', args=(message,)))
|
||||
|
||||
ebook = models.Ebook.objects.get(pk=kindle_ebook_id)
|
||||
request.session['next_page'] = reverse('work', args=(ebook.edition.work.id,))
|
||||
|
||||
if request.POST.has_key('kindle_email'):
|
||||
kindle_email = request.POST['kindle_email']
|
||||
|
@ -2609,7 +2601,7 @@ def send_to_kindle(request, kindle_ebook_id, javascript='0'):
|
|||
except ValidationError:
|
||||
return local_response(request, javascript, 3)
|
||||
request.session['kindle_email'] = kindle_email
|
||||
else:
|
||||
elif request.user.is_authenticated():
|
||||
kindle_email = request.user.profile.kindle_email
|
||||
|
||||
# don't forget to increment the download counter!
|
||||
|
@ -2627,7 +2619,7 @@ def send_to_kindle(request, kindle_ebook_id, javascript='0'):
|
|||
return local_response(request, javascript, 0)
|
||||
|
||||
try:
|
||||
email = EmailMessage(from_email='kindle@gluejar.com',
|
||||
email = EmailMessage(from_email='notices@gluejar.com',
|
||||
to=[kindle_email])
|
||||
email.attach(title + '.' + ebook.format, filehandle.read())
|
||||
email.send()
|
||||
|
@ -2640,9 +2632,8 @@ def send_to_kindle(request, kindle_ebook_id, javascript='0'):
|
|||
return local_response(request, javascript, 2)
|
||||
|
||||
def send_to_kindle_graceful(request, message):
|
||||
message = kindle_response_params[int(message)]
|
||||
return render(
|
||||
request,
|
||||
'kindle_response_graceful_degradation.html',
|
||||
{'message': message}
|
||||
{'message': int(message)}
|
||||
)
|
||||
|
|
|
@ -894,67 +894,6 @@ class PaymentManager( object ):
|
|||
logger.info("Refund Transaction " + str(transaction.id) + " Failed with error: " + p.error_string())
|
||||
return False
|
||||
|
||||
def pledge(self, currency, campaign=None, user=None,
|
||||
return_url=None, nevermind_url=None, pledge_extra=None):
|
||||
'''
|
||||
pledge
|
||||
|
||||
Performs an instant payment
|
||||
|
||||
currency: a 3-letter paypal currency code, i.e. USD
|
||||
campaign: required campaign object
|
||||
user: optional user object
|
||||
return_url: url to redirect supporter to after a successful PayPal transaction
|
||||
nevermind_url: url to send supporter to if support hits cancel while in middle of PayPal transaction
|
||||
|
||||
return value: a tuple of the new transaction object and a re-direct url. If the process fails,
|
||||
the redirect url will be None
|
||||
|
||||
'''
|
||||
|
||||
amount = D('0.00')
|
||||
|
||||
t = Transaction.create(amount=amount,
|
||||
max_amount=amount,
|
||||
currency=currency,
|
||||
status=TRANSACTION_STATUS_NONE,
|
||||
campaign=campaign,
|
||||
user=user,
|
||||
pledge_extra=pledge_extra
|
||||
)
|
||||
|
||||
t.date_payment=now()
|
||||
t.execution=EXECUTE_TYPE_CHAINED_INSTANT
|
||||
t.type=PAYMENT_TYPE_INSTANT
|
||||
p = t.get_payment_class().Pay(t,return_url=return_url, nevermind_url=nevermind_url)
|
||||
|
||||
# Create a response for this
|
||||
envelope = p.envelope()
|
||||
logger.info(envelope)
|
||||
|
||||
if envelope:
|
||||
r = PaymentResponse.objects.create(api=p.api(),
|
||||
correlation_id = p.correlation_id(),
|
||||
timestamp = p.timestamp(),
|
||||
info = p.raw_response,
|
||||
transaction=t)
|
||||
|
||||
if p.success() and not p.error():
|
||||
t.pay_key = p.key()
|
||||
t.status = TRANSACTION_STATUS_CREATED
|
||||
t.save()
|
||||
|
||||
url = p.next_url()
|
||||
|
||||
logger.info("Pledge Success: " + url)
|
||||
return t, url
|
||||
|
||||
else:
|
||||
t.error = p.error_string()
|
||||
t.save()
|
||||
logger.info("Pledge Error: %s" % p.error_string())
|
||||
return t, None
|
||||
|
||||
def make_account(self, user, host, token=None):
|
||||
"""delegate to a specific payment module the task of creating a payment account"""
|
||||
|
||||
|
@ -968,10 +907,5 @@ class PaymentManager( object ):
|
|||
return Account.objects.filter(user=user, host=host)
|
||||
else:
|
||||
return Account.objects.filter(user=user, host=host, date_deactivated__isnull=True)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -97,7 +97,16 @@ except Exception, e:
|
|||
|
||||
# set default stripe api_key to that of unglue.it
|
||||
|
||||
stripe.api_key = STRIPE_SK
|
||||
stripe.api_key = STRIPE_SK
|
||||
|
||||
# maybe we should be able to set this in django.settings...
|
||||
|
||||
# to start with, let's try hard-coding the api_version
|
||||
# https://stripe.com/docs/upgrades?since=2012-07-09#api-changelog
|
||||
|
||||
#API_VERSION = '2012-07-09'
|
||||
API_VERSION = '2013-02-13'
|
||||
stripe.api_version = API_VERSION
|
||||
|
||||
# https://stripe.com/docs/testing
|
||||
|
||||
|
@ -188,6 +197,7 @@ def _isListableAPIResource(x):
|
|||
except:
|
||||
return False
|
||||
|
||||
|
||||
class StripeClient(object):
|
||||
def __init__(self, api_key=STRIPE_SK):
|
||||
self.api_key = api_key
|
||||
|
@ -391,8 +401,8 @@ class StripeErrorTest(TestCase):
|
|||
charge1 = sc.create_charge(10, 'usd', card=token2.id)
|
||||
self.assertEqual(charge1.amount, 1000)
|
||||
self.assertEqual(charge1.id[:3], "ch_")
|
||||
# disputed, failure_message, fee, fee_details
|
||||
self.assertEqual(charge1.disputed,False)
|
||||
# dispute, failure_message, fee, fee_details
|
||||
self.assertEqual(charge1.dispute,None)
|
||||
self.assertEqual(charge1.failure_message,None)
|
||||
self.assertEqual(charge1.fee,59)
|
||||
self.assertEqual(charge1.refunded,False)
|
||||
|
@ -590,8 +600,6 @@ class Processor(baseprocessor.Processor):
|
|||
transaction.date_authorized = now_val
|
||||
transaction.date_expired = expiry
|
||||
|
||||
sc = StripeClient()
|
||||
|
||||
# let's figure out what part of transaction can be used to store info
|
||||
# try placing charge id in transaction.pay_key
|
||||
# need to set amount
|
||||
|
@ -628,7 +636,30 @@ class Processor(baseprocessor.Processor):
|
|||
"""return None because no redirection to stripe is required"""
|
||||
return None
|
||||
|
||||
|
||||
class Pay(StripePaymentRequest, baseprocessor.Processor.Pay):
|
||||
|
||||
'''
|
||||
The pay function generates a redirect URL to approve the transaction
|
||||
'''
|
||||
|
||||
def __init__( self, transaction, return_url=None, amount=None, paymentReason=""):
|
||||
self.transaction=transaction
|
||||
|
||||
#def api(self):
|
||||
# return "null api"
|
||||
#
|
||||
##def exec_status( self ):
|
||||
# return None
|
||||
|
||||
def amount( self ):
|
||||
return self.transaction.amount
|
||||
|
||||
def key( self ):
|
||||
return None
|
||||
|
||||
def next_url( self ):
|
||||
return self.url
|
||||
|
||||
class Execute(StripePaymentRequest):
|
||||
|
||||
'''
|
||||
|
|
|
@ -185,72 +185,6 @@ class PledgeTest(TestCase):
|
|||
valid(url)
|
||||
except ValidationError, e:
|
||||
print e
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_pledge_single_receiver(self):
|
||||
|
||||
try:
|
||||
p = PaymentManager()
|
||||
|
||||
# Note, set this to 1-5 different receivers with absolute amounts for each
|
||||
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':20.00}]
|
||||
t, url = p.pledge('USD', receiver_list, campaign=None, list=None, user=None)
|
||||
|
||||
self.validateRedirect(t, url, 1)
|
||||
|
||||
loginSandbox(self.selenium)
|
||||
paySandbox(self, self.selenium, url)
|
||||
|
||||
# sleep to make sure the transaction has time to complete
|
||||
time.sleep(10)
|
||||
|
||||
# by now we should have received the IPN
|
||||
# right now, for running on machine with no acess to IPN, we manually update statuses
|
||||
p.checkStatus()
|
||||
t = Transaction.objects.get(id=t.id)
|
||||
|
||||
self.assertEqual(t.status, IPN_PAY_STATUS_COMPLETED)
|
||||
self.assertEqual(t.receiver_set.all()[0].status, IPN_TXN_STATUS_COMPLETED)
|
||||
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_pledge_mutiple_receiver(self):
|
||||
|
||||
p = PaymentManager()
|
||||
|
||||
# Note, set this to 1-5 different receivers with absolute amounts for each
|
||||
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':20.00},
|
||||
{'email':settings.PAYPAL_TEST_RH_EMAIL, 'amount':10.00}]
|
||||
|
||||
t, url = p.pledge('USD', receiver_list, campaign=None, list=None, user=None)
|
||||
|
||||
self.validateRedirect(t, url, 2)
|
||||
|
||||
loginSandbox(self.selenium)
|
||||
paySandbox(self, self.selenium, url)
|
||||
|
||||
# by now we should have received the IPN
|
||||
# right now, for running on machine with no acess to IPN, we manually update statuses
|
||||
p.checkStatus()
|
||||
|
||||
t = Transaction.objects.get(id=t.id)
|
||||
|
||||
self.assertEqual(t.status, IPN_PAY_STATUS_COMPLETED)
|
||||
self.assertEqual(t.receiver_set.all()[0].status, IPN_TXN_STATUS_COMPLETED)
|
||||
self.assertEqual(t.receiver_set.all()[1].status, IPN_TXN_STATUS_COMPLETED)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_pledge_too_much(self):
|
||||
|
||||
p = PaymentManager()
|
||||
|
||||
# Note, set this to 1-5 different receivers with absolute amounts for each
|
||||
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':50000.00}]
|
||||
t, url = p.pledge('USD', receiver_list, campaign=None, list=None, user=None)
|
||||
|
||||
self.validateRedirect(t, url, 1)
|
||||
|
||||
def tearDown(self):
|
||||
self.selenium.quit()
|
||||
|
@ -429,7 +363,7 @@ class AccountTest(TestCase):
|
|||
|
||||
def suite():
|
||||
|
||||
#testcases = [PledgeTest, AuthorizeTest, TransactionTest]
|
||||
#testcases = [AuthorizeTest, TransactionTest, CreditTest]
|
||||
testcases = [TransactionTest, CreditTest]
|
||||
suites = unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(testcase) for testcase in testcases])
|
||||
return suites
|
||||
|
|
|
@ -14,7 +14,6 @@ urlpatterns = patterns(
|
|||
if settings.DEBUG:
|
||||
urlpatterns += patterns(
|
||||
"regluit.payment.views",
|
||||
url(r"^testpledge", "testPledge"),
|
||||
url(r"^testauthorize", "testAuthorize"),
|
||||
url(r"^testexecute", "testExecute"),
|
||||
url(r"^testcancel", "testCancel"),
|
||||
|
|
|
@ -215,7 +215,6 @@ def testModify(request):
|
|||
return HttpResponse("Error")
|
||||
|
||||
|
||||
|
||||
'''
|
||||
http://BASE/testfinish?transaction=2
|
||||
|
||||
|
@ -235,52 +234,6 @@ def testFinish(request):
|
|||
return HttpResponse(message)
|
||||
|
||||
|
||||
|
||||
'''
|
||||
http://BASE/testpledge?campaign=2
|
||||
|
||||
Example that initiates an instant payment for a campaign
|
||||
'''
|
||||
def testPledge(request):
|
||||
|
||||
p = PaymentManager()
|
||||
|
||||
if 'campaign' in request.REQUEST.keys():
|
||||
campaign_id = request.REQUEST['campaign']
|
||||
else:
|
||||
campaign_id = None
|
||||
|
||||
# see whether there is a user logged in.
|
||||
if request.user.is_authenticated():
|
||||
user = request.user
|
||||
else:
|
||||
user = None
|
||||
|
||||
# Note, set this to 1-5 different receivers with absolute amounts for each
|
||||
#receiver_list = [{'email':TEST_RECEIVERS[0], 'amount':20.00},{'email':TEST_RECEIVERS[1], 'amount':10.00}]
|
||||
|
||||
if 'pledge_amount' in request.REQUEST.keys():
|
||||
pledge_amount = request.REQUEST['pledge_amount']
|
||||
receiver_list = [{'email':TEST_RECEIVERS[0], 'amount':pledge_amount}]
|
||||
else:
|
||||
receiver_list = [{'email':TEST_RECEIVERS[0], 'amount':78.90}, {'email':TEST_RECEIVERS[1], 'amount':34.56}]
|
||||
|
||||
if campaign_id:
|
||||
campaign = Campaign.objects.get(id=int(campaign_id))
|
||||
t, url = p.pledge('USD', TARGET_TYPE_CAMPAIGN, receiver_list, campaign=campaign, list=None, user=user, return_url=None)
|
||||
|
||||
else:
|
||||
t, url = p.pledge('USD', TARGET_TYPE_NONE, receiver_list, campaign=None, list=None, user=user, return_url=None)
|
||||
|
||||
if url:
|
||||
logger.info("testPledge: " + url)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
else:
|
||||
response = t.error
|
||||
logger.info("testPledge: Error " + str(t.error))
|
||||
return HttpResponse(response)
|
||||
|
||||
def runTests(request):
|
||||
|
||||
try:
|
||||
|
@ -292,14 +245,6 @@ def runTests(request):
|
|||
# Run the authorize test
|
||||
test = AuthorizeTest('test_authorize')
|
||||
test.run(result)
|
||||
|
||||
# Run the pledge test
|
||||
test = PledgeTest('test_pledge_single_receiver')
|
||||
test.run(result)
|
||||
|
||||
# Run the pledge failure test
|
||||
test = PledgeTest('test_pledge_too_much')
|
||||
test.run(result)
|
||||
|
||||
output = "Tests Run: " + str(result.testsRun) + str(result.errors) + str(result.failures)
|
||||
logger.info(output)
|
||||
|
|
|
@ -54,7 +54,7 @@ selenium==2.25.0
|
|||
six==1.2.0
|
||||
ssh==1.7.14
|
||||
stevedore==0.4
|
||||
stripe==1.7.4
|
||||
stripe==1.9.1
|
||||
virtualenv==1.4.9
|
||||
virtualenvwrapper==3.6
|
||||
wsgiref==0.1.2
|
||||
|
|
|
@ -1 +1 @@
|
|||
.header-text{height:36px;line-height:36px;display:block;text-decoration:none;font-weight:bold;letter-spacing:-0.05em}.panelborders{border-width:1px 0;border-style:solid none;border-color:#fff}.roundedspan{border:1px solid #d4d4d4;-moz-border-radius:7px;-webkit-border-radius:7px;border-radius:7px;padding:1px;color:#fff;margin:0 8px 0 0;display:inline-block}.roundedspan>span{padding:7px 7px;min-width:15px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;text-align:center;display:inline-block}.roundedspan>span .hovertext{display:none}.roundedspan>span:hover .hovertext{display:inline}.mediaborder{padding:5px;border:solid 5px #edf3f4}.actionbuttons{width:auto;height:36px;line-height:36px;background:#8dc63f;-moz-border-radius:32px;-webkit-border-radius:32px;border-radius:32px;color:white;cursor:pointer;font-size:13px;font-weight:bold;padding:0 15px;border:0;margin:5px 0}.errors{-moz-border-radius:16px;-webkit-border-radius:16px;border-radius:16px;border:solid #e35351 3px;clear:both;width:90%;height:auto;line-height:16px;padding:7px 0;font-weight:bold;font-size:13px;text-align:center}.errors li{list-style:none;border:0}ul.social a:hover{text-decoration:none}ul.social li{padding:5px 0 5px 30px!important;height:28px;line-height:28px!important;margin:0!important;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}ul.social li.facebook{background:url("/static/images/icons/facebook.png") 10px center no-repeat;cursor:pointer}ul.social li.facebook span{padding-left:10px}ul.social li.facebook:hover{background:#8dc63f url("/static/images/icons/facebook-hover.png") 10px center no-repeat}ul.social li.facebook:hover span{color:#fff}ul.social li.twitter{background:url("/static/images/icons/twitter.png") 10px center no-repeat;cursor:pointer}ul.social li.twitter span{padding-left:10px}ul.social li.twitter:hover{background:#8dc63f url("/static/images/icons/twitter-hover.png") 10px center no-repeat}ul.social li.twitter:hover span{color:#fff}ul.social li.email{background:url("/static/images/icons/email.png") 10px center no-repeat;cursor:pointer}ul.social li.email span{padding-left:10px}ul.social li.email:hover{background:#8dc63f url("/static/images/icons/email-hover.png") 10px center no-repeat}ul.social li.email:hover span{color:#fff}ul.social li.embed{background:url("/static/images/icons/embed.png") 10px center no-repeat;cursor:pointer}ul.social li.embed span{padding-left:10px}ul.social li.embed:hover{background:#8dc63f url("/static/images/icons/embed-hover.png") 10px center no-repeat}ul.social li.embed:hover span{color:#fff}.download_container{width:75%;margin:auto}#lightbox_content a{color:#6994a3}#lightbox_content .signuptoday a{color:white}#lightbox_content h2,#lightbox_content h3,#lightbox_content h4{margin-top:15px}#lightbox_content h2 a{font-size:18.75px}#lightbox_content .ebook_download a{margin:auto 5px auto 0;font-size:15px}#lightbox_content .ebook_download img{vertical-align:middle}#lightbox_content .logo{font-size:15px}#lightbox_content .logo img{-moz-border-radius:7px;-webkit-border-radius:7px;border-radius:7px;height:50px;width:50px;margin-right:5px}#lightbox_content .unglued,#lightbox_content .not_unglued{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;margin-left:-0.25%;padding:.5%;padding-bottom:15px;margin-bottom:5px;width:74%}#lightbox_content .unglued h3,#lightbox_content .not_unglued h3{margin-top:5px}#lightbox_content .unglued{border:solid 2px #8dc63f}#lightbox_content .not_unglued{border:solid 2px #d6dde0}#lightbox_content a.add-wishlist .on-wishlist,#lightbox_content a.success,a.success:hover{text-decoration:none;color:#3d4e53}#lightbox_content a.success,a.success:hover{cursor:default}#lightbox_content ul{padding-left:50px}#lightbox_content ul li{margin-bottom:4px}.border{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border:solid 2px #d6dde0;margin:5px auto;padding-right:5px;padding-left:5px}.sharing{float:right;padding:.5%!important;width:23%!important;min-width:105px}.sharing ul{padding:.5%!important}.sharing .jsmod-title{-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;height:auto}.sharing .jsmod-title span{padding:5%!important;color:white!important;font-style:normal}#widgetcode2{display:none;border:1px solid #d6dde0;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;padding:10px}#widgetcode2 textarea{max-width:90%}
|
||||
.header-text{height:36px;line-height:36px;display:block;text-decoration:none;font-weight:bold;letter-spacing:-0.05em}.panelborders{border-width:1px 0;border-style:solid none;border-color:#fff}.roundedspan{border:1px solid #d4d4d4;-moz-border-radius:7px;-webkit-border-radius:7px;border-radius:7px;padding:1px;color:#fff;margin:0 8px 0 0;display:inline-block}.roundedspan>span{padding:7px 7px;min-width:15px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;text-align:center;display:inline-block}.roundedspan>span .hovertext{display:none}.roundedspan>span:hover .hovertext{display:inline}.mediaborder{padding:5px;border:solid 5px #edf3f4}.actionbuttons{width:auto;height:36px;line-height:36px;background:#8dc63f;-moz-border-radius:32px;-webkit-border-radius:32px;border-radius:32px;color:white;cursor:pointer;font-size:13px;font-weight:bold;padding:0 15px;border:0;margin:5px 0}.errors{-moz-border-radius:16px;-webkit-border-radius:16px;border-radius:16px;border:solid #e35351 3px;clear:both;width:90%;height:auto;line-height:16px;padding:7px 0;font-weight:bold;font-size:13px;text-align:center}.errors li{list-style:none;border:0}ul.social a:hover{text-decoration:none}ul.social li{padding:5px 0 5px 30px!important;height:28px;line-height:28px!important;margin:0!important;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}ul.social li.facebook{background:url("/static/images/icons/facebook.png") 10px center no-repeat;cursor:pointer}ul.social li.facebook span{padding-left:10px}ul.social li.facebook:hover{background:#8dc63f url("/static/images/icons/facebook-hover.png") 10px center no-repeat}ul.social li.facebook:hover span{color:#fff}ul.social li.twitter{background:url("/static/images/icons/twitter.png") 10px center no-repeat;cursor:pointer}ul.social li.twitter span{padding-left:10px}ul.social li.twitter:hover{background:#8dc63f url("/static/images/icons/twitter-hover.png") 10px center no-repeat}ul.social li.twitter:hover span{color:#fff}ul.social li.email{background:url("/static/images/icons/email.png") 10px center no-repeat;cursor:pointer}ul.social li.email span{padding-left:10px}ul.social li.email:hover{background:#8dc63f url("/static/images/icons/email-hover.png") 10px center no-repeat}ul.social li.email:hover span{color:#fff}ul.social li.embed{background:url("/static/images/icons/embed.png") 10px center no-repeat;cursor:pointer}ul.social li.embed span{padding-left:10px}ul.social li.embed:hover{background:#8dc63f url("/static/images/icons/embed-hover.png") 10px center no-repeat}ul.social li.embed:hover span{color:#fff}.download_container{width:75%;margin:auto}#lightbox_content a{color:#6994a3}#lightbox_content .signuptoday a{color:white}#lightbox_content h2,#lightbox_content h3,#lightbox_content h4{margin-top:15px}#lightbox_content h2 a{font-size:18.75px}#lightbox_content .ebook_download a{margin:auto 5px auto 0;font-size:15px}#lightbox_content .ebook_download img{vertical-align:middle}#lightbox_content .logo{font-size:15px}#lightbox_content .logo img{-moz-border-radius:7px;-webkit-border-radius:7px;border-radius:7px;height:50px;width:50px;margin-right:5px}#lightbox_content .one_click,#lightbox_content .ebook_download_container{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;margin-left:-0.25%;padding:.5%;padding-bottom:15px;margin-bottom:5px;width:74%}#lightbox_content .one_click h3,#lightbox_content .ebook_download_container h3{margin-top:5px}#lightbox_content .one_click{border:solid 2px #8dc63f}#lightbox_content .ebook_download_container{border:solid 2px #d6dde0}#lightbox_content a.add-wishlist .on-wishlist,#lightbox_content a.success,a.success:hover{text-decoration:none;color:#3d4e53}#lightbox_content a.success,a.success:hover{cursor:default}#lightbox_content ul{padding-left:50px}#lightbox_content ul li{margin-bottom:4px}.border{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border:solid 2px #d6dde0;margin:5px auto;padding-right:5px;padding-left:5px}.sharing{float:right;padding:.5%!important;width:23%!important;min-width:105px}.sharing ul{padding:.5%!important}.sharing .jsmod-title{-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;height:auto}.sharing .jsmod-title span{padding:5%!important;color:white!important;font-style:normal}#widgetcode2{display:none;border:1px solid #d6dde0;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;padding:10px}#widgetcode2 textarea{max-width:90%}.btn_support.kindle{height:40px}.btn_support.kindle a{width:auto;font-size:15px}
|
|
@ -1 +1 @@
|
|||
.buttons,#kindle_div .yes_js,.other_instructions_paragraph{display:inherit}.instructions>div:not(.active){display:none}#kindle_div .no_js{display:none!important}
|
||||
.buttons,.yes_js,.other_instructions_paragraph{display:inherit}.instructions>div:not(.active){display:none}.no_js{display:none!important}.active{display:inherit!important}
|
|
@ -1 +1 @@
|
|||
.buttons,#kindle_div .yes_js,.other_instructions_paragraph{display:inherit}.instructions>div{display:none}#kindle_div .no_js{display:none!important}.active{display:inherit}
|
||||
.yes_js,.other_instructions_paragraph{display:inherit}.instructions>div{display:none}.no_js{display:none!important}.active{display:inherit!important}
|
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
|
@ -13,18 +13,23 @@ else {
|
|||
// browser has a better sense of DOM changes than jQuery, so user can trigger click element
|
||||
$j(document).on('click', '.other_instructions', function(e) {
|
||||
e.preventDefault();
|
||||
var myID = $j(this).attr('id');
|
||||
var divSelector = '#' + myID + '_div';
|
||||
var myLink = $j(this);
|
||||
classes = myLink.attr('class').split(' ');
|
||||
mySelector = classes[0];
|
||||
var divSelector = '#' + mySelector + '_div';
|
||||
var activeDiv = $j(divSelector);
|
||||
activeDiv.show();
|
||||
activeDiv.siblings().hide();
|
||||
activeDiv.siblings().removeClass('active').hide();
|
||||
});
|
||||
|
||||
$j(document).on('click', '#kindle.authenticated', function() {
|
||||
classes = $j(this).attr('class').split(' ');
|
||||
kindle_ebook_id = classes[0];
|
||||
var myDiv = $j(this);
|
||||
kindle_ebook_id = myDiv.attr('title');
|
||||
myDiv.html('<img src="/static/images/loading.gif">')
|
||||
$j.post('/send_to_kindle/' + kindle_ebook_id + '/1/', function(data) {
|
||||
$j('#kindle_div').html(data);
|
||||
myDiv.removeClass('btn_support');
|
||||
myDiv.html(data);
|
||||
myDiv.removeAttr('id');
|
||||
return false;
|
||||
});
|
||||
});
|
|
@ -24,18 +24,20 @@ $j(document).ready(function() {
|
|||
if ($j(this).attr("href").indexOf("download") !== -1) {
|
||||
jQuery.getScript('/static/js/download_page.js');
|
||||
jQuery.getScript('https://platform.readmill.com/send.js');
|
||||
var work_page = $j(this).attr("href").split("download")[0];
|
||||
$j.cookie('next', work_page, {path: '/'});
|
||||
}
|
||||
|
||||
//need to push next cookie for sign-in links
|
||||
var vars = $j(this).attr("href").split("next=");
|
||||
if (vars.length>1){
|
||||
next=vars[1];
|
||||
if(next!='') {
|
||||
next = next.replace(/[\x22\x27\x3c\x3e]/g,'');
|
||||
$j.cookie('next', next, {path: '/'});
|
||||
else {
|
||||
//need to push next cookie for sign-in links
|
||||
var vars = $j(this).attr("href").split("next=");
|
||||
if (vars.length>1){
|
||||
next=vars[1];
|
||||
if(next!='') {
|
||||
next = next.replace(/[\x22\x27\x3c\x3e]/g,'');
|
||||
$j.cookie('next', next, {path: '/'});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fade-out rest of page elements on expand
|
||||
$j('#feedback, #js-page-wrap, #footer').css({"opacity": "0.07"});
|
||||
$j('#about_expandable').css({'position': 'absolute'});
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#lightbox_content a {
|
||||
color: @medium-blue;
|
||||
|
||||
}
|
||||
|
||||
#lightbox_content .signuptoday a {
|
||||
|
@ -34,7 +33,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
#lightbox_content .logo {
|
||||
#lightbox_content .logo {
|
||||
img {
|
||||
.one-border-radius(7px);
|
||||
height: 50px;
|
||||
|
@ -45,7 +44,7 @@
|
|||
font-size: @font-size-larger;
|
||||
}
|
||||
|
||||
#lightbox_content .unglued, #lightbox_content .not_unglued {
|
||||
#lightbox_content .one_click, #lightbox_content .ebook_download_container {
|
||||
.one-border-radius(5px);
|
||||
margin-left: -.25%;
|
||||
padding: 0.5%;
|
||||
|
@ -58,11 +57,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
#lightbox_content .unglued {
|
||||
border: solid 2px @call-to-action;
|
||||
#lightbox_content .one_click {
|
||||
border: solid 2px @call-to-action;
|
||||
}
|
||||
|
||||
#lightbox_content .not_unglued {
|
||||
#lightbox_content .ebook_download_container {
|
||||
border: solid 2px @blue-grey;
|
||||
}
|
||||
|
||||
|
@ -122,4 +121,13 @@
|
|||
textarea {
|
||||
max-width: 90%;
|
||||
}
|
||||
}
|
||||
|
||||
.btn_support.kindle{
|
||||
height: 40px;
|
||||
|
||||
a {
|
||||
width: auto;
|
||||
font-size: @font-size-larger;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
.buttons, #kindle_div .yes_js, .other_instructions_paragraph {
|
||||
.buttons, .yes_js, .other_instructions_paragraph {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,10 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
#kindle_div .no_js {
|
||||
.no_js {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.active {
|
||||
display: inherit !important;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
.buttons, #kindle_div .yes_js, .other_instructions_paragraph {
|
||||
.yes_js, .other_instructions_paragraph {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
#kindle_div .no_js {
|
||||
.no_js {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* the not selector doesn't work in IE <= 8 */
|
||||
.active {
|
||||
display: inherit;
|
||||
display: inherit !important;
|
||||
}
|
|
@ -747,7 +747,7 @@ a.nounderline {
|
|||
}
|
||||
|
||||
#lightbox_content {
|
||||
p {
|
||||
p, li {
|
||||
padding: 9px 0;
|
||||
font-size: @font-size-larger;
|
||||
line-height: 20px;
|
||||
|
@ -922,6 +922,26 @@ li.checked {
|
|||
}
|
||||
}
|
||||
|
||||
.one_click {
|
||||
float: left;
|
||||
& > div {
|
||||
float: left;
|
||||
|
||||
#kindle a, .kindle a {
|
||||
font-size: @font-size-larger;
|
||||
padding: 9px 0;
|
||||
}
|
||||
|
||||
div {
|
||||
margin: 0 10px 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ebook_download_container {
|
||||
clear: left;
|
||||
}
|
||||
|
||||
.other_instructions_paragraph {
|
||||
display: none;
|
||||
}
|
||||
|
@ -934,6 +954,6 @@ li.checked {
|
|||
display: none;
|
||||
}
|
||||
|
||||
#kindle_div .yes_js {
|
||||
.yes_js {
|
||||
display: none;
|
||||
}
|
Loading…
Reference in New Issue