Esempio n. 1
0
def run():
    cons_api = api.PodioApi(
        19156174)  # Credentials for the applicant conversion application
    vd_api = api.PodioApi(19600457)  #With credentials for the VD application
    time_based_update(cons_api=cons_api, vd_api=vd_api)
    vd_scripts(vd_api=vd_api)
    update_widgets(
    )  # This one uses a client PODIO API, so it has it's own API object
Esempio n. 2
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID, client=True)
    item = podioApi.get_item(params['item_id'], external_id=False)
    if item['values'][122927930]['value']['values'][122923596][
            'value'] == 'GV' and item['values'][132671269]['value'] == 'Si':
        transformer = [
            ("122927930#122923594", 113794808),  #Nombre del trainee
            ("122927930#122923598", 113794809),  #Email
            ("122927930#122923597", 113794810),  #EP Id, o EXPA Code
            ("122927930#122923600", 113794811),  #TN-ID
            (122927945, 113796635),  #Fecha de llegada a Colombia
            (122927946, 113794814),  #Fecha de realización
            (122927947, 113794815),  #Fecha de finalización
            (122927935, 113794816),  #FOto de pasaporte
            (135327307,
             113794817),  #Foto del pasaporte con estampado de la visa (PIP)
            (122927942, 113794818),  #Seguro internacional
            (122927950, 113794819),  #Memodeal
        ]
        extra_data = {
            113794813: 1,  #TODO es un campo de categoría, probablemente LC
            113796330:
            1  #TODO qué es esto? Es un campo de categoría, pero no sabría cual
        }

        ans = podioApi.copy_item(params['item_id'], 14817777, transformer,
                                 extra_data)
        print ans
        return ans
Esempio n. 3
0
def update_country_applications():
    p_api = api.PodioApi(19156174)
    bd_api = expaApi.ExpaApi(account='*****@*****.**',
                             fail_attempts=10)
    apps = bd_api.get_interactions(interaction='applied',
                                   start_date='01-03-2018',
                                   end_date='17-03-2018',
                                   officeID=2010,
                                   program='ogx')
    update_dict = {}
    print(len(apps))
    for app in apps['items']:
        # add app expa_id to update_dict
        person_id = app['person']['id']
        try:
            models.Office.objects.get(
                expa_id=app['opportunity']['office']['parent_id'])
            if person_id in update_dict:
                update_dict[person_id] += 1
            else:
                update_dict[person_id] = 1
        except models.Office.DoesNotExist:
            continue

    #now it updates the PODIO field for country partner applications in all items
    for expa_id, applications in update_dict.iteritems():
        # Search for the person by using the PODIO search function
        search = p_api.search_in_application_v2(app_id=19156174,
                                                ref_type='item',
                                                query=expa_id)
        item_id = search['results'][0]['id']

        p_api.updateItem(item_id, {167580470: applications})
Esempio n. 4
0
def run(appID, params, hook=None):
    """
    Runs a hook.

    Parameters:
        appID: The ID of the application that called the hook

        params: The parameters coming from the POST data inside the hook
    """
    template = {
        'Ingles': 'englishMatchedMail',
        'Español': 'spanishMatchedMail',
    }

    transformer = {
        'nombre': 'name',
    }

    podioApi = api.PodioApi(appID)
    item = podioApi.getItem(params['item_id'], no_html=True)
    if item['values']['estado-en-expa'] == 'Match':
        data = tools.dictSwitch(item['values'], transformer)
        email = mailApi.MailApi(
            template[item['values']['proyecto']['values']['idioma-proyecto']])
        status = email.send_mail('*****@*****.**', [
            item['values']['entrevista']['values']['email'],
        ], data)
        podioApi.comment(
            'item', params['item_id'], {
                'value':
                'El correo ha sido enviado satisfactoriamente: ' + str(status)
            })
