Example #1
0
def add_photo_by_url(phurl, b, user, default, caption, title):
    outpath = settings.STATIC_ROOT + str(b.id) + "_" + str(b.city) + "_" + str(b.state)
    # print('retrieve'+str(urlparse.urlunparse(phurl)))
    try:
        urlretrieve(phurl, outpath)
    except:
        return None
    p = Photo(user=user, business=b, image=outpath, title=title, caption=caption, is_default=default)
    p.save(False)

    return p
Example #2
0
def add_photo_by_url(phurl, b,user,default):
    outpath =settings.STATIC_ROOT+str(b.id)+"_"+str(b.city)+"_"+str(b.state)
    #print('retrieve'+str(urlparse.urlunparse(phurl)))
    try:
        urlretrieve(phurl, outpath)
    except:
        return None
    bp = Photo(user=user, business=b, image=outpath, title=b.name, caption=b.name,is_default=default)
#    try:
    bp.save(False)
#    except:
#        print("Unexpected error:" + str(sys.exc_info()[0]))
#        logger.error("Unexpected error:" + str(sys.exc_info()[0]))
#        pass
    return bp
Example #3
0
def add_userphoto_by_url(phurl, user,default):
    outpath =settings.STATIC_ROOT+str(user.id)+"_"+str(user.username)
    #print('retrieve'+str(urlparse.urlunparse(phurl)))
    try:
        urlretrieve(phurl, outpath)
    except:
        return None
    print(outpath)
    up = Photo(user=user, business=None, image_profile=outpath, title=user.username, caption=user.username,is_default=default)
    try:
        up.save(False)
    except:
        print("Unexpected error:" + str(sys.exc_info()[0]))
        logger.error("Unexpected error:" + str(sys.exc_info()[0]))
        pass
    return up
Example #4
0
def add_photo_by_upload(img,b,user,default):
    bp = Photo(user=user, business=b, image=img, title=b.name, caption=b.name,is_default=default)
    bp.save(True)
    return bp
Example #5
0
def add_userphoto_by_upload(img,user,default):
    up = Photo(user=user, business=None,image_profile=img,  title=user.username, caption=user.username,is_default=default)
    up.save(True)
    return up