コード例 #1
0
ファイル: signals.py プロジェクト: pgferretti/test-wable
def create_attendant(sender, instance, **kwargs):    
    attendant = instance
    print attendant
    if attendant.id:       
        att_old = Attendant.objects.get(pk=attendant.id)
        parse_attendant = parse.AttendantParse(objectId=att_old.parse_id)
        if att_old.img_attendant and 'http://' not in attendant.img_attendant:
            if '0_' not in att_old.img_attendant:
                if att_old.img_attendant != attendant.img_attendant:
                    parse_img_attendant = parse.get_image_parse(attendant.img_attendant, att_old.parse_img_attendant)
                    attendant.parse_img_attendant = parse_img_attendant.objectId
                    attendant.parse_img_attendant_url = parse_img_attendant.image.url
                    parse_attendant.imgAttendant = parse_img_attendant
        elif attendant.img_attendant and 'None' not in attendant.img_attendant and 'http://' not in attendant.img_attendant:
            parse_img_attendant = parse.get_image_parse(attendant.img_attendant, att_old.parse_img_attendant)
            attendant.parse_img_attendant = parse_img_attendant.objectId
            attendant.parse_img_attendant_url = parse_img_attendant.image.url
            parse_attendant.imgAttendant = parse_img_attendant
        elif 'http://' in attendant.img_attendant:
            attendant.parse_img_attendant_url = attendant.img_attendant
        parse.save_parse_attendant(attendant, parse_attendant)    
    else:
        parse_attendant = parse.AttendantParse()
        if attendant.img_attendant:
            parse_img_attendant = parse.get_image_parse(attendant.img_attendant)
            attendant.parse_img_attendant = parse_img_attendant.objectId
            attendant.parse_img_attendant_url = parse_img_attendant.image.url
            parse_attendant.imgAttendant = parse_img_attendant 
        attendant.parse_id = parse.save_parse_attendant(attendant, parse_attendant).objectId
コード例 #2
0
ファイル: signals.py プロジェクト: pgferretti/test-wable
def create_profile(sender, instance, **kwargs):
    user_profile = instance
    if user_profile.id :        
        up_old = UserProfile.objects.get(pk=user_profile.id) 
        parse_user_profile = parse.UserProfile(objectId=up_old.parse_id) 
        if up_old.img_profile != user_profile.img_profile:
            if up_old.parse_img_profile:
                parse_img_perfil = parse.get_image_parse(user_profile.img_profile, up_old.parse_img_profile)
                user_profile.parse_img_profile = parse_img_perfil.objectId
                user_profile.parse_img_profile_url = parse_img_perfil.image.url
                parse_user_profile.imgPerfil = parse_img_perfil
            else:
                parse_img_perfil = parse.get_image_parse(user_profile.img_profile)
                user_profile.parse_img_profile = parse_img_perfil.objectId
                user_profile.parse_img_profile_url = parse_img_perfil.image.url
                parse_user_profile.imgPerfil = parse_img_perfil
        elif up_old.parse_img_profile_url:
            user_profile.parse_img_profile_url = up_old.parse_img_profile_url
        
        user_profile.parse_id = parse.save_parse_profile(user_profile, parse_user_profile).objectId
    else:        
        parse_user_profile = parse.UserProfile()
        if user_profile.img_profile:
            parse_img_perfil = parse.get_image_parse(user_profile.img_profile)
            user_profile.parse_img_profile = parse_img_perfil.objectId
            user_profile.parse_img_profile_url = parse_img_perfil.image.url
            parse_user_profile.imgPerfil = parse_img_perfil                 
        user_profile.parse_id = parse.save_parse_profile(user_profile, parse_user_profile).objectId
