Exemple #1
0
def get_bitly_url(str_query):
    import urllib2
    url = url_for('frontend/link/share', _full=True) + '?' + str_query
    if get_app().debug:
        url = "http://puertogeo.appspot.com" + url_for(
            'frontend/link/share') + '?' + str_query

    shortener_params = {
        "login": "******",
        "apiKey": "R_3a5d98588cb05423c22de21292cd98d6",
        "longurl": url,
        "format": "json"
    }

    form_data = urllib.urlencode(shortener_params)

    post_url = 'http://api.bitly.com/v3/shorten?' + form_data

    result = urllib2.urlopen(post_url).read()

    bitlydata = json.decode(result)

    bitly_hash = ""
    if 'url' in bitlydata['data']:
        bitly_hash = bitlydata['data']['hash']

    return url_for('frontend/link/map', _full=True, bitly_hash=bitly_hash)
Exemple #2
0
def do_realestate_linkfy(realestate, check_domain=False):
    if check_domain:
        if realestate.managed_domain == 1 and realestate.website and realestate.website.strip(
        ) != '':
            return realestate.website

    if realestate.domain_id and realestate.domain_id.strip() != '':
        return url_for('realestate/search_slug',
                       realestate_slug=realestate.domain_id)

    return url_for('realestate/home', realestate=str(realestate.key()))
Exemple #3
0
 def requestinfo_agent(self, params):  
   key                   = params['propery_key']
   property              = db.get(key) 
   realestate_key        = params['realestate_key'] 
   realestate            = db.get(realestate_key) 
   
   prop_operation_id     = params['prop_operation_id']
   
   contact_from_map = True
   if 'template_realestate' in params:
     contact_from_map = False
   
   # realestate_property_link  = '%s/propiedades.html#%s/%s' % (realestate.website, key, prop_operation_id)
   # realestate_property_link  = url_for('realestate/ficha', realestate=str(realestate.key()), key=key, oper=prop_operation_id,  _full=True) 
   realestate_property_link    = url_for('frontend/ficha', slug=get_property_slug(property), key=key, oper= prop_operation_id, _full=True) 
   
   # if contact_from_map:
     # if realestate.website is None or realestate.website.strip()=='': # Deben tener ptopiedades.html y rever tema #if realestate.managed_domain==1 :
       # str_query                 = params['query_string'] 
       # realestate_property_link  = get_bitly_url(str_query)
   
   # Armo context, lo uso en varios lugares, jaja!
   context = { 'server_url':                 'http://'+self.request.headers.get('host', 'no host')
              ,'realestate_name':            realestate.name
              ,'realestate_website':         realestate.website
              ,'realestate_property_link':   realestate_property_link
              ,'sender_name':                self.request.POST.get('sender_name')
              ,'sender_email':               self.request.POST.get('sender_email')
              ,'sender_comment':             self.request.POST.get('sender_comment')
              ,'sender_telephone':           self.request.POST.get('sender_telephone', None)
              ,'prop_operation_id':          prop_operation_id
             , 'support_url' :               'http://'+self.request.headers.get('host', 'no host')}
   
   # Mando Correo a agente.
   # Armo el body en plain text.
   body = self.render_template('email/'+self.config['directodueno']['mail']['requestinfo_agent']['template']+'.txt', **context)  
   # Armo el body en HTML.
   html = self.render_template('email/'+self.config['directodueno']['mail']['requestinfo_agent']['template']+'.html', **context)  
   
   # Envío el correo.
   mail.send_mail(sender="www.directodueno.com <%s>" % self.config['directodueno']['mail']['requestinfo_agent']['sender'], 
                to       = realestate.email,
                bcc      = self.config['directodueno']['mail']['reply_consultas']['mail'],
                subject  = u'Hicieron una consulta por un inmueble - DirectoDueño',
                body     = body,
                html     = html)
   
   self.save_consulta(property, realestate, contact_from_map, **context)
   
   self.response.write('ok')
Exemple #4
0
  def requestinfo_user(self, params):
    key                   = params['propery_key']
    property              = db.get(key) 
    realestate_key        = params['realestate_key'] 
    realestate            = db.get(realestate_key) 
    
    prop_operation_id     = params['prop_operation_id']
    
    contact_from_map = True
    if 'template_realestate' in params:
      contact_from_map = False
    
    #property_link  = '%s/propiedades.html#%s/%s' % (realestate.website, key, prop_operation_id)
    property_link  = url_for('frontend/ficha', slug=get_property_slug(property), key=key, oper= prop_operation_id, _full=True) 
    

    if contact_from_map:
      str_query                 = params['query_string'] 
      property_link             = get_bitly_url(str_query)
    
    
    # Armo context, lo uso en varios lugares, jaja!
    context = { 'server_url':                 'http://'+self.request.headers.get('host', 'no host')
               ,'realestate_name':            realestate.name
               ,'realestate_website':         realestate.website
               ,'property_link':              property_link
               ,'sender_name':                self.request.POST.get('sender_name')
               ,'sender_email':               self.request.POST.get('sender_email')
               ,'sender_comment':             self.request.POST.get('sender_comment')
               ,'prop_operation_id':          prop_operation_id
              , 'support_url' :               'http://'+self.request.headers.get('host', 'no host')}
    
    # Mando Correo a Usuario.
    # Armo el body en plain text.
    body = self.render_template('email/'+self.config['directodueno']['mail']['requestinfo_user']['template']+'.txt', **context)  
    # Armo el body en HTML.
    html = self.render_template('email/'+self.config['directodueno']['mail']['requestinfo_user']['template']+'.html', **context)  
    
    # Envío el correo.
    mail.send_mail(sender="www.directodueno.com <%s>" % self.config['directodueno']['mail']['requestinfo_user']['sender'], 
                 to       = context['sender_email'],
                 subject  = u"Consulta por un inmueble - DirectoDueño",
                 body     = body,
                 html     = html)
    # --------------------------------------------------------------------------------
      
    self.response.write('ok')
Exemple #5
0
def get_link_url(str_query, is_user_chared_link=True, slug='', description=''):
    mLink = None
    if is_user_chared_link:
        mLink = Link.new_for_user()
    else:
        mLink = Link.new_for_admin()
    mLink.description = description
    mLink.slug = slug
    mLink.query_string = str_query
    mLink.put()

    key_name_or_id = str(mLink.key().id())
    if description is None or len(description) < 1:
        slug = 'compartido-%s' % key_name_or_id
    return url_for('frontend/map/slug/key',
                   _full=True,
                   slug=slug,
                   key_name_or_id=key_name_or_id)