예제 #1
0
def create_post(id, dt):
    try:
        board = Forum.objects.filter(id=id)
    except Exception as e:
        print " exception value: ", e
        return redirect(url_for('.index'))
    threads = board[0].threads

    t_ret, sve_cnt = Helper().find_thread(threads, dt)
    form = CreatePostForm()
    if form.validate_on_submit():
        p = Helper().build_post(form, session['username'])
        pe = PostArrayEl()
        pe.key = str(len(t_ret.posts) + 1)
        pe.post = p
        t_ret.posts.append(pe)
        threads[sve_cnt - 1].thread = t_ret
        try:
            Forum.objects(slug=slug).update_one(set__threads=threads)
        except Exception as e:
            print " exception update value: ", e
            return redirect(url_for('.index'))

        return redirect(url_for('.board', slug=slug))

    return render_template('forum/create_post1.html', thread=t_ret, form=form)
예제 #2
0
def create_thread(id):
    try:
        board = Forum.objects.filter(id = id)
    except Exception as e:
        print " exception value: ", e
        return redirect(url_for('.index'))
    form = CreateThreadForm()
    if form.validate_on_submit():
        t=Helper().build_thread(form,session['username'])
        te=ThreadArrayEl()
        te.key = str(len(board[0].threads)+1)
        te.thread=t
        try:
            Forum.objects(slug=slug).update_one(push__threads=te)
        except Exception as e:
            print " exception update value: ", e
            return redirect(url_for('.index'))



        return redirect(url_for('.board', slug=slug))


    return render_template('forum/create_thread1.html', board=board[0],
                           form=form)
예제 #3
0
def create_post(id,dt):
    try:
        board = Forum.objects.filter(id = id)
    except Exception as e:
        print " exception value: ", e
        return redirect(url_for('.index'))
    threads = board[0].threads

    t_ret, sve_cnt = Helper().find_thread(threads,dt)
    form = CreatePostForm()
    if form.validate_on_submit():
        p=Helper().build_post(form,session['username'])
        pe = PostArrayEl()
        pe.key = str(len(t_ret.posts) + 1)
        pe.post = p
        t_ret.posts.append(pe)
        threads[sve_cnt - 1].thread=t_ret
        try:
            Forum.objects(slug=slug).update_one(set__threads=threads)
        except Exception as e:
            print " exception update value: ", e
            return redirect(url_for('.index'))


        return redirect(url_for('.board', slug=slug))



    return render_template('forum/create_post1.html', thread=t_ret,
                           form=form)
예제 #4
0
def create_thread(id):
    try:
        board = Forum.objects.filter(id=id)
    except Exception as e:
        print " exception value: ", e
        return redirect(url_for('.index'))
    form = CreateThreadForm()
    if form.validate_on_submit():
        t = Helper().build_thread(form, session['username'])
        te = ThreadArrayEl()
        te.key = str(len(board[0].threads) + 1)
        te.thread = t
        try:
            Forum.objects(slug=slug).update_one(push__threads=te)
        except Exception as e:
            print " exception update value: ", e
            return redirect(url_for('.index'))

        return redirect(url_for('.board', slug=slug))

    return render_template('forum/create_thread1.html',
                           board=board[0],
                           form=form)