Ejemplo n.º 1
0
def reaction(db_issue: Issue, db_user: User, db_arg_user: Argument, db_arg_sys: Argument, relation: Relations, history,
             path) -> dict:
    """
    Initialize the reaction step for a position in a discussion. Creates helper and returns a dictionary containing
    different feedback options for the confrontation with an argument in a discussion.

    :param db_issue:
    :param db_user:
    :param db_arg_user:
    :param db_arg_sys:
    :param relation:
    :param history:
    :param path:
    :return:
    """
    logger('Core', 'Entering discussion.reaction')
    # set votes and reputation
    add_rep, broke_limit = add_reputation_for(db_user, reason=rep_reason_first_argument_click)
    add_click_for_argument(db_arg_user, db_user)

    _ddh = DiscussionDictHelper(db_issue.lang, db_user.nickname, history, slug=db_issue.slug, broke_limit=broke_limit)
    _idh = ItemDictHelper(db_issue.lang, db_issue, path=path, history=history)
    discussion_dict = _ddh.get_dict_for_argumentation(db_arg_user, db_arg_sys.uid, relation, history, db_user)
    item_dict = _idh.get_array_for_reaction(db_arg_sys.uid, db_arg_user.uid, db_arg_user.is_supportive, relation,
                                            discussion_dict['gender'])

    return {
        'issues': issue_helper.prepare_json_of_issue(db_issue, db_user),
        'discussion': discussion_dict,
        'items': item_dict,
        'title': db_issue.title
    }
Ejemplo n.º 2
0
def finish(db_issue: Issue, db_user: User, db_argument: Argument, history: str) -> dict:
    issue_dict = issue_helper.prepare_json_of_issue(db_issue, db_user)

    _ddh = DiscussionDictHelper(db_issue.lang, db_user.nickname, history, slug=db_issue.slug)
    discussion_dict = _ddh.get_dict_for_argumentation(db_argument, None, None, history, db_user)
    item_dict = ItemDictHelper.get_empty_dict()

    return {
        'issues': issue_dict,
        'discussion': discussion_dict,
        'items': item_dict,
        'title': issue_dict['title']
    }