Пример #1
0
def destroy(request, id):
    user = request.user

    p = Post.objects.filter(id=id)
    if p and p[0].user == user:
        p[0].delete()
        response = jsonize_post(p[0])
    else:
        rq = reverse(destroy, kwargs={'id':id})
        response = dict(request=rq, error="That's not yours.")

    return HttpResponse(json.dumps(response), mimetype='application/json')
Пример #2
0
def update(request):
    user = request.user
    status = request.POST['status']
    post = uapi.new_post(user, status)
    return HttpResponse(json.dumps(jsonize_post(post)),
            mimetype='application/json')
Пример #3
0
def show(request, id):
    post = jsonize_post(Post.objects.get(id=id))
    return HttpResponse(json.dumps(post),
            mimetype='application/json')
Пример #4
0
def public_timeline(request):
    posts = uapi.public_timeline(paginated=False)[:20]
    posts = [jsonize_post(i) for i in posts]
    return HttpResponse(json.dumps(posts),
            mimetype='application/json')
Пример #5
0
def friends_timeline(request, username):
    posts = uapi.friends_timeline(username)[:20]
    posts = [jsonize_post(i) for i in posts]
    return HttpResponse(json.dumps(posts),
            mimetype='application/json')
Пример #6
0
def replies(request):
    posts = get_replies(request)[:20]
    posts = [jsonize_post(i) for i in posts]
    return HttpResponse(json.dumps(posts),
            mimetype='application/json')
Пример #7
0
def user_timeline(request, username):
    posts = uapi.user_timeline(username, paginated=False)[:20]
    posts = [jsonize_post(i) for i in posts]
    return HttpResponse(json.dumps(posts),
            mimetype='application/json')