Esempio n. 1
0
def init(request):
    """
    View configuration for the initial discussion.

    :param request: request of the web server
    :return: dictionary
    """
    LOG.debug("Configuration for initial discussion. %s", request.matchdict)
    emit_participation(request)

    prepared_discussion = discussion.init(request.validated['issue'],
                                          request.validated['user'])
    modify_discussion_url(prepared_discussion)
    modify_discussion_bubbles(prepared_discussion, request.registry)

    rdict = prepare_request_dict(request)

    # redirect to oauth url after login and redirecting
    if request.authenticated_userid and 'service' in request.params and request.params[
            'service'] in oauth_providers:
        url = request.session['oauth_redirect_url']
        return HTTPFound(location=url)

    append_extras_dict(prepared_discussion, rdict,
                       request.authenticated_userid, False)
    if len(prepared_discussion['items']['elements']) == 1:
        _dh = DictionaryHelper(rdict['ui_locales'],
                               prepared_discussion['issues']['lang'])
        nickname = request.authenticated_userid if request.authenticated_userid else nick_of_anonymous_user
        _dh.add_discussion_end_text(prepared_discussion['discussion'],
                                    prepared_discussion['extras'],
                                    nickname,
                                    at_start=True)

    return prepared_discussion
Esempio n. 2
0
def choose(request):
    """
    View configuration for discussion step, where the user has to choose between given statements.

    This step is shown when the user has given multiple reasons at the same time for/against a statement. The
    corresponding premisegroup ids are given in the url.

    :param request: request of the web server
    :return: dictionary
    """
    # '/discuss/{slug}/choose/*pgroup_ids'
    LOG.debug("Choose a statement. %s", request.matchdict)
    emit_participation(request)

    db_user: User = request.validated['user']
    db_issue = request.validated['issue']

    history = history_handler.save_and_set_cookie(request, db_user, db_issue)

    prepared_discussion = discussion.choose(db_issue, db_user,
                                            request.validated['pgroup_uids'],
                                            history, request.path)

    rdict = prepare_request_dict(request)

    modify_discussion_url(prepared_discussion)
    modify_discussion_bubbles(prepared_discussion, request.registry)
    append_extras_dict(prepared_discussion, rdict,
                       request.authenticated_userid, False)

    return prepared_discussion
Esempio n. 3
0
def jump(request):
    """
    View configuration for the jump view.

    :param request: request of the web server
    :return: dictionary
    """
    emit_participation(request)

    db_user = request.validated['user']
    db_issue = request.validated['issue']

    history = history_handler.save_and_set_cookie(request, db_user, db_issue)

    prepared_discussion = discussion.jump(db_issue, db_user,
                                          request.validated['argument'],
                                          history, request.path)

    rdict = prepare_request_dict(request)

    if not request.validated.get("from_api", False):
        modify_discussion_url(prepared_discussion)

    modify_discussion_bubbles(prepared_discussion, request.registry)
    append_extras_dict(prepared_discussion, rdict,
                       request.authenticated_userid, True)

    return prepared_discussion
Esempio n. 4
0
def finish(request):
    """
    View configuration for discussion step, where we present a small/daily summary on the end

    :param request: request of the web server
    :return:
    """
    LOG.debug("Finish the discussion. %s", request.matchdict)
    emit_participation(request)
    emit_agreement_with_argument(request)

    db_user = request.validated['user']
    db_issue = request.validated['issue']

    history = history_handler.save_and_set_cookie(request, db_user, db_issue)

    prepared_discussion = discussion.finish(db_issue, db_user,
                                            request.validated['argument'],
                                            history)

    modify_discussion_url(prepared_discussion)
    modify_discussion_bubbles(prepared_discussion, request.registry)
    append_extras_dict(prepared_discussion, prepare_request_dict(request),
                       request.authenticated_userid, True)

    return prepared_discussion
