コード例 #1
0
ファイル: frontend.py プロジェクト: XScripter/channels
def new_thread():
    form = NewThreadForm()
    if form.validate_on_submit():
        thread = api_call(disqusapi.threads.create, title=form.subject.data, forum=app.config['DISQUS_FORUM'])
        Thread.save(thread)
        return redirect(url_for('thread_details', thread_id=base62_encode(thread['id'])))

    return render_template('threads/new.html', form=form)
コード例 #2
0
def new_thread():
    form = NewThreadForm()
    if form.validate_on_submit():
        thread = api_call(disqusapi.threads.create,
                          title=form.subject.data,
                          forum=app.config['DISQUS_FORUM'])
        Thread.save(thread)
        return redirect(
            url_for('thread_details', thread_id=base62_encode(thread['id'])))

    return render_template('threads/new.html', form=form)
コード例 #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)
        })
コード例 #4
0
ファイル: frontend.py プロジェクト: XScripter/channels
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)
    })
コード例 #5
0
def thread_search():
    query = request.args.get('q')
    if query:
        thread_list = Thread.search(query=query, limit=50)
    else:
        thread_list = None

    return render_template('threads/search.html', **{
        'query': query,
        'thread_list': thread_list,
    })
コード例 #6
0
ファイル: frontend.py プロジェクト: XScripter/channels
def thread_search():
    query = request.args.get('q')
    if query:
        thread_list = Thread.search(query=query, limit=50)
    else:
        thread_list = None

    return render_template('threads/search.html', **{
        'query': query,
        'thread_list': thread_list,
    })
コード例 #7
0
ファイル: frontend.py プロジェクト: XScripter/channels
def landing_page():
    thread_list = Thread.list(limit=15)

    session_list = Session.list_upcoming(limit=10)

    # user_list = User.list(limit=100)

    return render_template('landing.html', **{
        # 'user_list': user_list or [],
        'thread_list': thread_list,
        'session_list': session_list,
    })
コード例 #8
0
def landing_page():
    thread_list = Thread.list(limit=15)

    session_list = Session.list_upcoming(limit=10)

    # user_list = User.list(limit=100)

    return render_template(
        'landing.html',
        **{
            # 'user_list': user_list or [],
            'thread_list': thread_list,
            'session_list': session_list,
        })
コード例 #9
0
ファイル: frontend.py プロジェクト: XScripter/channels
def thread_list():
    try:
        page = int(request.args.get('page', 1)) - 1
    except (TypeError, ValueError):
        return redirect(url_for('thread_list'))

    thread_list = Thread.list(offset=page * 50, limit=50 + (page * 1))
    has_next = len(thread_list) > 50
    has_prev = page > 1

    thread_list = thread_list[:50]

    return render_template('threads/all.html', **{
        'thread_list': thread_list,
        'next_page': (page + 2) if has_next else None,
        'prev_page': (page) if has_prev else None,
    })
コード例 #10
0
def thread_list():
    try:
        page = int(request.args.get('page', 1)) - 1
    except (TypeError, ValueError):
        return redirect(url_for('thread_list'))

    thread_list = Thread.list(offset=page * 50, limit=50 + (page * 1))
    has_next = len(thread_list) > 50
    has_prev = page > 1

    thread_list = thread_list[:50]

    return render_template(
        'threads/all.html', **{
            'thread_list': thread_list,
            'next_page': (page + 2) if has_next else None,
            'prev_page': (page) if has_prev else None,
        })
コード例 #11
0
def my_threads():
    thread_list = Thread.list_by_author(author_id=session['auth']['user_id'])

    return render_template('threads/mine.html', thread_list=thread_list)
コード例 #12
0
ファイル: frontend.py プロジェクト: XScripter/channels
def my_threads():
    thread_list = Thread.list_by_author(author_id=session['auth']['user_id'])

    return render_template('threads/mine.html', thread_list=thread_list)