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)
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)
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)
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)
def list_by_author(cls, author_id, offset=0, limit=100): assert author_id == session['auth']['user_id'] result = threads.list(author_id=author_id, offset=offset, limit=limit) if result is None: result = [] for thread in api_call(disqusapi.users.listActiveThreads, forum=app.config['DISQUS_FORUM'], method='GET'): result.append(Thread.save(thread)) score = thread['createdAt'].strftime('%s.%m') threads.add_to_set(thread['id'], score, author_id=author_id) result.reverse() return result