Exemplo n.º 1
0
 def get(self, key):
   ip_addr = self.request.remote_addr
   link = None
   try:
     link = models.GeoLink.get(key)
   except:
     self.error(404)
   if link:
     url = None
     res = quova.ipinfo(ip_addr)
     if link.url:
       # replace params
       url = link.url
       for code in models.GEOLINK_CODES:
         link_code_start = url.find(code)
         if link_code_start != -1:
           link_code_name = code.lstrip('{').rstrip('}')
           link_code_value = quova.get(res, link_code_name)
           if link_code_value:
             url = url.replace(code,link_code_value)
           else:
             url = url.replace(code,"")
     else:
       # parse linkmap to find appropriate link
       code_value = quova.get(res, link.linkmap_key)
       if code_value:
         url = link.linkmap_find(code_value)
     if url is None:
       # redirect to link info page
       self.redirect(link.infolink)
     else:
       self.redirect(url)
   else:
     self.error(404)
Exemplo n.º 2
0
  def get(self):
    ip_addr = self.request.remote_addr
    location = quova.ipinfo(ip_addr);
    user_state = quova.get(location, "state").capitalize()
    user_zip = quova.get(location, "postal_code")

    self.render('home/index.html', {'user_state':user_state,
      'user_zip':user_zip});
Exemplo n.º 3
0
  def get(self):
    user = users.get_current_user()
    if user:
      
      ip_addr = self.request.remote_addr
      location = quova.ipinfo(ip_addr);
      parts = {} 
      for code in models.GEOLINK_CODES:
        parts[code.lstrip('{').rstrip('}')] = quova.get(location, code.lstrip('{').rstrip('}'));

      links = models.GeoLink.gql("WHERE user = :1 ORDER BY created_on desc", user) 
      self.render('link/index.html', {'page_title':'link',
        'links': links,
        'parts': parts})
    else:
      self.error(403)