Exemple #1
0
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))
Exemple #2
0
def news(request):
    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('news.html', {'recent_posts':recent_posts, 'recent_comments':recent_comments, 'read_most':read_most}, context_instance=RequestContext(request))
Exemple #3
0
    return HttpResponseRedirect('/view/' + key + '/')

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
    comments = Comment.all().filter('refer =', jot).order('when').fetch(utils.PAGE_SIZE, utils.PAGE_SIZE * (page - 1))

    return render_to_response('view.html', {'entry':jot, 'comments':comments}, context_instance=RequestContext(request))

@login_required
def edit(request, key):
    mode = request.GET.get('mode', None)
    user = users.get_current_user()
    try:
        jot = Jot.get(key)
    except Exception, e:
        raise Httindexp404
    if not (jot.who.user == user):
        return HttpResponseRedirect('/')
    return render_to_response('publish.html', {'jot':jot, 'mode':mode}, context_instance=RequestContext(request))