コード例 #1
0
ファイル: __init__.py プロジェクト: shahpranaf/ascolta
def detect_region():
    region = request.cookies.get('region')
    if region is None or Enigma.decrypt(request.cookies.get('region')) == '|':
        reg = Repo.getLocation()
        region = Enigma.encrypt('|'.join(
            [reg.get('country_name'),
             reg.get('country_code')]))

        @after_this_request
        def remember_region(response):
            response.set_cookie('region', region)

    g.region = region
コード例 #2
0
ファイル: __init__.py プロジェクト: shahpranaf/ascolta
def get_location():
    real_location, sel_location = Repo.getLocation(), Repo.getRegion()
    real_region = {
        'countryCode': real_location.get('country_name', ''),
        'countryName': real_location.get('country_code', '')
    }
    sel_region = {
        'countryCode': sel_location.get('countryCode', ''),
        'countryName': sel_location.get('countryName', '')
    }
    return jsonify({
        'status': True,
        'actual': real_region,
        'selected': sel_region
    })