Esempio n. 5
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID, client=True)
    item = podioApi.get_item(params['item_id'], external_id=False)
    if item['values'][120840533]['value'] == 'Si':
        transformer = [
            ('120839833#120914599', 113795330), #Nombre del trainee
            ('120839833#120836241', 113795330), #Email del trainee
            ('120839833#120335070', 113795331), #EP Id, o EXPA Code
            ('120839833#120335071', 113795337), #Opportunity ID
            (120839834, 113795332), #Number of exchanges 
            (120839835, 113795335), #Skype ID
            (120839836, 113795336), #Facebook link
            (122096055, 113798817), #Tipo de documento
            (122096056, 113795341), #ID del documento
            (122096169, 113795344), #Fecha de viaje
            (122096170, 113795345), #Fecha de refreso
            (120839839, 113795344), #Día de comienzo del intercambio
            (120839837, 113795338), #Contacto en Colombia
            (120839838, 113795340), #Contacto en el exterior
            (120839840, 113795346), #Canal de coumunicación
            (120839842, 113795348), #Pasaporte o cédula escaneados
            (120839843, 113795349), #Seguro internacional
            (120839844, 113798819), #Visa
            (120839841, 113795347), #Documentos adjuntos
            (120839845, 113795350), #Seguro internacional de ASSIST Card?
            (122096171, 113799877), #Autorizo a AIESEC en Colombia
        ]
        extra_data = {
            113795333:1  #Para que el comité local sea Andes
        }
            
        ans = podioApi.copy_item(params['item_id'], 14817837, transformer, extra_data)
        return ans
Esempio n. 6
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID, client=True)
    item = podioApi.get_item(params['item_id'], external_id=False)
    if item['values'][112443321][
            'value'] == 'Aceptado como miembro de AIESEC' and item['values'][
                112443323]['value'] == 'Andes':
        transformer = [  #Primero el origen y después el destino
            (112443317, 117701584),  #Nombre del trainee
            (112443318, 118634876),  #Cedula
            (112443324, 117701824),  #Email
            (112443319, 127294461),  #Foto
            (112443325, 117701826),  #Celular
            (112443328, 120001811),  #Universidad
            (112443330, 127294462),  #Semestre
            #(, ), #Pasaporte
            #(, ), #Pasaporte con estampado de la visa
            #(, ), #Seguro internacional
            #(, ), #Memodeal
        ]
        extra_data = {
            117759550: 1,  #Asignarlo como newbie
            117701833: 3,  #Rol de TMP
        }

        ans = podioApi.copy_item(params['item_id'], 15280717, transformer,
                                 extra_data)
        return ans
Esempio n. 7
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID)
    item = podioApi.getItem(params['item_id'])
    pdb.set_trace()

    return 'success. item_id: %s, app_id: %s' % (params['item_id'], appID)
        
Esempio n. 8
0
def run(appID, params, hook=None):
    ans = ""
    hook = hook.email_document_hook
    podioApi = api.PodioApi(appID, client=hook.podio_user_client)
    item = podioApi.get_item(params['item_id'],
                             external_id=False,
                             no_html=True,
                             depth=2)
    email_document.email_document(item, hook, podioApi)
Esempio n. 9
0
def run(appID, params, hook=None):
    transformer = {
        'english-writing': 'writing', 
        'english-reading': 'reading',
        'english-listening': 'listening',
        'english-speaking': 'speaking',
        'world-citizen-after': 'wc_a',
        'solution-driven-before': 'sd_b',
        'empowering-others-after': 'eo_a',
        'horas-semanales': 'horas_semanales',
        'title': 'cargo',
        'world-citizen-before': 'wc_b',
        'self-aware-before': 'sa_b',
        'empowering-others-before': 'eo_b',
        'self-aware-after': 'sa_a',
        'lider': 'lider__nombre',
        'main-functions': 'main_functions',
        'software-knowledge': 'software_knowledge',
        'specific-knowledge': 'specific_knowledge',
        'kpis': 'critical_success_factors',
        'job-description': 'job_description',
        'solution-driven-after': 'sd_a',
        }

    podioApi = api.PodioApi(appID)
    item = podioApi.getItem(params['item_id'], no_html=True)
    
    data = tools.dictSwitch(item['values'], transformer)
    data['lider'] = item['values']['lider']['values']['title']
    data['area'] = item['values']['lider']['values']['nombre-del-cargo'].replace('LCVP ', "")
    data['horas_semanales'] = data['horas_semanales'].split('.')[0]
    print data

    generator = documentsApi.ODTTemplate('jdTemplate.odt')
    if item['values']['formato-del-jd'] == 'Word':
        fileExtension = '.odt' 
        jd = generator.renderODT(data)
    
    else:
        fileExtension = '.pdf'
        jd = generator.render(data)
    
    fileName = 'JD - %s' % data['cargo']
    email = EmailMessage()
    email.subject = fileName 
    email.body = 'Lo puedes encontrar como un archivo adjunto'
    email.from_email = '*****@*****.**'
    email.to = [item['values']['lider']['values']['correo-corporativo-aiesecandesorg'],]
    print email.to
    fileData = jd.read()
    #email.attach(fileName + fileExtension, fileData)
    #email.send()
    podioApi.appendFile(params['item_id'], fileName + fileExtension, fileData)


        
