def addToInventory(self,title="",status="STOCK",authors=[],publisher="",listprice="",ourprice='',isbn="",categories=[],distributor="",location="",owner="",notes="",quantity=1,known_title=False,types='',kind_name="",kind=default_kind, extra_prices={}, tag='', num_copies=0, printlabel=False): print "GOT to addToInventory" if not(known_title): print "unknown title" #add a title the_kinds=list(Kind.select(Kind.q.kindName==kind)) kind_id = None if the_kinds: kind_id = the_kinds[0].id print 'kind id is', kind_id #print title title=title publisher=publisher #print title, publisher known_title=Title(isbn=isbn, booktitle=title, publisher=publisher,tag=" ",type=types, kindID=kind_id) print known_title for rawAuthor in authors: author = rawAuthor.encode("utf8", "backslashreplace") theAuthors = Author.selectBy(authorName=author) theAuthorsList = list(theAuthors) if len(theAuthorsList) == 1: known_title.addAuthor(theAuthorsList[0]) elif len(theAuthorsList) == 0: a = Author(authorName=author) known_title.addAuthor(a) else: # We should SQLDataCoherenceLost here print "mmm... looks like you have multiple author of the sama name in your database..." for category in categories: Category(categoryName=category.encode("utf8", "backslashreplace"),title=known_title) the_locations=list(Location.select(Location.q.locationName==location)) location_id=1 if the_locations: location_id = the_locations[0].id if not ourprice: ourprice=listprice for i in range(int(quantity)): #print "book loop" b=Book(title=known_title,status=status.encode("utf8", "backslashreplace"), distributor=distributor.encode('ascii', "backslashreplace"),listprice=listprice, ourprice=ourprice, location=location_id,owner=owner.encode("utf8", "backslashreplace"),notes=notes.encode("utf8", "backslashreplace"),consignmentStatus="")
def addToInventory(self,title="",status="STOCK",authors=[],publisher="",price="",isbn="",categories=[],distributor="",owner="",notes="",quantity=1,known_title=False,kind_name="",extra_prices={}): if not(known_title): #add a title the_kinds=list(Kind.select(Kind.q.kindName==kind_name)) kind_id = None if the_kinds: kind_id = the_kinds[0].id known_title=Title(isbn=isbn, booktitle=title.encode("ascii", "backslashreplace"), publisher=publisher.encode("ascii", "backslashreplace"),tag=" ",kindID=kind_id) for rawAuthor in authors: author = rawAuthor.encode("ascii", "backslashreplace") theAuthors = Author.selectBy(author_name=author) theAuthorsList = list(theAuthors) if len(theAuthorsList) == 1: known_title.addAuthor(theAuthorsList[0]) elif len(theAuthorsList) == 0: a = Author(author_name=author) known_title.addAuthor(a) else: # We should SQLDataCoherenceLost here print "mmm... looks like you have multiple author of the sama name in your database..." for category in categories: Category(categoryName=category.encode("ascii", "backslashreplace"),title=known_title) for i in range(int(quantity)): print distributor.encode('ascii', "backslashreplace") wholesale=0 try: wholesale=extra_prices['wholesale'] except: pass b=Book(title=known_title,status=status.encode("ascii", "backslashreplace"), distributor=distributor.encode('ascii', "backslashreplace"),listprice=price,owner=owner.encode("ascii", "backslashreplace"),notes=notes.encode("ascii", "backslashreplace"),consignmentStatus="",wholesale=wholesale) b.extracolumns() for mp in extra_prices.keys(): setattr(b,string.replace(mp," ",""),extra_prices[mp])
def addToInventory(self, title="", status="STOCK", authors=[], publisher="", price="", isbn="", categories=[], distributor="", owner="", notes="", quantity=1, known_title=False, kind_name="", extra_prices={}): if not (known_title): #add a title the_kinds = list(Kind.select(Kind.q.kindName == kind_name)) kind_id = None if the_kinds: kind_id = the_kinds[0].id known_title = Title(isbn=isbn, booktitle=title.encode("ascii", "backslashreplace"), publisher=publisher.encode( "ascii", "backslashreplace"), tag=" ", kindID=kind_id) for rawAuthor in authors: author = rawAuthor.encode("ascii", "backslashreplace") theAuthors = Author.selectBy(author_name=author) theAuthorsList = list(theAuthors) if len(theAuthorsList) == 1: known_title.addAuthor(theAuthorsList[0]) elif len(theAuthorsList) == 0: a = Author(author_name=author) known_title.addAuthor(a) else: # We should SQLDataCoherenceLost here print "mmm... looks like you have multiple author of the sama name in your database..." for category in categories: Category(categoryName=category.encode("ascii", "backslashreplace"), title=known_title) for i in range(int(quantity)): print distributor.encode('ascii', "backslashreplace") wholesale = 0 try: wholesale = extra_prices['wholesale'] except: pass b = Book(title=known_title, status=status.encode("ascii", "backslashreplace"), distributor=distributor.encode('ascii', "backslashreplace"), listprice=price, owner=owner.encode("ascii", "backslashreplace"), notes=notes.encode("ascii", "backslashreplace"), consignmentStatus="", wholesale=wholesale) b.extracolumns() for mp in extra_prices.keys(): setattr(b, string.replace(mp, " ", ""), extra_prices[mp])
def addToInventory( title="", status="STOCK", authors=None, publisher="", listprice="", ourprice="", isbn="", orig_isbn="", categories=[], distributor="", location="", location_id="", large_url="", med_url="", small_url="", owner="", notes="", quantity=1, known_title=False, types="", kind_name="", kind=default_kind, extra_prices={}, tag="", labels_per_copy=1, printlabel=False, special_orders=0, ): print("GOT to addToInventory", file=sys.stderr) if not authors: authors = [] if known_title: print("known_title ", known_title, file=sys.stderr) if not known_title.booktitle: known_title.booktitle = title if not known_title.publisher: known_title.publisher = publisher if not known_title.type: known_title.type = types elif not (known_title): print("unknown title", file=sys.stderr) # add a title the_kinds = list(Kind.select(Kind.q.kindName == kind)) kind_id = None if the_kinds: kind_id = the_kinds[0].id print("kind id is", kind_id, file=sys.stderr) # print>>sys.stderr, title title = title publisher = publisher # print>>sys.stderr, title, publisher known_title = Title( isbn=isbn, origIsbn=orig_isbn, booktitle=title, publisher=publisher, tag=" ", type=types, kindID=kind_id, ) print(known_title, file=sys.stderr) im = Images( titleID=known_title.id, largeUrl=large_url, medUrl=med_url, smallUrl=small_url, ) print(im, file=sys.stderr) for rawAuthor in authors: author = rawAuthor theAuthors = Author.selectBy(authorName=author) theAuthorsList = list(theAuthors) if len(theAuthorsList) == 1: known_title.addAuthor(theAuthorsList[0]) elif len(theAuthorsList) == 0: a = Author(authorName=author) known_title.addAuthor(a) else: # We should SQLDataCoherenceLost here print( "mmm... looks like you have multiple author of the sama name in your database...", file=sys.stderr, ) for category in categories: Category(categoryName=category, title=known_title) # the_locations=list(Location.select(Location.q.locationName==location)) # location_id=1 # if the_locations: # location_id = the_locations[0].id if not ourprice: ourprice = listprice print("about to enter book loop", file=sys.stderr) print("location is", location, file=sys.stderr) print("location_id is", location_id, file=sys.stderr) for i in range(int(quantity)): print("book loop", file=sys.stderr) b = Book( title=known_title, status=status, distributor=distributor, listprice=listprice, ourprice=ourprice, location=int(location_id), owner=owner, notes=notes, consignmentStatus="", )