示例#1
0
文件: views.py 项目: fay/Nankin
def view(request, key):
    try:
        page = int(request.GET['page'])
    except:
        page = 1
    paginator = utils.createPaginator(page)
    
    try:
        jot = Jot.get(key)
        jot.read_num += 1
        jot.put()
    except Exception, e:
        raise Http404
示例#2
0
文件: views.py 项目: fay/Nankin
def list(request, jots):
    try:
        page = int(request.GET['page'])
    except:
        page = 1  
    paginator = utils.createPaginator(page=page)
    for jot in jots:
        if jot.tags and jot.tags[0] != 'photo':
            jot.what = utils.strip_tags(jot.what)[:200] + "..."
    recent_posts = Jot.all().order('-when').fetch(RECENT_POST_SIZE, 0)
    recent_comments = Comment.all().order('-when').fetch(RECENT_POST_SIZE, 0)
    read_most = Jot.all().order('-read_num').fetch(RECENT_POST_SIZE, 0)
    return render_to_response('index.html', {'jots':jots, 'paginator':paginator,
                                             'recent_posts':recent_posts, 'recent_comments':recent_comments,
                                             'read_most':read_most},
                                             context_instance=RequestContext(request))