Exemple #1
0
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) 
Exemple #2
0
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})

    
Exemple #3
0
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})
Exemple #4
0
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})
Exemple #5
0
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})
Exemple #6
0
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})
Exemple #7
0
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()})
Exemple #8
0
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})
Exemple #9
0
def listxml(request):
    query = Book.all().order('-created')
    books = query.fetch(ITEMS_PER_PAGE)
    return render_to_response('catalog/listxml.html', {'books': books})