Esempio n. 10
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID)
    item = podioApi.getItem(params['item_id'])
    email = mailApi.MailApi('testMail')
    status = email.send_mail('*****@*****.**', [
        '*****@*****.**', '*****@*****.**',
        '*****@*****.**'
    ],
                             context=item['values'])
    print status
    return 'success %s' % item['values']['email']
Esempio n. 11
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID)
    item = podioApi.get_item(params['item_id'], external_id=False)
    email = item['values'][102329869]['value']
    a = podioApi.find_referenceable_items(121611822, text=email)
    if len(a) > 0:
        podioApi.updateItem(params['item_id'],
                            {121611822: int(a[0]['item_id'])})
    #pdb.set_trace()

    return 'success. item_id: %s, app_id: %s' % (params['item_id'], appID)
Esempio n. 12
0
def email_recordar_metas():
    """
    Este script le envía un correo electrónico a todos los miembros del LC que tienen metas para esta semana, pero aún no han reportado su cumplimiento
    """
    p_api = api.PodioApi(15389408)
    items = p_api.get_items_by_view(28622471)
    email_hook = models.EmailDocumentHook.objects.get(
        id=10
    )  #TODO: Esto es poco elegante, debo hallar una manera alternativa de hacer esto
    for item in items:
        email_document.email_document(item, email_hook, p_api)
Esempio n. 13
0
def email_quizz_sender(podio_app_id, week):
    p_api = api.PodioApi(podio_app_id)
    items = p_api.get_filtered_items({}, no_html=True)
    email = mailApi.MailApi("ECBALQuizAnswer")
    from_email = '*****@*****.**'
    for item in items:
        context = {}
        for value in item['values'].values():
            context[value['label'].split(' - ')[0]] = value['value']
            context['week'] = week
        to_email = [context['Email']]
        email.send_mail(from_email, to_email, context)
Esempio n. 14
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID, client=True)
    item = podioApi.get_item(params['item_id'], external_id=False)
    print item
    transformer = {
        '118632836#124721552':'127894715',#Area
        '118632836#117701833':'119050124',#TMP, TLP o EB
    }
    new_dict = tools.dictSwitch(item['values'], {}, transformer, ignore_unknown = True)
    ans = podioApi.updateItem(params['item_id'], new_dict)
    return ans
        
Esempio n. 15
0
def run(appID, params, hook=None):
    p_api = api.PodioApi(appID)
    item = p_api.get_item(params['item_id'])
    stage = item['values'][151795769]['value']
    stage_number = int(stage.split(' - ')[0])
    if stage_number != 0 and 159724899 not in item['values']:
        p_api.updateItem(params['item_id'], {
            159724899: {
                'start_utc': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            }
        })

    return 'success. item_id: %s, app_id: %s' % (params['item_id'], appID)
Esempio n. 16
0
def copiar_email_plenos():
    """
    Este script coge el correo electrónico, basado en la estructura, de los miembros en pleno derecho del comité y lo usa para actualizar el campo de correo de la base de datos
    """
    api = podioApi.PodioApi(16186489, client=True)
    plenos = api.get_filtered_items([{'key': 126714277, 'values': [1]}])
    for pleno in plenos:
        api.updateItem(
            pleno['item'], {
                125498432:
                pleno['values'][125498431]['value']['values'][117701824]
                ['value']
            })
    return plenos
