コード例 #1
0
ファイル: helper.py プロジェクト: kroschu/dbas
def __append_extras_dict_without_flag(request: Request, db_user: User,
                                      db_issue: Issue, db_statement: Statement,
                                      pdict: dict, attitude: Attitudes):
    """

    :param request:
    :param db_user:
    :param db_issue:
    :param db_statement:
    :param pdict:
    :param attitude:
    :return:
    """
    item_len = len(pdict['items']['elements'])
    _dh = DictionaryHelper(get_language_from_cookie(request), db_issue.lang)
    supportive = attitude in [Attitudes.AGREE, Attitudes.DONT_KNOW]
    logged_in = db_user is not None and db_user.nickname != nick_of_anonymous_user
    extras_dict = _dh.prepare_extras_dict(db_issue.slug, False, True, True,
                                          request.registry,
                                          request.application_url,
                                          request.path, db_user)

    if item_len == 0 or item_len == 1 and logged_in:  # is the discussion at the end?
        _dh.add_discussion_end_text(pdict['discussion'],
                                    extras_dict,
                                    db_user.nickname,
                                    at_justify=True,
                                    current_premise=db_statement.get_text(),
                                    supportive=supportive)
    pdict['extras'] = extras_dict
コード例 #2
0
ファイル: helper.py プロジェクト: kroschu/dbas
def __append_extras_dict_with_flag(request: Request, db_user: User,
                                   db_issue: Issue, db_statement: Statement,
                                   pdict: dict):
    """

    :param request:
    :param db_user:
    :param db_issue:
    :param db_statement:
    :param pdict:
    :return:
    """
    item_len = len(pdict['items']['elements'])
    _dh = DictionaryHelper(get_language_from_cookie(request), db_issue.lang)
    extras_dict = _dh.prepare_extras_dict(db_issue.slug,
                                          True,
                                          True,
                                          True,
                                          request.registry,
                                          request.application_url,
                                          request.path,
                                          db_user=db_user)

    if item_len == 0:  # is the discussion at the end?
        _dh.add_discussion_end_text(pdict['discussion'],
                                    extras_dict,
                                    db_user.nickname,
                                    at_dont_know=True,
                                    current_premise=db_statement.get_text())
    pdict['extras'] = extras_dict
コード例 #3
0
ファイル: helper.py プロジェクト: kroschu/dbas
def append_extras_dict_during_justification_argument(request: Request,
                                                     db_user: User,
                                                     db_issue: Issue,
                                                     pdict: dict):
    """

    :param request:
    :param db_user:
    :param db_issue:
    :param pdict:
    :return:
    """
    system_lang = get_language_from_cookie(request)
    item_len = len(pdict['items']['elements'])
    _dh = DictionaryHelper(system_lang, db_issue.lang)
    logged_in = (db_user
                 and db_user.nickname != nick_of_anonymous_user) is not None
    extras_dict = _dh.prepare_extras_dict(db_issue.slug,
                                          False,
                                          True,
                                          True,
                                          request.registry,
                                          request.application_url,
                                          request.path,
                                          db_user=db_user)
    # is the discussion at the end?
    if item_len == 0 or item_len == 1 and logged_in or 'login' in pdict[
            'items']['elements'][0].get('id'):
        _dh.add_discussion_end_text(pdict['discussion'],
                                    extras_dict,
                                    request.authenticated_userid,
                                    at_justify_argumentation=True)

    pdict['extras'] = extras_dict
コード例 #4
0
def __append_extras_dict_during_justification_statement(
        request: Request, db_user: User, db_issue: Issue,
        db_statement: Statement, pdict: dict, attitude: Attitudes):
    system_lang = get_language_from_cookie(request)
    supportive = attitude in [Attitudes.AGREE, Attitudes.DONT_KNOW]
    item_len = len(pdict['items']['elements'])
    _dh = DictionaryHelper(system_lang, db_issue.lang)
    logged_in = (db_user
                 and db_user.nickname != nick_of_anonymous_user) is not None

    if attitude in (Attitudes.AGREE, Attitudes.DISAGREE):
        extras_dict = _dh.prepare_extras_dict(db_issue.slug, False, True, True,
                                              request.registry,
                                              request.application_url,
                                              request.path, db_user)
        if item_len == 0 or item_len == 1 and logged_in:
            _dh.add_discussion_end_text(
                pdict['discussion'],
                extras_dict,
                db_user.nickname,
                at_justify=True,
                current_premise=db_statement.get_text(),
                supportive=supportive)

    else:
        extras_dict = _dh.prepare_extras_dict(db_issue.slug,
                                              True,
                                              True,
                                              True,
                                              request.registry,
                                              request.application_url,
                                              request.path,
                                              db_user=db_user)
        # is the discussion at the end?
        if item_len == 0:
            _dh.add_discussion_end_text(
                pdict['discussion'],
                extras_dict,
                db_user.nickname,
                at_dont_know=True,
                current_premise=db_statement.get_text())

    pdict['extras'] = extras_dict
コード例 #5
0
ファイル: helper.py プロジェクト: tbsschroeder/dbas
def append_extras_dict(pdict: dict, rdict: dict, nickname: str, is_reportable: bool) -> None:
    """

    :param pdict: prepared dict for rendering
    :param rdict: request dictionary
    :param nickname: request.authenticated_userid
    :param is_reportable: Same as discussion.bubbles.last.is_markable, but TAL has no last indicator
    :return:
    """
    _dh = DictionaryHelper(rdict['ui_locales'], pdict['issues']['lang'])
    db_user = DBDiscussionSession.query(User).filter_by(
        nickname=nickname if nickname else nick_of_anonymous_user).first()
    pdict['extras'] = _dh.prepare_extras_dict(rdict['issue'].slug, is_reportable, True, True, rdict['registry'],
                                              rdict['app_url'], rdict['path'], db_user)