def lend(request, key): if request.method == "POST" : book = Book.get(key) lending_str = request.form['lending'] if(lending_str == 'True'): book.lending = True else: book.lending = False book.put() detail_url = '/catalog/detail/' + key return redirect(detail_url)
def listpagexml(request, page_no): page_no = int(page_no) query = Book.all().order('-created') if not page_no > 0: page_no = 0 offset = page_no * ITEMS_PER_PAGE books = query.fetch(ITEMS_PER_PAGE, offset) total_count = query.count() return render_to_response('catalog/listpagexml.html', {'books': books, 'offset_count': offset, 'total_count': total_count})
def lendbydroid(request, key): books = [] if request.method == "POST" : book = Book.get(key) lending_str = request.form['lending'] if(lending_str.lower() == 'true'): book.lending = True else: book.lending = False book.put() #book = Book.get(key) books.append(book) #return render_to_response('catalog/detail.html', {'book': book}) return render_to_response('catalog/listxml.html', {'books': books})
def detail(request, key): book = Book.get(key) tag_key_list = book.tags #tags is always not None tag_title_list = [] for tag_key in tag_key_list : try : tag_title = Tag.get(tag_key) if tag_title : tag_title_list.append(tag_title) except : pass return render_to_response('catalog/detail.html', {'book': book, 'tag_title_list': tag_title_list})
def tag_relation(request, book_key): form = BookForm() book = Book.get(book_key) if request.method == "POST" : book.tags = [] tag_keys = request.form.getlist('tag_keys') for tag_key in tag_keys : book.tags.append(tag_key) book.save() book.put() tags = Tag.all() return render_to_response('register/tag_relation.html', {'errors': form.errors, 'book': book, 'tags': tags})
def index(request): tag = request.args.get('tags') query = Book.all() if tag : tag_id = "" tag_model = Tag.all().filter("title =", tag).get() if tag_model : tag_id = str(tag_model.key()) query.filter("tags =", tag_id) query.order('-created') books = query.fetch(ITEMS_PER_PAGE) tags = Tag.all() return render_to_response('catalog/index.html', {'books': books, 'tags': tags})
def index(request): form = BookForm() if request.method == "POST" : if form.validate(request.form): book = form.save() book.put() return redirect(url_for('register/index')) else : return render_to_response('register/search_amazon.html', {'form': form.as_widget(), 'errors': form.errors }) query = Book.all().order('-created') books = query.fetch(ITEMS_PER_PAGE) return render_to_response('register/index.html', {'errors': form.errors, 'books': books, 'form': form.as_widget()})
def deletion_reserve_list(request): query = Book.all().filter("deletion_reserve = ", True).order('-created') books = query.fetch(ITEMS_PER_PAGE) return render_to_response('catalog/index.html', {'books': books, 'deletion_reserve_flg': True})
def listxml(request): query = Book.all().order('-created') books = query.fetch(ITEMS_PER_PAGE) return render_to_response('catalog/listxml.html', {'books': books})