Esempio n. 17
0
def email_falta_reportar():
    """
    Este script le envía un correo electrónico a todos los miembros del LC que tienen metas para esta semana, pero aún no han reportado su cumplimiento
    """
    p_api = api.PodioApi(15389408, client=True)
    items = p_api.get_items_by_view(28545599)
    email_hook = models.EmailDocumentHook.objects.get(
        id=9
    )  #TODO: Esto es poco elegante, debo hallar una manera alternativa de hacer esto
    print "iniciando iteraciones"
    for item in items:
        email_document.email_document(item, email_hook, p_api)
        print "Se le envió el recordatorio a %s" % item['values'][130741485][
            'value']
Esempio n. 18
0
def load_andes_ogx_opens(andes_opens):
    """
    """
    for person in andes_opens['items']:
        p_api = api.PodioApi(16504431)
        attributes = {
            128296712: person['first_name'],
            128296713: person['last_name'],
            134415808: person['email'],
            134414121: unicode(person['id']),
            134415678: person['phone'],
        }
        p_api.create_item({'fields': attributes})
        print("Se ha agregado a %s al espacio de OGX de opens" %
              person['email'])
Esempio n. 19
0
def run(appID, params, hook=None):
    ans = ""
    podioApi = api.PodioApi(appID)
    item = podioApi.get_item(params['item_id'], external_id=False)
    hook = hook.email_document_hook
    conditions = hook.conditions.all()
    all_conditions = True
    for condition in conditions:
        ans += unicode(condition)
        if condition.condition_type == "=":
            all_conditions = all_conditions and condition.value == item['values'][condition.field_id]['value']
            print item['values'][condition.field_id]['value']
    print ans
    if all_conditions:
        transformer_dict = {}
        related_transformer_dict = {}
        transformers = hook.transformers.all()
        attachments = []
        for transformer in transformers:
            if "#" in transformer.key:
                related_transformer_dict[transformer.key] = transformer.value
            else:
                transformer_dict[int(transformer.key)] = transformer.value
        data = tools.dictSwitch(item['values'], transformer_dict, related_transformer_dict, True)            
        print data
        flat_data = tools.flatten_dict(data)
        if hook.document:
            generator = documentsApi.ODTTemplate(hook.document.name + '.odt')#TODO: esto solo sirve con odts, toca formalizarlo 
            generated_document = generator.render(flat_data)
            file_name = hook.document.file_name + '.pdf'
            attachments.append({'filename':file_name, 'data': generated_document.read()})
            generated_document.seek(0)
            podioApi.appendFile(params['item_id'], file_name, generated_document)
        if hook.email_template:
            print hook.email_template.pk
            email = mailApi.MailApi(hook.email_template.name)
            from_email = tools.retrieve_email(hook.from_email, item)
            to_email = tools.retrieve_email(hook.to_email, item)
            if hook.cc_email:
                cc_email = tools.retrieve_email(hook.cc_email, item)
            else:
                cc_email = []
            print from_email
            print to_email
            status = email.send_mail(from_email, [to_email], flat_data, attachments=attachments)
        return status
    else:
        return ans
Esempio n. 20
0
def mark_not_interested():
    """
    Here are centralized all the scripts that require an specific action according to a PODIO field to happen after a day, two days, a week and so on.
    """
    cons_api = api.PodioApi(
        19156174)  # Credentials for the applicant conversion application
    items = cons_api.get_items_by_view(37277816)
    for item in items:
        params = {
            151795769: "-2 - Not interested - Explain why in the comments"
        }
        cons_api.updateItem(item['item'], params)
        cons_api.comment(
            'item', item['item'], {
                'value':
                "This person was marked as not interested automatically by a script, because they were too old (before February 1st)"
            })
Esempio n. 21
0
def email_falta_llenar():
    """
    Este script le envía un correo electrónico a todos los miembros del LC que no han llenado la tracking tool esta semana
    """
    p_api = api.PodioApi(15280717)
    items = p_api.get_filtered_items(None)
    unfilled_members = []
    for item in items:
        try:
            pass
        except KeyError:
            unfilled_members.append(item)
    email_hook = models.EmailDocumentHook.objects.get(
        id=10
    )  #TODO: Esto es poco elegante, debo hallar una manera alternativa de hacer esto
    for item in unfilled_members:
        email_document.email_document(item, email_hook, p_api)
