Example #1
0
def delete(request, identifier):
	book = Book().get(identifier)
	readerBook = ReaderBook().byReaderAndBook(Reader.byCurrentUser(), book)
	
	readerBook.delete()
	
	return HttpResponseRedirect('/')
Example #2
0
def delete(request, identifier):
    book = Book().get(identifier)
    readerBook = ReaderBook().byReaderAndBook(Reader.byCurrentUser(), book)

    readerBook.delete()

    return HttpResponseRedirect('/')
Example #3
0
def index(request, username=None, state=None, page=1):
    reader = Reader.byUsername(username)

    if not reader:
        return HttpResponse('No such username')

    page = int(page)
    template_values = {}

    template_values["currentState"] = state
    template_values["readOnly"] = True
    template_values["books"] = []
    template_values["toReadCount"] = reader.toReadCount
    template_values["inProgressCount"] = reader.inProgressCount
    template_values["finishedCount"] = reader.finishedCount
    template_values["totalCount"] = reader.totalCount

    # paging stuff
    paging.preparePagingTemplateForBookcase(template_values, reader, state,
                                            page)
    # end paging stuff

    for readerBook in ReaderBook.byReaderAndState(reader, state, page - 1):
        template_values["books"].append(
            mapping.toReaderBookTemplate(readerBook.book, readerBook))

    template_values["navRoot"] = "/public/" + username

    return render(template_values)
Example #4
0
def markAsTodo(request, identifier):
	book = Book().get(db.Key(identifier))
	readerBook = ReaderBook.byReaderAndBook(Reader.byCurrentUser(), book)
	readerBook.state = 'unread'
	readerBook.put()
	
	return redirectToBook(book)
Example #5
0
def markAsTodo(request, identifier):
    book = Book().get(db.Key(identifier))
    readerBook = ReaderBook.byReaderAndBook(Reader.byCurrentUser(), book)
    readerBook.state = 'unread'
    readerBook.put()

    return redirectToBook(book)
Example #6
0
def index(request, username=None, state=None, page=1):
	reader = Reader.byUsername(username)
	
	if not reader:
		return HttpResponse('No such username')
	
	page = int(page)
	template_values = {}
	
	template_values["currentState"] = state
	template_values["readOnly"] = True
	template_values["books"] = []
	template_values["toReadCount"] = reader.toReadCount
	template_values["inProgressCount"] = reader.inProgressCount
	template_values["finishedCount"] = reader.finishedCount
	template_values["totalCount"] = reader.totalCount	
	
	# paging stuff
	paging.preparePagingTemplateForBookcase(template_values, reader, state, page)
	# end paging stuff
		
	for readerBook in ReaderBook.byReaderAndState(reader, state, page - 1):
		template_values["books"].append(mapping.toReaderBookTemplate(readerBook.book, readerBook))
	
	template_values["navRoot"] = "/public/" + username
	
	return render(template_values)
Example #7
0
def createReaderBookIfNecessary(reader, book, state):
    readerBook = ReaderBook.byReaderAndBook(reader, book)

    if not readerBook:
        readerBook = ReaderBook(parent=reader)
        readerBook.reader = reader
        readerBook.book = book

    readerBook.state = state
    readerBook.put()
Example #8
0
def index(request, state=None, page=1):
    reader = Reader().byCurrentUser()
    user = users.get_current_user()
    page = int(page)
    template_values = {}

    if state:
        template_values["currentState"] = state
    else:
        template_values["currentState"] = ""

    if user: template_values["isLoggedIn"] = True
    else: template_values["isLoggedIn"] = False

    if not reader:
        template_values["loginUrl"] = users.create_login_url('/reader')
    else:
        template_values["hasReader"] = True
        template_values["books"] = []
        template_values["toReadCount"] = reader.toReadCount
        template_values["inProgressCount"] = reader.inProgressCount
        template_values["finishedCount"] = reader.finishedCount
        template_values["totalCount"] = reader.totalCount
        template_values["showRatings"] = True

        # paging stuff
        paging.preparePagingTemplateForBookcase(template_values, reader, state,
                                                page)
        # end paging stuff

        if state == "unrated":
            collection = ReaderBook.byReaderUnrated(reader, page - 1)
        else:
            collection = ReaderBook.byReaderAndState(reader, state, page - 1)

        for readerBook in collection:
            template_values["books"].append(
                mapping.toReaderBookTemplate(readerBook.book, readerBook))

    template_values["navRoot"] = "/bookcase"
    template_values["viewtype"] = "searchresult.html"

    return render(template_values)
