Example #1
0
def borrowbook(request):
    app = 'normal-user'
    borrow_list = util.getBorrow_now(request.user.username)
    tlist = []
    for br in borrow_list:
        temp = {}
        temp['id'] = br.record.booki.id
        temp['isbn'] = br.record.booki.book.isbn
        temp['name'] = br.record.booki.book.title
        temp['time'] = br.record.time
        temp['renewal'] = br.record.booki.renewal
        tlist.append(temp)

    p = request.GET.get('page', '1')
    if not p.isdigit():
        p = 1
    else:
        p = int(p)

    relist = []
    paginator = Paginator(tlist , Per_Page)

    try:
        relist = paginator.page(p)
    except:
        relist = paginator.page(1)
        
    return render_to_response('normal_user/borrow.html', {'app':app,'tlist':relist, 'page_obj':relist, 'is_paginated':True}, context_instance=RequestContext(request))
Example #2
0
def information(request):
    app = 'normal-user'

    userprofile = util.getUser(request.user.username)
    username = request.user.username
    email = request.user.email
    level = userprofile.level[0]
    debt = userprofile.debt

    borrow_list = util.getBorrow_now(request.user.username)
    tlist = []
    for br in borrow_list:
        temp = {}
        temp['id'] = br.record.booki.id
        temp['isbn'] = br.record.booki.book.isbn
        temp['name'] = br.record.booki.book.title
        temp['time'] = br.record.time
        temp['renewal'] = br.record.booki.renewal
        tlist.append(temp)

    p = request.GET.get('page', '1')
    if not p.isdigit():
        p = 1
    else:
        p = int(p)

    relist = []
    paginator = Paginator(tlist , Per_Page)

    try:
        relist = paginator.page(p)
    except:
        relist = paginator.page(1)
        
    return render_to_response('normal_user/information.html',
        {'app':app,
        'username':username,
        'email':email,
        'level':level,
        'debt':debt,
        'tlist':relist,
        'page_obj':relist,
        'is_paginated':True
        },
        context_instance=RequestContext(request)
    )