Esempio n. 22
0
def load_applied_igv_trainees(apps):
    p_api = api.PodioApi(18275836)
    for app in apps['items']:
        attributes = {
            143813278: app['person']['first_name'],
            143813279: app['person']['last_name'],
            143813280: app['person']['email'],
            143813282: unicode(app['person']['id']),
            143813283: app['opportunity']['title'],  #Nombre del proyecto
            143813284: unicode(app['opportunity']['id']),
            143813638: unicode(app['id']),
            143813285: app['opportunity']['office']['name'],
            143813286: app['person']['home_lc']['country'],  #País origen
        }
        p_api.create_item({'fields': attributes})
        print(
            "Se ha agregado a %s al espacio de IGV Strike de Trainees aprobados"
            % app['person']['email'])
Esempio n. 23
0
def send_performance_email(): 
    p_api = api.PodioApi(19156174)
    email = mailApi.MailApi("Performance email")
    performance = {}
    gbm_date = '2018-04-06'
    recent_items = p_api.get_filtered_items({
        'last_edit_on':{'from':gbm_date}
    })
    for item in recent_items:
        if 151795767 not in item['values']:
            continue
        tm_id = item['values'][151795767]['value']['user_id']
        if tm_id not in performance:
            performance[tm_id] = {
                'contacted': 0,
                'applied': 0,
                'approved': 0,
                'name': item['values'][151795767]['value']['name'],
            }
        if 151950042 in item['values']:
            registration_date =  item['values'][151950042]['value']['start_date']
        status = item['values'][151795769]['value']
        status_number = status.split(' - ')[0]
        if status_number != 0: #if uncontacted, ignores everything
            if registration_date >= gbm_date:
                performance[tm_id]['contacted'] += 1
            elif 159724899 in item['values']:
                contacted_date = item['values'][159724899]['value']['start_date']
                if contacted_date >= gbm_date:
                    performance[tm_id]['contacted'] += 1

            if 158519539 in item['values']:
                application_date = item['values'][158519539]['value']['start_date']
                if application_date >= gbm_date:
                    performance[tm_id]['applied'] += 1
            if 159728809 in item['values']:
                approval_date = item['values'][159728809]['value']['start_date']
                if approval_date >= gbm_date:
                    performance[tm_id]['approved'] += 1
    status = email.send_mail('*****@*****.**', ['*****@*****.**', '*****@*****.**'], {'performance': performance})
    print(status)
Esempio n. 24
0
def run(appID, params, hook=None):
    """
    Runs a hook.

    Parameters:
        appID: The ID of the application that called the hook

        params: The parameters coming from the POST data inside the hook
    """
    template = {
        'Ingles': 'englishAcceptedMail',
        'Español': 'spanishAcceptedMail',
    }
    transformer = {
        'title': 'name',
    }

    podioApi = api.PodioApi(appID)
    item = podioApi.getItem(params['item_id'], no_html=True)
    if item['values']['paso-entrevista'] == 'Si':
        data = tools.dictSwitch(item['values'], transformer)
        data['project_name'] = item['values']['project-you-are-applying'][
            'values']['title']
        data['tn_id'] = item['values']['project-you-are-applying']['values'][
            'tn-id-2']

        email = mailApi.MailApi(
            template[item['values']['project-you-are-applying']['values']
                     ['idioma-proyecto']])
        status = email.send_mail('*****@*****.**', [
            item['values']['email'],
        ], data)
        podioApi.comment(
            'item', params['item_id'], {
                'value':
                'El correo ha sido enviado satisfactoriamente a ' +
                item['values']['email'] + ' con código ' + str(status)
            })