Example #9
0
def index(request, state=None, page=1):
	reader = Reader().byCurrentUser()
	user = users.get_current_user()
	page = int(page)
	template_values = {}
	
	if state:
		template_values["currentState"] = state
	else:
		template_values["currentState"] = ""
	
	if user: template_values["isLoggedIn"] = True
	else: template_values["isLoggedIn"] = False
		
	if not reader:
		template_values["loginUrl"] = users.create_login_url('/reader')	
	else:
		template_values["hasReader"] = True
		template_values["books"] = []
		template_values["toReadCount"] = reader.toReadCount
		template_values["inProgressCount"] = reader.inProgressCount
		template_values["finishedCount"] = reader.finishedCount
		template_values["totalCount"] = reader.totalCount
		template_values["showRatings"] = True
	
		# paging stuff
		paging.preparePagingTemplateForBookcase(template_values, reader, state, page)
		# end paging stuff
	
		if state == "unrated":
			collection = ReaderBook.byReaderUnrated(reader, page - 1)
		else:
			collection = ReaderBook.byReaderAndState(reader, state, page - 1)
			
		for readerBook in collection:
			template_values["books"].append(mapping.toReaderBookTemplate(readerBook.book, readerBook))
	
	template_values["navRoot"] = "/bookcase"
	template_values["viewtype"] = "searchresult.html"
	
	return render(template_values)
Example #10
0
def createReaderBookIfNecessary(reader, book, state):
	readerBook = ReaderBook.byReaderAndBook(reader, book)
	
	if not readerBook:
		readerBook = ReaderBook(parent=reader)
		readerBook.reader = reader
		readerBook.book = book
	
	readerBook.state = state
	readerBook.put()
Example #11
0
def delete(request):

    r = Reader.byCurrentUser()

    if r:
        list = ReaderBook.all(keys_only=True).ancestor(r).fetch(1000)
        db.delete(list)
        r.delete()
    else:
        return HttpResponseRedirect('/')

    return HttpResponse(render('reader_delete_confirm.html', None))
Example #12
0
def export(request):
	reader = Reader().byCurrentUser()
	collection = ReaderBook.finishedBooks(reader)

	response = HttpResponse(content_type='text/csv')
	response['Content-Disposition'] = 'attachment; filename="somefilename.csv"'

	writer = csv.writer(response)
	writer.writerow(['Title', 'ISBN', 'My Rating', 'Date Read', 'Date Added'])
	for c in collection:
		title = c.book.title.replace('""', '')
		writer.writerow([title,c.book.isbn,c.rating,c.finishedDate,c.created])

	return response
Example #13
0
def export(request):
    reader = Reader().byCurrentUser()
    collection = ReaderBook.finishedBooks(reader)

    response = HttpResponse(content_type='text/csv')
    response['Content-Disposition'] = 'attachment; filename="somefilename.csv"'

    writer = csv.writer(response)
    writer.writerow(['Title', 'ISBN', 'My Rating', 'Date Read', 'Date Added'])
    for c in collection:
        title = c.book.title.replace('""', '')
        writer.writerow(
            [title, c.book.isbn, c.rating, c.finishedDate, c.created])

    return response
Example #14
0
def index(request):
	
	reader = Reader().byCurrentUser()
	fromDate = getPastDate(1)
	finished = ReaderBook.finishedBooks(reader, fromDate)

	# 12 months where each is a list to a book
	months = [[] for i in range(12)]
	
	for b in finished:
		if b.finishedDate:
			months[b.finishedDate.month - 1].append(b.book.title)
		
	tv = {}
	tv["months"] = months
	
	return render(tv)