コード例 #3
0
ファイル: signals.py プロジェクト: pgferretti/test-wable
def create_establishment(sender, instance, **kwargs):
    establishment = instance
    if establishment.id:      
        ec_old = Establishment.objects.get(pk=establishment.id)
        if ec_old.parse_id:
            parse_establishment = parse.EstablishmentParse(objectId=ec_old.parse_id)
            if ec_old.img_logo != establishment.img_logo:
                parse_img_logo = parse.get_image_parse(establishment.img_logo, ec_old.parse_img_logo)
                establishment.parse_img_logo = parse_img_logo.objectId
                establishment.parse_img_logo_url = parse_img_logo.image.url
                parse_establishment.imgLogo = parse_img_logo
            elif ec_old.parse_img_logo_url:
                establishment.parse_img_logo_url = ec_old.parse_img_logo_url
            if ec_old.img_vitrin != establishment.img_vitrin: 
                parse_img_vitrin = parse.get_image_parse(establishment.img_vitrin, ec_old.parse_img_vitrin)
                establishment.parse_img_vitrin = parse_img_vitrin.objectId
                establishment.parse_img_vitrin_url = parse_img_vitrin.image.url
                parse_establishment.imgVitrin = parse_img_vitrin
            elif ec_old.parse_img_vitrin_url:
                establishment.parse_img_vitrin_url = ec_old.parse_img_vitrin_url
        else:
            parse_establishment = parse.EstablishmentParse()
            process = process_stablishment(establishment, parse_establishment)
            establishment = process[0]
            parse_establishment = process[1]
        parse.save_parse_establishment(establishment, parse_establishment)
    else:        
        parse_establishment = parse.EstablishmentParse()
        process = process_stablishment(establishment, parse_establishment)
        establishment = process[0]
        parse_establishment = process[1]
        establishment.parse_id = parse.save_parse_establishment(establishment, parse_establishment).objectId
コード例 #4
0
ファイル: signals.py プロジェクト: pgferretti/test-wable
def create_product(sender, instance, **kwargs):    
    product = instance
    print product
    if product.id:       
        pro_old = Product.objects.get(pk=product.id)
        parse_product = parse.ProductParse(objectId=pro_old.parse_id)
        if pro_old.img_product and 'http://' not in product.img_product:
            if '0_' not in pro_old.img_product:
                if pro_old.img_product != product.img_product:
                    parse_img_product = parse.get_image_parse(product.img_product, pro_old.parse_img_product)
                    product.parse_img_product = parse_img_product.objectId
                    product.parse_img_product_url = parse_img_product.image.url
                    parse_product.imgProduct = parse_img_product
        elif product.img_product and 'None' not in product.img_product and 'http://' not in product.img_product:
            parse_img_product = parse.get_image_parse(product.img_product, pro_old.parse_img_product)
            product.parse_img_product = parse_img_product.objectId
            product.parse_img_product_url = parse_img_product.image.url
            parse_product.imgProduct = parse_img_product
        elif 'http://' in product.img_product:
            product.parse_img_product_url = product.img_product
        parse.save_parse_product(product, parse_product)    
    else:
        parse_product = parse.ProductParse()
        if product.img_product:
            parse_img_product = parse.get_image_parse(product.img_product)
            product.parse_img_product = parse_img_product.objectId
            product.parse_img_product_url = parse_img_product.image.url
            parse_product.imgProduct = parse_img_product            
        product.parse_id = parse.save_parse_product(product, parse_product).objectId
コード例 #5
0
ファイル: signals.py プロジェクト: pgferretti/test-wable
def process_stablishment(establishment, parse_establishment):
    if establishment.img_logo:
        parse_img_logo = parse.get_image_parse(establishment.img_logo)
        establishment.parse_img_logo = parse_img_logo.objectId
        establishment.parse_img_logo_url = parse_img_logo.image.url
        parse_establishment.imgLogo = parse_img_logo
    if establishment.img_vitrin:
        parse_img_vitrin = parse.get_image_parse(establishment.img_vitrin)
        establishment.parse_img_vitrin = parse_img_vitrin.objectId
        establishment.parse_img_vitrin_url = parse_img_vitrin.image.url
        parse_establishment.imgVitrin = parse_img_vitrin    
    return (establishment, parse_establishment)