regluit/frontend/templates/goodreads_display.html

134 lines
4.4 KiB
HTML
Raw Normal View History

2015-04-28 03:24:02 +00:00
{% extends 'base.html' %}
2016-05-11 14:41:50 +00:00
{% block extra_head %}
<script type="application/x-javascript">
jQuery(document).ready(function($) {
2011-11-01 22:23:54 +00:00
// post to form_loc and alert with response
var post_and_alert = function (form_loc){
return function(bubble,params) {
$.post(form_loc, params, function (data) {
alert(data);
});
return bubble;
}
};
var update_number_of_books = function (){
$.ajax({url:'/api/v1/wishlist/{{user.wishlist.id}}/',
data: {format:'json',
api_key:'{{api_key}}',
username: '{{user.username}}'},
success: function(json) {
2011-11-01 21:09:04 +00:00
$('#number_of_books_on_wishlist').html(json["works"].length);
2011-11-01 22:23:54 +00:00
var d = new Date();
$('#num_books_update_time').html(d.toUTCString());
},
error: function(jqXHR, textStatus, errorThrown) {
alert('error')
}
2011-11-01 22:23:54 +00:00
})
2011-11-01 21:09:04 +00:00
2011-11-01 22:23:54 +00:00
}
// add a current date time to the display of current number of books on wishlist
var d = new Date()
$('#num_books_update_time').html(d.toUTCString());
$('#test_click').click(update_number_of_books);
$('#clear_wishlist_form').submit(function (){
2015-04-28 03:24:02 +00:00
post_and_alert('{% url 'clear_wishlist' %}')(true,{});
2011-11-01 22:23:54 +00:00
update_number_of_books();
return false;
});
$('#load_shelf_form').submit(function(){
2015-04-28 03:24:02 +00:00
post_and_alert('{% url 'goodreads_load_shelf'%}')(false,$('#load_shelf_form').serialize());
2011-11-01 22:23:54 +00:00
return false;
});
2011-11-01 21:09:04 +00:00
});
</script>
{% endblock %}
{% block title %}Goodreads{% endblock %}
{% block content %}
<div id="main-container">
<div class="js-main">
<div id="js-maincol-fr">
<div class="js-maincol-inner">
<div id="content-block">
<h1>Goodreads</h1>
2011-11-01 21:09:04 +00:00
2011-10-29 22:40:00 +00:00
{% if user.profile.goodreads_user_id %}
<p>Welcome, Goodreads user id# {{user.profile.goodreads_user_id}}. Your GR username is {{user.profile.goodreads_user_name}} and here is <a href="{{user.profile.goodreads_user_link}}">your Goodreads profile</a>.</p>
2015-04-28 03:24:02 +00:00
<form id="clear_goodreads_id" method="post" action="{% url 'goodreads_flush_assoc' %}">
2011-11-01 21:09:04 +00:00
<p><input type="submit" value="Unlink your Goodreads account from Unglue.it" /></p>
</form>
2011-11-01 21:09:04 +00:00
<p>You can also revoke access for Unglue.it at <a href="http://www.goodreads.com/user/edit?tab=apps">Goodreads user apps panel</a>.</p>
2011-11-01 21:09:04 +00:00
<hr />
2011-11-01 22:23:54 +00:00
<form id="load_shelf_form" method="post" action="#">
{{gr_shelf_load_form.as_p}}
<input type="submit" value="Load the books from your Goodreads shelf to your faves" />
</form>
2011-11-01 17:41:39 +00:00
{% else %}
<p>We don't currently know your Goodreads user information.</p>
2011-11-01 21:09:04 +00:00
<p><a href="{{goodreads_auth_url}}">Enable Unglue.it to link to your Goodreads account</a></p>
{% endif %}
2011-11-01 21:09:04 +00:00
<hr />
<p><a href="#" id="test_click">Click here to update the number of books on your favorites list:</a></p>
<div id="gr_status"><p>Number of books on your favorites list: <span id="number_of_books_on_wishlist">{{user.wishlist.works.all|length}}</span> (as of <span id="num_books_update_time"></span>)</p></div>
2011-11-01 21:09:04 +00:00
<form id="clear_wishlist_form" method="post" action="#">
<input type="submit" value="Empty your faves" />
2011-11-01 21:09:04 +00:00
</form>
<!-- list user's books -->
{% if reviews %}
<p>Here are some of your books that you've put on your Goodreads shelves:</p>
<ul id="id">
{% for review in reviews|slice:":50" %}
<li><img src="{{review.book.small_image_url}}" /><a href="{{review.book.link}}">{{review.book.title}}</a></li>
{% endfor %}
</ul>
{% endif %}
<hr />
<!-- list any Celery tasks and status -->
{% if celerytasks %}
<p>Book Loading tasks you've initiated</p>
<ul>
{% for task in celerytasks %}
<li>{{task.task_id}} | {{task.description}} | {{task.state}}</li>
{% endfor %}
</ul>
2015-04-28 03:24:02 +00:00
<form id="clear_celery_tasks" method="post" action="{% url 'clear_celery_tasks' %}">
{% csrf_token %}
<input type="submit" value="Clear Celery Tasks" />
</form>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}