Example #15
0
def index(request):

    reader = Reader().byCurrentUser()
    fromDate = getPastDate(1)
    finished = ReaderBook.finishedBooks(reader, fromDate)

    # 12 months where each is a list to a book
    months = [[] for i in range(12)]

    for b in finished:
        if b.finishedDate:
            months[b.finishedDate.month - 1].append(b.book.title)

    tv = {}
    tv["months"] = months

    return render(tv)
Example #16
0
def layout(request):

	# get all the books within x amount of time layed out by date
	# go by each day from the earliest day
	# output day and the book that is being read on that day
	# and continue doing that until all the books have been output
	reader = Reader().byCurrentUser()
	fromDate = getPastDate(2)
	finished = ReaderBook.finishedBooks(reader, fromDate)
	
	currentDate = fromDate
	byDate = {}
	while currentDate <= datetime.date.today() + datetime.timedelta(days=1):
		list = matchedBookByDate(currentDate, finished)
		byDate[currentDate] = []
		for b in list:
			byDate[currentDate].append(b.book.title)
		currentDate = currentDate + datetime.timedelta(days=1)
	
	return render_to_response('layout.html', {"data" : sorted(byDate.iteritems())})
Example #17
0
def layout(request):

    # get all the books within x amount of time layed out by date
    # go by each day from the earliest day
    # output day and the book that is being read on that day
    # and continue doing that until all the books have been output
    reader = Reader().byCurrentUser()
    fromDate = getPastDate(2)
    finished = ReaderBook.finishedBooks(reader, fromDate)

    currentDate = fromDate
    byDate = {}
    while currentDate <= datetime.date.today() + datetime.timedelta(days=1):
        list = matchedBookByDate(currentDate, finished)
        byDate[currentDate] = []
        for b in list:
            byDate[currentDate].append(b.book.title)
        currentDate = currentDate + datetime.timedelta(days=1)

    return render_to_response('layout.html',
                              {"data": sorted(byDate.iteritems())})
Example #18
0
def viewByIsbn(request, isbn = ""):
	
	user = users.get_current_user()
	reader = None
	book = None
	readerBook = None
	
	if user:
		reader = Reader.byCurrentUser()
	
	book = fetchCreateByISBN(isbn, invokeSearchByIsbn, True)
	
	readerBook = ReaderBook.byReaderAndBook(reader, book)
		
	template_values = mapping.toReaderBookTemplate(book, readerBook)
	
	if not user:
		template_values["loginUrlToAdd"] = users.create_login_url('/book/isbn/' + isbn)
	else:
		if not reader:
			template_values["signupUrl"] = '/reader'
	
	return render(template_values)
Example #19
0
def viewByIsbn(request, isbn=""):

    user = users.get_current_user()
    reader = None
    book = None
    readerBook = None

    if user:
        reader = Reader.byCurrentUser()

    book = fetchCreateByISBN(isbn, invokeSearchByIsbn, True)

    readerBook = ReaderBook.byReaderAndBook(reader, book)

    template_values = mapping.toReaderBookTemplate(book, readerBook)

    if not user:
        template_values["loginUrlToAdd"] = users.create_login_url(
            '/book/isbn/' + isbn)
    else:
        if not reader:
            template_values["signupUrl"] = '/reader'

    return render(template_values)
Example #20
0
def view(request, identifier):

    book = db.get(db.Key(identifier))
    readerBook = ReaderBook.byReaderAndBook(Reader.byCurrentUser(), book)

    return render(mapping.toReaderBookTemplate(book, readerBook))
Example #21
0
def getCurrentUserBook(identifier):
    return ReaderBook.byReaderAndBook(Reader.byCurrentUser(),
                                      db.Key(identifier))
Example #22
0
def getCurrentUserBook(identifier):
	return ReaderBook.byReaderAndBook(Reader.byCurrentUser(), db.Key(identifier))
Example #23
0
def view(request, identifier):

	book = db.get(db.Key(identifier))
	readerBook = ReaderBook.byReaderAndBook(Reader.byCurrentUser(), book)
	
	return render( mapping.toReaderBookTemplate(book, readerBook) )