Python django.conf.settings.GOOGLE_API_KEY Examples

The following are 6 code examples of django.conf.settings.GOOGLE_API_KEY(). 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 also want to check out all available functions/classes of the module django.conf.settings , or try the search function .
Example #1
Source File: tests.py    From cornerwise with 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
Source File: common.py    From opentaps_seas with 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
Source File: utils.py    From opentaps_seas with 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
Source File: context_processors.py    From pets with 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
Source File: context_processors.py    From influence-texas with 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
Source File: context_processors.py    From micromasters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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,
        }
    }