add helpful link to response from send-to-kindle

also, move the kindle result messages into a template
pull/1/head
eric 2013-06-25 01:11:43 -04:00
parent e33077138f
commit 3407b7cec4
4 changed files with 13 additions and 13 deletions

View File

@ -1,8 +1,7 @@
{% 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>

View File

@ -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 %}

View File

@ -2553,20 +2553,13 @@ def kindle_config(request, kindle_ebook_id=None):
{'form': form, 'kindle_ebook_id': kindle_ebook_id, 'title': title}
)
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.'
]
@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
@ -2613,9 +2606,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)}
)

View File

@ -27,6 +27,7 @@ $j(document).on('click', '#kindle.authenticated', function() {
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) {
myDiv.removeClass('btn_support');
myDiv.html(data);
return false;
});