Ejemplo n.º 1
0
def discussion_page_settings(discussion_id):
    query = DBQuery()
    discussion = query.get_discussions_by_id(discussion_id)
    comments = query.get_all_comments_list(discussion_id)
    user = ''
    joined = ''
    user_score_discussion = ''
    big_dict = {}
    for c in comments:
        parent_id = c[2]
        parent_content = c[3]
        value_list = []
        while parent_id is not None:
            value_list.insert(0, parent_content)
            big_dict[c[0]] = value_list
            parent_id, parent_content = query.get_parent_id(parent_id)
    user_score_discussion = ''
    if session['logged_in']:
        user = query.get_user_details(session['email'])
        joined = query.check_if_joined(discussion_id, session['email'])
        user_score_discussion = query.get_user_vote_details_discussion(
            discussion_id, session['email'])
    return render_template('discussion_page.html',
                           discussion=discussion,
                           comments=comments,
                           main=False,
                           user=user,
                           joined=joined,
                           user_score_discussion=user_score_discussion,
                           big_dict=big_dict,
                           settings=True)
Ejemplo n.º 2
0
def join_new_discuss(discussion_id):
    if request.method == 'POST':
        query = DBQuery()
        email = session['email']
        discuss_id = discussion_id
        joined = query.check_if_joined(discuss_id, email)
        if not joined:
            query.initial_score_for_discussion(discuss_id, email)

    return redirect('/discussions/' + discussion_id)
Ejemplo n.º 3
0
def discussion_page_main(discussion_id):
    query = DBQuery()
    discussion = query.get_discussions_by_id(discussion_id)
    comments = query.get_all_comments_list(discussion_id)
    graph = {}
    counter = 1
    level = [1]

    for s in comments:
        mylist = []
        node_id = s[0]
        counter = counter + 1
        for j in comments:
            parent_id = (j[2])
            if parent_id == node_id:
                level.append(counter)
                mylist.append(str(j[0]))
                graph[str(node_id)] = mylist
        if str(node_id) not in graph:
            graph[str(node_id)] = []

    global html_string
    status = discussion[0][6]
    html_string = []
    visited = dfs(graph, str(comments[0][0]), [], html_string, comments,
                  status)
    str1 = ''.join(html_string)
    user = ''
    merge_comments = ''
    joined = ''
    big_dict = {}
    for c in comments:
        parent_id = c[2]
        parent_content = c[3]
        value_list = []
        if parent_id is None:
            value_list.insert(0, parent_content)
            big_dict[c[0]] = value_list
        else:
            while parent_id is not None:
                value_list.insert(0, parent_content)
                big_dict[c[0]] = value_list
                parent_id, parent_content = query.get_parent_id(parent_id)
    print(big_dict)
    user_score_discussion = ''
    if session['logged_in']:
        user = query.get_user_details(session['email'])
        user_score_discussion = query.get_user_vote_details_discussion(
            discussion_id, session['email'])
        merge_comments = query.get_merge_list(discussion_id)
        joined = query.check_if_joined(discussion_id, session['email'])

    return render_template('discussion_page.html',
                           discussion=discussion,
                           comments=comments,
                           main=True,
                           tree=False,
                           html_string=Markup(str1),
                           user=user,
                           merge_list=merge_comments,
                           joined=joined,
                           user_score_discussion=user_score_discussion,
                           big_dict=big_dict)