Esempio n. 25
0
def load_lc_goals():
    """
    Este método carga todas las metas mensuales presentes en el espacio de PODIO asociado a esta funcionalidad
    """
    #Un diccionario que asocia los field_ids de la aplicación con un mes
    month_dict = {
        139291307:(2, 2018),
        139291308:(3, 2018),
        139291309:(4, 2018),
        139291310:(5, 2018),
        139291311:(6, 2018),
        139291312:(7, 2018),
        139291313:(8, 2018),
        139291314:(9, 2018),
        139291315:(10, 2018),
        139291316:(11, 2018),
        139291317:(12, 2018),
        139291318:(1, 2019),
    }
    podioApi = api.PodioApi(17770429)
    items = podioApi.get_filtered_items({})
    for item in items:
        #Se crea un diccionario que luego entra como parámetro a la creación de las metas.
        create_dict = {
            'program_id':item['values'][139291304]['value'], #Para obtener el valor del programa del item de PODIO
            'office_id':item['values'][139291303]['value']['values'][130513591]['value'], #Para obtener el ID del LC del related item "LC"
        }
        month_goals = tools.dictSwitch(item['values'], month_dict, ignore_unknown=True)
        #Recorre todos los meses en el diccionario y crea un objeto de tipo MonthlyGoal para cada uno de ellos
        for date, goals in month_goals.iteritems():
            create_dict['month'] = date[0]
            create_dict['year'] = date[1]
            create_dict['defaults']= {
                item['values'][139291305]['value'].lower():goals['value'].split('.')[0]#Obtiene la meta, eliminando decimales, y la asigna al approved o al realized según sea el caso
            }
            print create_dict
            MonthlyGoal.objects.update_or_create(**create_dict)
Esempio n. 26
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID, client=True)
    item = podioApi.get_item(params['item_id'], external_id=False)
    if item['values'][120836970]['value'] == 'Si':
        transformer = [
            ('120335287#120914599', 114271376),  #Nombre del trainee
            ('120335287#120335070', 114271380),  #EP Id, o EXPA Code
            ('120335287#120335071', 114271381),  #TN-ID
            (120335289, 114271385),  #Cédula
            (120335855, 114271386),  #Cédula escaneada
            (120335856, 114271387),  #Fecha de inicio de la experiencia
            (120838710, 114271388),  #Fecha de pago
            (120838711, 114271389),  #Total pagado
            (120838712, 114271390),  #FOto del recibo de pago
            (120838713, 114271396),  #Seguro internacional
        ]
        extra_data = {
            114271377: 1,  #Para colocar el programa de OGCDP
            114271383: 1  #Para que el comité local sea Andes
        }

        ans = podioApi.copy_item(params['item_id'], 14874570, transformer,
                                 extra_data)
        return ans
Esempio n. 27
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID, client=True)
    item = podioApi.get_item(params['item_id'], external_id=False)
    if item['values'][122301101]['value'] == 'Si':
        transformer = [
            ('122301093#122297407', 114271376),  #Nombre del trainee
            ('122301093#122297411', 114271380),  #EP Id, o EXPA Code
            ('122301093#122297412', 114271381),  #TN-ID
            (122301095, 114271385),  #Cédula
            (122301096, 114271386),  #Cédula escaneada
            (122301097, 114271387),  #Fecha de inicio de la experiencia
            (122301098, 114271388),  #Fecha de pago
            (122301099, 114271389),  #Total pagado
            (122301100, 114271390),  #FOto del recibo de pago
            (122301102, 114271396),  #Autorizo a AIESEC en COlombia
        ]
        extra_data = {
            114271377: 2,  #Para colocar el programa de OGIP
            114271383: 1  #Para que el comité local sea Andes
        }

        ans = podioApi.copy_item(params['item_id'], 14874570, transformer,
                                 extra_data)
        return ans
Esempio n. 28
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID)
    item = podioApi.getItem(params['item_id'], no_html=True)

    if item['values']['enviar-certificado'] == 'Si':
        data = tools.hyphen_to_underscore(item['values'])
        data['project_start_date'] = data['project_start_date']['start_date']
        data['project_end_date'] = data['project_end_date']['start_date']
        data['work_hours'] = data['work_hours'].split('.')[0]
        data['today'] = datetime.today().strftime('%Y-%m-%d')
        generator = documentsApi.ODTTemplate('certVoluntariado.odt')
        fileExtension = '.pdf'
        jd = generator.render(data)
        
        fileName = 'Certificado Voluntariado - %s' % data['title']
        email = mailApi.MailApi('mailCertificado')
        status = email.send_mail('*****@*****.**', 
            [item['values']['email'], '*****@*****.**', '*****@*****.**'], data, 
            attachments=[{'filename': fileName + fileExtension, 'data': jd.read()}, ]
            )
        jd.seek(0)
        print 'return code AppendFile'
        podioApi.appendFile(params['item_id'], fileName + fileExtension, jd)
        print 'fin return code AppendFile'
