示例#1
0
def post(request, post_id):
    if request.method == 'POST':
        comment = request.POST['comment']
        comment_id = services.post_comment(post_id, comment, request.session['base64'])
        return HttpResponseRedirect('/post/' + post_id + '/#' + comment_id)
    post = services.get_post(post_id)
    comments = services.get_comments(post_id)
    post['comments'] = comments
    return render(request, 'post.html', post)
示例#2
0
def edit_post(request, post_id):
    if request.method == 'POST':
        data = dict(request.POST)
        services.put_post(data, post_id, request.session['base64'])
        return HttpResponseRedirect('/user_page/post/' + post_id)
    data = services.get_post(post_id)
    text = []
    for line in data['content']:
        if line['type'] == 'IMG':
            text.append('#img:' + line['content'])
        else:
            text.append(line['content'])
    return render(request, 'add_post.html', {'title': 'edit post',
                                             'image_source': 'https://snap-photos.s3.amazonaws.com/img-thumbs/960w/I98ZOPE9FM.jpg',
                                             'heading': 'Here you can edit this post.',
                                             'subheading': 'To add an image type link in new line with prefix #img:',
                                             'text_title': data['title'],
                                             'description': data['subheading'],
                                             'content': '\n'.join(text),
                                             'post_icon': data['image_source']})
示例#3
0
def del_post(request, post_id):
    blog_id = services.get_post(post_id)['blog_id']
    services.del_post(post_id, request.session['base64'])
    messages.info(request,'Post removed.')
    return HttpResponseRedirect('/user_page/blog/' + blog_id)
示例#4
0
def user_post(request, post_id):
    user_data = services.get_user_data(request.session['base64'])
    post = services.get_post(post_id)
    return render(request, 'user_post.html', post)