def preparation_for_justify_argument(db_issue: Issue, db_user: User, db_argument: Argument, relation: str, supportive: bool, history, path): """ Prepares some parameter for the justification step for an argument :param db_issue: :param db_user: :param db_stmt_or_arg: :param relation: :param supportive: :param history: :param path: :return: """ logger('ViewHelper', 'main') nickname = db_user.nickname slug = db_issue.slug disc_ui_locales = db_issue.lang _ddh = DiscussionDictHelper(disc_ui_locales, nickname, history, slug=slug) _idh = ItemDictHelper(disc_ui_locales, db_issue, path=path, history=history) # justifying argument item_dict = _idh.get_array_for_justify_argument(db_argument.uid, relation, db_user, history) discussion_dict = _ddh.get_dict_for_justify_argument( db_argument.uid, supportive, relation) return item_dict, discussion_dict
def preparation_for_justify_statement(history, db_user: User, path, db_issue: Issue, db_statement: Statement, supportive: bool): """ Prepares some parameter for the justification step for an statement. :param history: history :param db_user: User :param path: :param db_statement: Statement :param db_issue: Issue :param supportive: Boolean :return: dict(), dict(), dict() """ logger('ViewHelper', 'main') nickname = db_user.nickname slug = db_issue.slug disc_ui_locales = db_issue.lang _ddh = DiscussionDictHelper(disc_ui_locales, nickname, history, slug=slug) _idh = ItemDictHelper(disc_ui_locales, db_issue, path=path, history=history) voting_helper.add_click_for_statement(db_statement, db_user, supportive) item_dict = _idh.get_array_for_justify_statement(db_statement, db_user, supportive, history) discussion_dict = _ddh.get_dict_for_justify_statement( db_statement, slug, supportive, len(item_dict['elements']), db_user) return item_dict, discussion_dict
def __preparation_for_dont_know_statement(db_issue: Issue, db_user: User, db_stmt_or_arg: Statement, supportive: bool, history, path) -> Tuple[dict, dict]: """ Prepares some parameter for the "don't know" step :param db_issue: Current issue :param db_user: User :param db_stmt_or_arg: Statement :param supportive: Boolean :param history: :param path: request.path :return: dict(), dict(), dict() """ logger('ViewHelper', 'main') nickname = db_user.nickname slug = db_issue.slug disc_ui_locales = db_issue.lang _ddh = DiscussionDictHelper(disc_ui_locales, nickname, history, slug=slug) _idh = ItemDictHelper(disc_ui_locales, db_issue, path=path, history=history) discussion_dict = _ddh.get_dict_for_dont_know_reaction( db_stmt_or_arg.uid, nickname) item_dict = _idh.get_array_for_dont_know_reaction( db_stmt_or_arg.uid, supportive, db_user, discussion_dict['gender']) return item_dict, discussion_dict
def choose(db_issue: Issue, db_user: User, is_argument: bool, is_supportive: bool, pgroup: PremiseGroup, pgroup_ids: list, history: str, path: str) -> dict: """ Initialize the choose step for more than one premise in a discussion. Creates helper and returns a dictionary containing several feedback options regarding this argument. :param db_issue: :param db_user: :param is_argument: :param is_supportive: :param uid: :param pgroup: :param history: :param path: :return: """ logger('Core', 'Entering discussion.choose') issue_dict = issue_helper.prepare_json_of_issue(db_issue, db_user) disc_ui_locales = issue_dict['lang'] _ddh = DiscussionDictHelper(disc_ui_locales, db_user.nickname, history, slug=db_issue.slug) _idh = ItemDictHelper(disc_ui_locales, db_issue, path=path, history=history) discussion_dict = _ddh.get_dict_for_choosing(pgroup.uid, is_argument, is_supportive) item_dict = _idh.get_array_for_choosing(pgroup.uid, pgroup_ids, is_argument, is_supportive, db_user.nickname) return { 'issues': issue_dict, 'discussion': discussion_dict, 'items': item_dict, 'title': issue_dict['title'] }
def attitude(db_issue: Issue, db_user: User, db_statement: Statement, history: str, path: str) -> dict: """ Initialize the attitude step for a position in a discussion. Creates helper and returns a dictionary containing the first elements needed for the discussion. :param db_issue: Issue :param db_user: User :param db_statement: Statement with is_position == True :param history: Current history :param path: :return: prepared collection dict for the discussion :rtype: dict """ logger('Core', 'attitude') issue_dict = issue_helper.prepare_json_of_issue(db_issue, db_user) disc_ui_locales = db_issue.lang _ddh = DiscussionDictHelper(disc_ui_locales, db_user.nickname, slug=db_issue.slug) discussion_dict = _ddh.get_dict_for_attitude(db_statement) _idh = ItemDictHelper(disc_ui_locales, db_issue, path=path, history=history) item_dict = _idh.prepare_item_dict_for_attitude(db_statement.uid) return { 'issues': issue_dict, 'discussion': discussion_dict, 'items': item_dict, 'title': issue_dict['title'] }
def jump(db_issue: Issue, db_user: User, db_argument: Argument, history: str, path: str) -> dict: """ Initialize the jump step for an argument in a discussion. Creates helper and returns a dictionary containing several feedback options regarding this argument. :param request_dict: dict out of pyramid's request object including issue, slug and history and more :rtype: dict :return: prepared collection matchdict for the discussion """ logger('Core', 'Entering discussion.jzmp') issue_dict = issue_helper.prepare_json_of_issue(db_issue, db_user) disc_ui_locales = issue_dict['lang'] _ddh = DiscussionDictHelper(disc_ui_locales, db_user.nickname, history, slug=db_issue.slug) _idh = ItemDictHelper(disc_ui_locales, db_issue, path=path, history=history) discussion_dict = _ddh.get_dict_for_jump(db_argument.uid) item_dict = _idh.get_array_for_jump(db_argument.uid, db_issue.slug) return { 'issues': issue_dict, 'discussion': discussion_dict, 'items': item_dict, 'title': issue_dict['title'] }
def support(db_issue: Issue, db_user: User, db_arg_user: Argument, db_arg_sys: Argument, history: str, path: str) -> dict: """ Initialize the support step for the end of a branch in a discussion. Creates helper and returns a dictionary containing the first elements needed for the discussion. :param db_issue: :param db_user: :param db_arg_user: :param db_arg_sys: :param history: :param path: :return: """ logger('Core', 'Entering discussion.support') issue_dict = issue_helper.prepare_json_of_issue(db_issue, db_user) disc_ui_locales = issue_dict['lang'] _ddh = DiscussionDictHelper(disc_ui_locales, db_user.nickname, history, slug=db_issue.slug) _idh = ItemDictHelper(disc_ui_locales, db_issue, path=path, history=history) discussion_dict = _ddh.get_dict_for_supporting_each_other(db_arg_sys.uid, db_arg_user.uid, db_user.nickname) item_dict = _idh.get_array_for_support(db_arg_sys.uid, db_issue.slug) return { 'issues': issue_dict, 'discussion': discussion_dict, 'items': item_dict, 'title': issue_dict['title'] }
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 }
def init(db_issue: Issue, db_user: User) -> dict: """ Initialize the discussion. Creates helper and returns a dictionary containing the first elements needed for the discussion. :param db_issue: Issue :param db_user: User :return: prepared collection with first elements for the discussion """ logger('Core', 'main') slug = db_issue.slug issue_dict = issue_helper.prepare_json_of_issue(db_issue, db_user) disc_ui_locales = issue_dict['lang'] _ddh = DiscussionDictHelper(disc_ui_locales, nickname=db_user.nickname, slug=slug) item_dict = ItemDictHelper(disc_ui_locales, db_issue).get_array_for_start(db_user) discussion_dict = _ddh.get_dict_for_start(position_count=(len(item_dict['elements']))) return { 'issues': issue_dict, 'discussion': discussion_dict, 'items': item_dict, 'title': issue_dict['title'] }
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'] }
def choose(db_issue: Issue, db_user: User, pgroup_ids: [int], history: str, path: str) -> dict: """ Initialize the choose step for more than one premise in a discussion. Creates helper and returns a dictionary containing several feedback options regarding this argument. :param db_issue: :param db_user: :param pgroup_ids: :param history: :param path: :return: """ LOG.debug("Entering choose function") issue_dict = issue_helper.prepare_json_of_issue(db_issue, db_user) disc_ui_locales = issue_dict['lang'] created_argument: Argument = DBDiscussionSession.query(Argument).filter( Argument.premisegroup_uid == pgroup_ids[0]).one() is_supportive = created_argument.is_supportive conclusion_is_argument = created_argument.attacks is not None if conclusion_is_argument: conclusion = created_argument.attacks else: conclusion = created_argument.conclusion _ddh = DiscussionDictHelper(disc_ui_locales, db_user.nickname, history, slug=db_issue.slug) _idh = ItemDictHelper(disc_ui_locales, db_issue, path=path, history=history) discussion_dict = _ddh.get_dict_for_choosing(conclusion.uid, conclusion_is_argument, is_supportive) item_dict = _idh.get_array_for_choosing(conclusion.uid, pgroup_ids, conclusion_is_argument, is_supportive, db_user.nickname) return { 'issues': issue_dict, 'discussion': discussion_dict, 'items': item_dict, 'title': issue_dict['title'] }
def jump(db_issue: Issue, db_user: User, db_argument: Argument, history: str, path: str) -> dict: """ Initialize the jump step for an argument in a discussion. Creates helper and returns a dictionary containing several feedback options regarding this argument. :param db_issue: The issue that shall be jumped to :param db_user: The concerning user :param db_argument: :param history: :param path: :rtype: dict :return: prepared collection matchdict for the discussion """ LOG.debug("Entering jump function") issue_dict = issue_helper.prepare_json_of_issue(db_issue, db_user) disc_ui_locales = issue_dict['lang'] _ddh = DiscussionDictHelper(disc_ui_locales, db_user.nickname, history, slug=db_issue.slug) _idh = ItemDictHelper(disc_ui_locales, db_issue, path=path, history=history) discussion_dict = _ddh.get_dict_for_jump(db_argument.uid) item_dict = _idh.get_array_for_jump(db_argument.uid, db_issue.slug) return { 'issues': issue_dict, 'discussion': discussion_dict, 'items': item_dict, 'title': issue_dict['title'] }