Esempio n. 29
0
def run(appID, params, hook=None):
    podioApi = api.PodioApi(appID, client=True)
    item = podioApi.get_item(params['item_id'], external_id=False)
    if item['values'][50175872]['value'] == 'Social' and item['values'][117107512]['value'] == 'Si':
        transformer = [
            (44389815, 113794808), #Nombre del trainee
            (51046438, 113794809), #Email
            (44389816, 113794810), #EP Id, o EXPA Code
            (117106118, 113794811), #TN-ID
            (50175085, 113796635), #Fecha de llegada a Colombia
            (117106119, 113794814), #Fecha de realización
            (117106120, 113794815), #Fecha de finalización
            (44389821, 113794816), #Pasaporte
            (50175084, 113794817), #Pasaporte con estampado de la visa
            (44389822, 113794818), #Seguro internacional
            (50174533, 113794819), #Memodeal
        ]
        extra_data = {
            113794813:1, #TODO es un campo de categoría, probablemente LC
            113796330:1 #TODO qué es esto? Es un campo de categoría, pero no sabría cual
        }
            
        ans = podioApi.copy_item(params['item_id'], 14817777, transformer, extra_data)
        return ans
Esempio n. 30
0
def load_bangladesh_ogx_apps(apps):
    p_api = api.PodioApi(19156174)
    modified_eps = {}
    for app in apps['items']:
        print("Loading application of %s" % app['person']['full_name'])
        if app['person']['email'] not in modified_eps:
            search = p_api.search_in_application_v2(app_id=19156174,
                                                    ref_type='item',
                                                    query=app['person']['id'])
            if len(search['results']
                   ) == 1:  #Found exactly one, as it should be
                item_id = search['results'][0]['id']
                item = p_api.get_item(item_id, external_id=False)
                stage = item['values'][151795769]['value']
                stage_number = int(stage.split(' - ')[0])
                print(stage)
                if stage_number == 0:
                    p_api.updateItem(item_id, {
                        151795769:
                        '0 - Applied at least once AND UNCONTACTED'
                    })
                    print("EP has applied while being uncontacted, updated")
                elif stage_number == 1 or stage_number == 2:
                    p_api.updateItem(
                        item_id,
                        {151795769: '3 - Contacted and applied at least once'})
                    print("EP has applied, updated")
                elif stage_number < 1:
                    print("EP is not elegible for exchange, ignoring...")
                elif stage_number > 2:
                    print(
                        "This EP has already been accepted, or more, ignoring..."
                    )
            elif len(
                    search['results']
            ) == 0:  #Found 0, not ideal but not unexpected, gotta create it and generate a warning
                attributes = {
                    151791638: app['person']['first_name'],
                    151795763: app['person']['last_name'],
                    151795764: unicode(app['person']['id']),
                    154339943: {
                        'start_date': app['person']['dob']
                    },
                    151795766: {
                        'type': 'work',
                        'value': app['person']['email']
                    },
                    151795772: app['person']['home_lc']['name'],
                    151795769: "0 - Applied at least once AND UNCONTACTED",
                    151818116: app['person']['referral_type'],
                }
                new_item = p_api.create_item({'fields': attributes})
                item_id = new_item['item_id']
                p_api.comment(
                    'item', item_id, {
                        'value':
                        "This applications belongs to an EP who hasn't been loaded yet. It means that either 1) they registered before May, 2) they were assigned an EP Manager in EXPA before being loaded into PODIO or 3) the loading script didn't work properly. The reason should be found as soon as possible, and remedial action taken https://podio.com/users/1707071"
                    })
                print("No EP was found, created")
            else:  #FOund more than one, why, which one is it, help, abort
                print("######ERROR#####")
                print('Error, more than one item found')
                print("")
                break
            modified_eps[app['person']['email']] = item_id
        else:  #We already know this EP's PODIO ID
            print("Found in previously loaded apps, just add the comment")
            item_id = modified_eps[app['person']['email']]
        p_api.comment(
            'item', item_id, {
                'value':
                "This person has applied to the %s project '%s' in %s, %s (link: https://experience.aiesec.org/#/opportunities/%s/)"
                % (app['opportunity']['programmes']['short_name'],
                   app['opportunity']['title'],
                   app['opportunity']['office']['name'],
                   app['opportunity']['office']['country'],
                   app['opportunity']['id'])
            })