Esempio n. 5
0
def support(request):
    """
    View configuration for discussion step, where we will present another supportive argument.

    :param request: request of the web server
    :return: dictionary
    """
    LOG.debug("Support a statement. %s", request.matchdict)
    emit_participation(request)

    db_user = request.validated['user']
    db_issue = request.validated['issue']

    history = history_handler.save_and_set_cookie(request, db_user, db_issue)
    prepared_discussion = discussion.support(db_issue, db_user,
                                             request.validated['arg_user'],
                                             request.validated['arg_sys'],
                                             history, request.path)
    rdict = prepare_request_dict(request)

    modify_discussion_url(prepared_discussion)
    modify_discussion_bubbles(prepared_discussion, request.registry)
    append_extras_dict(prepared_discussion, rdict,
                       request.authenticated_userid, False)

    return prepared_discussion
Esempio n. 6
0
def reaction(request):
    r"""
    View configuration for discussion step, where we will ask the user for her reaction (support, undercut, rebut)...

    Path: /discuss/{slug}/reaction/{arg_id_user:\d+}/{relation}/{arg_id_sys:\d+}

    :param request: request of the web server
    :return: dictionary
    """
    LOG.debug("React to a step. %s", request.validated)
    emit_participation(request)

    db_user = request.validated['user']
    db_issue = request.validated['issue']

    history = history_handler.save_and_set_cookie(request, db_user, db_issue)
    prepared_discussion = discussion.reaction(db_issue, db_user,
                                              request.validated['arg_user'],
                                              request.validated['arg_sys'],
                                              request.validated['relation'],
                                              history, request.path)
    rdict = prepare_request_dict(request)

    modify_discussion_url(prepared_discussion)
    modify_discussion_bubbles(prepared_discussion, request.registry)
    append_extras_dict(prepared_discussion, rdict,
                       request.authenticated_userid, True)

    return prepared_discussion
Esempio n. 7
0
def attitude(request):
    """
    View configuration for discussion step, where we will ask the user for her attitude towards a statement.
    Route: /discuss/{slug}/attitude/{position_id}

    :param request: request of the web server
    :return: dictionary
    """
    LOG.debug("View attitude: %s", request.matchdict)
    emit_participation(request)

    db_statement = request.validated['statement']
    db_issue = request.validated['issue']
    db_user = request.validated['user']

    history = history_handler.save_and_set_cookie(request, db_user, db_issue)
    prepared_discussion = discussion.attitude(db_issue, db_user, db_statement,
                                              history, request.path)
    modify_discussion_url(prepared_discussion)
    modify_discussion_bubbles(prepared_discussion, request.registry)

    rdict = prepare_request_dict(request)

    append_extras_dict(prepared_discussion, rdict,
                       request.authenticated_userid, False)

    return prepared_discussion
Esempio n. 8
0
def choose(request):
    """
    View configuration for discussion step, where the user has to choose between given statements.

    :param request: request of the web server
    :return: dictionary
    """
    # '/discuss/{slug}/choose/{is_argument}/{supportive}/{id}*pgroup_ids'
    LOG.debug("Choose a statement. %s", request.matchdict)
    emit_participation(request)

    db_user: User = request.validated['user']
    db_issue = request.validated['issue']

    history = history_handler.save_and_set_cookie(request, db_user, db_issue)

    pgroups = {
        'pgroup_uid': request.validated['pgroup_uid'],
        'pgroup_uids': request.validated['pgroup_uids'],
    }
    prepared_discussion = discussion.choose(db_issue, db_user,
                                            request.validated['is_argument'],
                                            request.validated['is_supportive'],
                                            pgroups, history, request.path)

    rdict = prepare_request_dict(request)

    modify_discussion_url(prepared_discussion)
    modify_discussion_bubbles(prepared_discussion, request.registry)
    append_extras_dict(prepared_discussion, rdict,
                       request.authenticated_userid, False)

    return prepared_discussion