def get(self, mlsname, listingkey):
     """
     mlsname: string
     listingkey: string
     """
     res = {}
     res["count"] = 0
     res["imgs"] = []
     res["listingkey"] = listingkey
     if mlsname == "CRMLS":
         # query from db first to see if image is already there
         q = psydb.query({"listingkey": listingkey}, "properties")
         if q["colnames"] and q["results"]:
             # listingkey existing
             image = psydb.get_field("image", q["colnames"],q["results"][0]) 
             if image == "":
                 # if first time, query from crmls, then save to db (callback func)
                 image_obj = crmhandler.get_image(listingkey)
                 res["count"] = image_obj["image_count"]
                 for url, t in zip(image_obj["image_urls"], image_obj["media_types"]) :
                     res["imgs"].append({"url":url, "type":t})
                 @after_this_request
                 def update_image(response):
                     print('After request ...')
                     crmhandler.update_image(listingkey, image_obj)
                     return response
             else:
                 # return
                 imgs = eval(image)
                 res["imgs"] = imgs
                 res["count"] = len(imgs)        
     return res
Example #2
0
def propertyinfo(id):
    """
    View of single property
    """
    # query from db
    res = psydb.query({"id": id}, "properties")
    image = crmhandler.get_image(res["results"][0][2])
    return render_template('manage/property.html', res=res, image=image)
Example #3
0
def cityquery():
    """
    Lookup city full name by shortname (CRMLS for now)
    :return:
    """
    if any(request.args[item] for item in request.args):
        res = psydb.query(request.args, "citys")
        return render_template('manage/city.html', res=res)
    else:
        return render_template('manage/city.html')
Example #4
0
def propertyinfo_origin(id):
    """
    View of single property
    """
    # query from db
    res = psydb.query({"id": id}, "properties")
    # query from mls
    listing_id = res["results"][0][3]
    origin_data = crmhandler.query("(ListingID=%s)" % (listing_id, ), limit=1)
    origin = []
    for colname in res["colnames"]:
        origin.append(origin_data[0].get(colname, 'Null'))
    # TODO: also show the data query direct from mls
    return render_template('manage/property_origin.html',
                           res=res,
                           origin=origin)
 def get(self, mlsname, listingid):
     r = psydb.query({"mlsname": mlsname, "listingid": listingid}, "properties")
     res = {}
     if r['results'] and len(r['results']) > 0:
         res["success"] = "true"
         property_info = {}
         for k, v in zip(list(r['colnames']), list(r['results'][0])) :
             property_info[str(k)]= str(v)
         res["property_info"] = property_info
         # misc
         misc = eval(res["property_info"]["misc"]) 
         for k, v in misc.items():
            res["property_info"][k] = v
         # query city shortname to fullname
         res["property_info"]["city"] = psydb.getcityfullname(res["property_info"]["city"])
         res["property_info"]["county"] = psydb.getfullname("COUNTIES", res["property_info"]["county"])
     else:
         res["success"] = "false"
     return res