Ejemplo n.º 1
0
def new_post(thread_id):
    form = NewPostForm()
    if form.validate_on_submit():
        post = api_call(disqusapi.posts.create,
                        thread=thread_id,
                        message=form.message.data)
        formatted = Post.save(post)
        return better_jsonify({'post': formatted}, status=201)
    return better_jsonify({'message': "invalid request"}, status=400)
Ejemplo n.º 2
0
def new_post(thread_id):
    form = NewPostForm()
    if form.validate_on_submit():
        post = api_call(disqusapi.posts.create, thread=thread_id, message=form.message.data)
        formatted = Post.save(post)
        return better_jsonify({
            'post': formatted
        }, status=201)
    return better_jsonify({'message': "invalid request"}, status=400)
Ejemplo n.º 3
0
def thread_details(thread_id):
    if not thread_id.isdigit():
        try:
            thread_id = base62_decode(thread_id)
        except:
            return redirect('/')

    form = NewPostForm(get_form_from_session())

    thread = Thread.get(thread_id)

    channel_list = {
        'posts': posts.get_channel_key(posts.get_key(thread_id=thread_id)),
        'participants':
        users.get_channel_key(users.get_key(thread_id=thread_id)),
        'active_thread_list': threads.get_channel_key(threads.get_key()),
    }

    if thread['link'] in schedule:
        pycon_session = schedule[thread['link']]
    else:
        pycon_session = False

    if 'auth' in session:
        my_threads = Thread.list_by_author(
            author_id=session['auth']['user_id'])[:5]
        channel_list['my_thread_list'] = threads.get_channel_key(
            threads.get_key(author_id=thread_id))
    else:
        my_threads = []

    post_list = Post.list_by_thread(thread_id)[::-1]
    if 'auth' in session:
        current_user = User.get_by_id(session['auth']['user_id'])
    else:
        current_user = None

    return render_template(
        'threads/details.html', **{
            'thread': thread,
            'form': form,
            'pycon_session': pycon_session,
            'participant_list': User.list_by_thread(thread_id) or [],
            'my_thread_list': my_threads,
            'active_thread_list': Thread.list(limit=10),
            'post_list': post_list,
            'channel_list': channel_list,
            'realtime_host': app.config.get('REALTIME_HOST'),
            'current_user': current_user,
            'do_troll': app.config.get('DING_ENABLED', False)
        })
Ejemplo n.º 4
0
def thread_details(thread_id):
    if not thread_id.isdigit():
        try:
            thread_id = base62_decode(thread_id)
        except:
            return redirect('/')

    form = NewPostForm(get_form_from_session())

    thread = Thread.get(thread_id)

    channel_list = {
        'posts': posts.get_channel_key(posts.get_key(thread_id=thread_id)),
        'participants': users.get_channel_key(users.get_key(thread_id=thread_id)),
        'active_thread_list': threads.get_channel_key(threads.get_key()),
    }

    if thread['link'] in schedule:
        pycon_session = schedule[thread['link']]
    else:
        pycon_session = False

    if 'auth' in session:
        my_threads = Thread.list_by_author(author_id=session['auth']['user_id'])[:5]
        channel_list['my_thread_list'] = threads.get_channel_key(threads.get_key(author_id=thread_id))
    else:
        my_threads = []

    post_list = Post.list_by_thread(thread_id)[::-1]
    if 'auth' in session:
        current_user = User.get_by_id(session['auth']['user_id'])
    else:
        current_user = None

    return render_template('threads/details.html', **{
        'thread': thread,
        'form': form,
        'pycon_session': pycon_session,
        'participant_list': User.list_by_thread(thread_id) or [],
        'my_thread_list': my_threads,
        'active_thread_list': Thread.list(limit=10),
        'post_list': post_list,
        'channel_list': channel_list,
        'realtime_host': app.config.get('REALTIME_HOST'),
        'current_user': current_user,
        'do_troll': app.config.get('DING_ENABLED', False)
    })
Ejemplo n.º 5
0
def get_posts(thread_id):
    return jsonify({'post_list': Post.list_by_thread(thread_id)[::-1]})
Ejemplo n.º 6
0
def get_posts(thread_id):
    return jsonify({
        'post_list': Post.list_by_thread(thread_id)[::-1]
    })