Python django.conf.settings.GOOGLE_API_KEY Examples

The following are 6 code examples for showing how to use django.conf.settings.GOOGLE_API_KEY(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .

Example 1
Project: cornerwise   Author: codeforboston   File: tests.py    License: MIT License 5 votes vote down vote up
def setUp(self):
        self.region = "Somerville, MA"
        self.addresses = ["240 Elm Street", "100 Broadway", "115 Medford Street"]
        self.geocoder = gmaps.GoogleGeocoder(settings.GOOGLE_API_KEY)
        self.proposal_importer_url = "https://58kr1azj04.execute-api.us-east-1.amazonaws.com/prod/somervillema" 
Example 2
Project: opentaps_seas   Author: opentaps   File: common.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        if settings.GOOGLE_API_KEY:
            context['GOOGLE_API_KEY'] = settings.GOOGLE_API_KEY
        return context 
Example 3
Project: opentaps_seas   Author: opentaps   File: utils.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def get_site_addr_loc(tags, site_id, session):
    show_google_map = False
    addr_loc = None
    site_address = ""
    allowed_tags = ['geoCity', 'geoCountry', 'geoPostalCode', 'geoState', 'geoStreet', 'geoAddr']
    geo_addr = None
    if settings.GOOGLE_API_KEY:
        if tags:
            for tag in tags:
                if tag in allowed_tags and tags[tag]:
                    if tag == 'geoAddr':
                        geo_addr = tags[tag]
                        continue
                    if site_address:
                        site_address = site_address + ", "
                    site_address = site_address + tags[tag]
                    if tag == 'geoStreet':
                        show_google_map = True

        if not show_google_map and geo_addr:
            if site_address:
                site_address = site_address + ", "
            site_address = site_address + geo_addr
        show_google_map = True

        if site_address and show_google_map:
            hash_object = hashlib.md5(site_address.encode('utf-8'))
            hash_key = hash_object.hexdigest()

            if hash_key in session:
                addr_loc = session[hash_key]

            if not addr_loc:
                geo = geocoder.google(site_address, key=settings.GOOGLE_API_KEY)

                if geo.json and geo.json["ok"]:
                    addr_loc = {"latitude": geo.json["lat"], "longitude": geo.json["lng"], "site_id": site_id}
                    session[hash_key] = addr_loc

    return addr_loc 
Example 4
Project: pets   Author: jllorencetti   File: context_processors.py    License: MIT License 5 votes vote down vote up
def analytics(request):
    return {"GOOGLE_API_KEY": settings.GOOGLE_API_KEY, "HOTJAR_TRACKING_KEY": settings.HOTJAR_TRACKING_KEY} 
Example 5
Project: influence-texas   Author: open-austin   File: context_processors.py    License: GNU General Public License v2.0 5 votes vote down vote up
def global_settings(request):
    # return any necessary values
    return {
        'GOOGLE_ANALYTICS': settings.GOOGLE_ANALYTICS,
        'GOOGLE_API_KEY': settings.GOOGLE_API_KEY
} 
Example 6
def api_keys(request):
    """
    Pass a `APIKEYS` dictionary into the template context, which holds
    IDs and secret keys for the various APIs used in this project.
    """
    return {
        "APIKEYS": {
            "GOOGLE": settings.GOOGLE_API_KEY,
            "GOOGLE_ANALYTICS": settings.GA_TRACKING_ID,
            "GOOGLE_ADWORDS": settings.ADWORDS_CONVERSION_ID,
            "GOOGLE_TAG_MANAGER": settings.GTM_CONTAINER_ID,
            "SMARTLOOK": settings.SL_TRACKING_ID,
        }
    }