Example #1
0
File: tasks.py Project: slok/dwarf
def click_link(token, request_meta_dict):

    #Extract data
    user_agent = request_meta_dict.get('HTTP_USER_AGENT')
    data = detect_browser_and_OS(user_agent)
    ip = request_meta_dict.get('REMOTE_ADDR')
    language = request_meta_dict.get('HTTP_ACCEPT_LANGUAGE',
                                     "None").split(",")[0]
    location = detect_country_location_with_geoip(ip).get('country_code')

    #TODO: remote host

    c = Click(token=token, browser=data[1], os=data[2], ip=ip,
              language=language, location=location)

    # Metrics
    ClickMetrics().increment()
    TotalClickMetrics().increment()
    c.save()
Example #2
0
File: tests.py Project: slok/dwarf
 def test_OS_browser_detail_detection(self):
     for i in test_data:
         correct_tuple = (i[3], i[0], i[1])
         self.assertEqual(correct_tuple, detect_browser_and_OS(i[2]))