示例#1
0
文件: views.py 项目: HEPData/hepdata3
def process_year_facet(request, facets):
    url_path = modify_query('.search', **{'date': None})
    year_facet = get_session_item(url_path)
    if len(year_facet) == 0 or (request.full_path[:-1] == url_path or request.full_path == url_path):
        # we update the facet if there is no value stored in the session,
        # or if the base url is the same as the stripped url
        year_facet = get_facet(facets, 'Date')
        if year_facet:
            year_facet = {decode_string(json.dumps(year_facet))}
            set_session_item(url_path, year_facet)

    if year_facet and len(year_facet) > 0:
        year_facet = list(year_facet)[0]

    return year_facet
示例#2
0
文件: views.py 项目: drjova/hepdata
def process_year_facet(request, facets):
    url_path = modify_query('.search', **{'date': None})
    year_facet = get_session_item(url_path)
    if len(year_facet) == 0 or (request.full_path[:-1] == url_path or request.full_path == url_path):
        # we update the facet if there is no value stored in the session,
        # or if the base url is the same as the stripped url
        year_facet = get_facet(facets, 'Date')
        if year_facet:
            year_facet = {decode_string(json.dumps(year_facet))}
            set_session_item(url_path, year_facet)

    if year_facet and len(year_facet) > 0:
        year_facet = list(year_facet)[0]

    return year_facet
示例#3
0
def test_session(app):
    with app.app_context():
        set_session_item('test', 'value_1')

        assert(get_session_item('test') == 'value_1')
示例#4
0
def test_session(app):
    with app.app_context():
        response = set_session_item('test', 'value_1')
        assert (response == "ok")
        assert (get_session_item('test') == 'value_1')