CottageLabs / uniboard

UniBoard project
0 stars 0 forks source link

Auto-create advert from ISBN #49

Closed richard-jones closed 10 years ago

richard-jones commented 10 years ago

Integrate with google books or something similar to auto-populate the book metadata

richard-jones commented 10 years ago

To do this we will integrate with the google books lookup.

On the "New Advert" page, the user will be presented with only the ISBN input box, and a "Fetch" button. They enter the ISBN and hit the button, which queries the Google Books API. The response will be one of the following:

  1. 0 results are returned. We tell the user that we could not find a result, and we open the empty book entry form. We keep the (unfound) ISBN as it might just be missing from the google data.
  2. 1 result is returned. We open the book form and pre-populate it with the relevant data from the google data.
  3. more than 1 result is returned. Here we have options: a. Tell the user that we could not find a result b. give the user a list of the possible results and ask them to choose.

3b is more work than 3a

The user will be able to change the ISBN at any time and hit "Fetch" again, and we will overwrite any existing content in the form.

@mjb295 - could you confirm that this is the behaviour that you'd like in the ISBN lookup, and make a call on 3a vs 3b.

mjb295 commented 10 years ago

Yes looks ok, we should be looking to complete option '3b'.

richard-jones commented 10 years ago

Agreed that we will actually go with option 3a.

richard-jones commented 10 years ago

@Nimphal - assigning this to you first, so you can get on with implementing the API calls to google. If you could implement the following and then assign back to me:

Nimphal commented 10 years ago

A new module called isbn_lookup has been created. It takes as an argument an ISBN and returns a JSON representation of the Google Books API response. A URL rool at /advert/isbn/<isbn> calls this module and returns a JSON of the book. If no book or more than one result found (I have yet to encounter this case), it returns an empty dictionary. Assigning to @richard-jones, please assign back if I've missed something.

richard-jones commented 10 years ago

The isbn_lookup should take the google books data and crosswalk it into the book json format that uniboard uses.

Nimphal commented 10 years ago

The root now returns a book object containing only the data relevant to the form. If no data is found in the response from google, the value is set to none (apparently there are books out there that don't have publishers, go figure). An example book object:

{
publisher: null,
authors: [
"George Clarke",
"Jane Field-Lewis"
],
subjects: [
"Architecture, Domestic"
],
isbn: [
{
identifier: "1849493391",
type: "ISBN_10"
},
{
identifier: "9781849493390",
type: "ISBN_13"
}
],
title: "Amazing Spaces",
image: "http://bks0.books.google.co.uk/books?id=eN2GnAEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api",
year: 2013
}
richard-jones commented 10 years ago

Front-end has now been bound to the back end.

richard-jones commented 10 years ago

Oh, one minor thing - could you make the back-end normalise any ISBN that comes in. For example 1843341387 works, but if you input it as written on a book then it doesn't (1-84334-138-7). Probably enough to strip whitespace and replace non-numeric characters with the empty string.

Nimphal commented 10 years ago

This should now work, all characters that are not numbers are stripped before the Books API is called. As a result ISBNs as they appear in books are now okay.

2014-08-18 23:57 GMT+01:00 Richard Jones notifications@github.com:

Reopened #49 https://github.com/CottageLabs/uniboard/issues/49.

— Reply to this email directly or view it on GitHub https://github.com/CottageLabs/uniboard/issues/49#event-154218280.

richard-jones commented 10 years ago

tested and is working