Merge branch 'master' into ry
commit
cf2e937969
|
@ -53,7 +53,7 @@ def widget(request,isbn):
|
||||||
work = identifier.work
|
work = identifier.work
|
||||||
edition = identifier.edition
|
edition = identifier.edition
|
||||||
campaigns = work.campaigns.all()
|
campaigns = work.campaigns.all()
|
||||||
except models.Identifer.DoesNotExist:
|
except models.Identifier.DoesNotExist:
|
||||||
edition = None
|
edition = None
|
||||||
work = None
|
work = None
|
||||||
campaigns = []
|
campaigns = []
|
||||||
|
|
|
@ -524,7 +524,7 @@ def load_gutenberg_edition(title, gutenberg_etext_id, ol_work_id, seed_isbn, url
|
||||||
sister_edition = add_by_isbn(seed_isbn)
|
sister_edition = add_by_isbn(seed_isbn)
|
||||||
if sister_edition.new:
|
if sister_edition.new:
|
||||||
# add related editions asynchronously
|
# add related editions asynchronously
|
||||||
regluit.core.tasks.populate_edition.delay(sister_edition)
|
regluit.core.tasks.populate_edition.delay(sister_edition.isbn_13)
|
||||||
work = sister_edition.work
|
work = sister_edition.work
|
||||||
# attach the olwk identifier to this work if it's not none.
|
# attach the olwk identifier to this work if it's not none.
|
||||||
if ol_work_id is not None:
|
if ol_work_id is not None:
|
||||||
|
|
|
@ -293,7 +293,7 @@ def load_goodreads_shelf_into_wishlist(user, shelf_name='all', goodreads_user_id
|
||||||
else:
|
else:
|
||||||
logger.error("unable to extract goodreads id from %s", link)
|
logger.error("unable to extract goodreads id from %s", link)
|
||||||
if edition.new:
|
if edition.new:
|
||||||
regluit.core.tasks.populate_edition.delay(edition)
|
regluit.core.tasks.populate_edition.delay(edition.isbn_13)
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.info ("Exception adding ISBN %s: %s", isbn, e)
|
logger.info ("Exception adding ISBN %s: %s", isbn, e)
|
||||||
|
|
|
@ -230,7 +230,7 @@ def load_librarything_into_wishlist(user, lt_username, max_books=None):
|
||||||
identifier= models.Identifier.get_or_add(type = 'lccn', value = book['lc_call_number'], edition = edition, work = edition.work)
|
identifier= models.Identifier.get_or_add(type = 'lccn', value = book['lc_call_number'], edition = edition, work = edition.work)
|
||||||
user.wishlist.add_work(edition.work, 'librarything')
|
user.wishlist.add_work(edition.work, 'librarything')
|
||||||
if edition.new:
|
if edition.new:
|
||||||
tasks.populate_edition.delay(edition)
|
tasks.populate_edition.delay(edition.isbn_13)
|
||||||
logger.info("Work with isbn %s added to wishlist.", isbn)
|
logger.info("Work with isbn %s added to wishlist.", isbn)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.info ("error adding ISBN %s: %s", isbn, e)
|
logger.info ("error adding ISBN %s: %s", isbn, e)
|
||||||
|
|
|
@ -16,4 +16,4 @@ class Command(BaseCommand):
|
||||||
user = User.objects.get(username=user_name)
|
user = User.objects.get(username=user_name)
|
||||||
max_books = int(max_books)
|
max_books = int(max_books)
|
||||||
|
|
||||||
tasks.load_goodreads_shelf_into_wishlist.delay(user, shelf_name, goodreads_user_id, max_books)
|
tasks.load_goodreads_shelf_into_wishlist.delay(user.id, shelf_name, goodreads_user_id, max_books)
|
|
@ -13,4 +13,4 @@ class Command(BaseCommand):
|
||||||
user = User.objects.get(username=user_name)
|
user = User.objects.get(username=user_name)
|
||||||
max_books = int(max_books)
|
max_books = int(max_books)
|
||||||
|
|
||||||
tasks.load_librarything_into_wishlist.delay(user, lt_username, max_books)
|
tasks.load_librarything_into_wishlist.delay(user.id, lt_username, max_books)
|
|
@ -2,25 +2,31 @@ from time import sleep
|
||||||
|
|
||||||
from celery.decorators import task
|
from celery.decorators import task
|
||||||
|
|
||||||
from regluit.core import bookloader
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
from regluit.core import bookloader, models
|
||||||
from regluit.core import goodreads, librarything
|
from regluit.core import goodreads, librarything
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def populate_edition(edition):
|
def populate_edition(isbn):
|
||||||
"""given an edition this task will populate the database with additional
|
"""given an edition this task will populate the database with additional
|
||||||
information about related editions and subjects related to this edition
|
information about related editions and subjects related to this edition
|
||||||
"""
|
"""
|
||||||
bookloader.add_related(edition.isbn_13)
|
bookloader.add_related(isbn)
|
||||||
bookloader.add_openlibrary(edition.work)
|
edition=models.Edition.get_by_isbn(isbn)
|
||||||
|
if edition:
|
||||||
|
bookloader.add_openlibrary(edition.work)
|
||||||
return edition
|
return edition
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def load_goodreads_shelf_into_wishlist(user, shelf_name='all', goodreads_user_id=None, max_books=None,
|
def load_goodreads_shelf_into_wishlist(user_id, shelf_name='all', goodreads_user_id=None, max_books=None,
|
||||||
expected_number_of_books=None):
|
expected_number_of_books=None):
|
||||||
|
user=User.objects.get(id=user_id)
|
||||||
return goodreads.load_goodreads_shelf_into_wishlist(user,shelf_name,goodreads_user_id,max_books, expected_number_of_books)
|
return goodreads.load_goodreads_shelf_into_wishlist(user,shelf_name,goodreads_user_id,max_books, expected_number_of_books)
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def load_librarything_into_wishlist(user, lt_username, max_books=None):
|
def load_librarything_into_wishlist(user_id, lt_username, max_books=None):
|
||||||
|
user=User.objects.get(id=user_id)
|
||||||
return librarything.load_librarything_into_wishlist(user, lt_username, max_books)
|
return librarything.load_librarything_into_wishlist(user, lt_username, max_books)
|
||||||
|
|
||||||
@task
|
@task
|
||||||
|
|
|
@ -90,7 +90,7 @@ class BookLoaderTests(TestCase):
|
||||||
|
|
||||||
def test_populate_edition(self):
|
def test_populate_edition(self):
|
||||||
edition = bookloader.add_by_googlebooks_id('c_dBPgAACAAJ')
|
edition = bookloader.add_by_googlebooks_id('c_dBPgAACAAJ')
|
||||||
edition = tasks.populate_edition.run(edition)
|
edition = tasks.populate_edition.run(edition.isbn_13)
|
||||||
self.assertTrue(edition.work.editions.all().count() > 20)
|
self.assertTrue(edition.work.editions.all().count() > 20)
|
||||||
self.assertTrue(edition.work.subjects.all().count() > 10)
|
self.assertTrue(edition.work.subjects.all().count() > 10)
|
||||||
self.assertTrue(edition.work.publication_date)
|
self.assertTrue(edition.work.publication_date)
|
||||||
|
|
|
@ -101,7 +101,7 @@ class MyZotero(Zotero2):
|
||||||
if isbn:
|
if isbn:
|
||||||
edition = bookloader.add_by_isbn(isbn)
|
edition = bookloader.add_by_isbn(isbn)
|
||||||
# let's not trigger too much traffic to Google books for now
|
# let's not trigger too much traffic to Google books for now
|
||||||
regluit.core.tasks.populate_edition.delay(edition)
|
regluit.core.tasks.populate_edition.delay(edition.isbn_13)
|
||||||
user.wishlist.add_work(edition.work, 'zotero')
|
user.wishlist.add_work(edition.work, 'zotero')
|
||||||
logger.info("Work with isbn %s added to wishlist.", isbn)
|
logger.info("Work with isbn %s added to wishlist.", isbn)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
|
|
||||||
<a name="crowdfunding"></a><dt>What is Crowdfunding?</dt>
|
<a name="crowdfunding"></a><dt>What is Crowdfunding?</dt>
|
||||||
|
|
||||||
<dd>Crowdfunding is working together to support something you believe in. By pooling donations, big and small, from all over the world, we can make huge things happen.</dd>
|
<dd>Crowdfunding is collectively pooling donations (or pledges) to support some cause. Using the internet to coordinate means that complete strangers can work together, drawn by a common cause. This also means the number of donors can be vast, so individual donations can be as large or as small as people are comfortable with, and still add up to enough to do something amazing.<br /><br />
|
||||||
|
Want to see some examples? The <a href="http://buyindiaalibrary.wordpress.com/">Buy India a Library</a> project (cofounded by an Unglue.It team member) crowdfunded donations -- mostly small ones, around $20 -- to build a school library in India. <a href="http://www.kickstarter.com/">Kickstarter</a> lets artists and inventors solicit funds to make their projects a reality. For instance, webcomic artist Rich Burlew sought $57,750 to reprint his comics in paper form -- and raised <a href="http://www.kickstarter.com/projects/599092525/the-order-of-the-stick-reprint-drive">close to a million</a>.<br /><br />
|
||||||
|
In other words, crowdfunding working together to support something you love. By pooling donations, big and small, from all over the world, we can make huge things happen.</dd>
|
||||||
|
|
||||||
<dt>What does it cost?</dt>
|
<dt>What does it cost?</dt>
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ def googlebooks(request, googlebooks_id):
|
||||||
edition = bookloader.add_by_googlebooks_id(googlebooks_id)
|
edition = bookloader.add_by_googlebooks_id(googlebooks_id)
|
||||||
if edition.new:
|
if edition.new:
|
||||||
# add related editions asynchronously
|
# add related editions asynchronously
|
||||||
tasks.populate_edition.delay(edition)
|
tasks.populate_edition.delay(edition.isbn_13)
|
||||||
except bookloader.LookupFailure:
|
except bookloader.LookupFailure:
|
||||||
logger.warning("failed to load googlebooks_id %s" % googlebooks_id)
|
logger.warning("failed to load googlebooks_id %s" % googlebooks_id)
|
||||||
return HttpResponseNotFound("failed looking up googlebooks id %s" % googlebooks_id)
|
return HttpResponseNotFound("failed looking up googlebooks id %s" % googlebooks_id)
|
||||||
|
@ -863,7 +863,7 @@ def wishlist(request):
|
||||||
edition = bookloader.add_by_googlebooks_id(googlebooks_id)
|
edition = bookloader.add_by_googlebooks_id(googlebooks_id)
|
||||||
if edition.new:
|
if edition.new:
|
||||||
# add related editions asynchronously
|
# add related editions asynchronously
|
||||||
tasks.populate_edition.delay(edition)
|
tasks.populate_edition.delay(edition.isbn_13)
|
||||||
request.user.wishlist.add_work(edition.work,'user')
|
request.user.wishlist.add_work(edition.work,'user')
|
||||||
except bookloader.LookupFailure:
|
except bookloader.LookupFailure:
|
||||||
logger.warning("failed to load googlebooks_id %s" % googlebooks_id)
|
logger.warning("failed to load googlebooks_id %s" % googlebooks_id)
|
||||||
|
@ -1066,7 +1066,7 @@ def goodreads_load_shelf(request):
|
||||||
logger.info('Adding task to load shelf %s to user %s with %d books', shelf_name, user, expected_number_of_books)
|
logger.info('Adding task to load shelf %s to user %s with %d books', shelf_name, user, expected_number_of_books)
|
||||||
load_task_name = "load_goodreads_shelf_into_wishlist"
|
load_task_name = "load_goodreads_shelf_into_wishlist"
|
||||||
load_task = getattr(tasks, load_task_name)
|
load_task = getattr(tasks, load_task_name)
|
||||||
task_id = load_task.delay(user, shelf_name, expected_number_of_books=expected_number_of_books)
|
task_id = load_task.delay(user.id, shelf_name, expected_number_of_books=expected_number_of_books)
|
||||||
|
|
||||||
ct = models.CeleryTask()
|
ct = models.CeleryTask()
|
||||||
ct.task_id = task_id
|
ct.task_id = task_id
|
||||||
|
@ -1119,7 +1119,7 @@ def librarything_load(request):
|
||||||
logger.info('Adding task to load librarything %s to user %s', lt_username, user )
|
logger.info('Adding task to load librarything %s to user %s', lt_username, user )
|
||||||
load_task_name = "load_librarything_into_wishlist"
|
load_task_name = "load_librarything_into_wishlist"
|
||||||
load_task = getattr(tasks, load_task_name)
|
load_task = getattr(tasks, load_task_name)
|
||||||
task_id = load_task.delay(user, lt_username, None)
|
task_id = load_task.delay(user.id, lt_username, None)
|
||||||
|
|
||||||
ct = models.CeleryTask()
|
ct = models.CeleryTask()
|
||||||
ct.task_id = task_id
|
ct.task_id = task_id
|
||||||
|
|
|
@ -49,7 +49,7 @@ def load_penguin_moby_dick():
|
||||||
seed_isbn = '9780142000083'
|
seed_isbn = '9780142000083'
|
||||||
ed = bookloader.add_by_isbn(seed_isbn)
|
ed = bookloader.add_by_isbn(seed_isbn)
|
||||||
if ed.new:
|
if ed.new:
|
||||||
ed = tasks.populate_edition.delay(ed)
|
ed = tasks.populate_edition.delay(ed.isbn_13)
|
||||||
|
|
||||||
def load_gutenberg_moby_dick():
|
def load_gutenberg_moby_dick():
|
||||||
title = "Moby Dick"
|
title = "Moby Dick"
|
||||||
|
|
Loading…
Reference in New Issue