Пример #1
0
def prepare_request_dict(request: Request):
    """

    :param request:
    :return:
    """
    LOG.debug("Preparing request dict for renderer")
    db_user = request.validated['user']
    nickname = db_user.nickname if db_user.nickname != nick_of_anonymous_user else None
    db_last_topic = history_handler.get_last_issue_of(db_user)

    slug = __get_slug(request.matchdict)
    db_issue = __get_issue(request, slug, db_last_topic)

    issue_handler.save_issue_id_in_session(db_issue.uid, request)
    history = history_handler.save_and_set_cookie(request, db_user, db_issue)
    set_language_for_visit(request)

    return {
        'nickname': nickname,
        'user': db_user,
        'path': request.path,
        'app_url': request.application_url,
        'matchdict': request.matchdict,
        'params': request.params,
        'session': request.session,
        'registry': request.registry,
        'issue': db_issue,
        'history': history,
        'ui_locales': get_language_from_cookie(request)
    }
Пример #2
0
 def test_get_saved_issue(self):
     settings = self.user_tobi.settings
     self.assertEqual(settings.last_topic_uid,
                      history.get_last_issue_of(self.user_tobi).uid)