コード例 #1
0
ファイル: OM2MC.py プロジェクト: JohannMG/OM2MC-Python
def runEmailLink(startDate, endDate):
    

    res = ommc.getSurveyAllData(startDate, endDate)
    resObject = res.json()

    mergevars = dex.getMailchimpOtherMergeVars() 
    ''' e.g.: {  'POSTAL': ['zip', 'zipcode', 'postal']  }'''
    
    mailchimpBatch = []

    for survey in resObject: 
        emailIndex = ommc.getEmailQuestionIndex(survey)
        if emailIndex == None:
            continue; 

        mergedict = {}
        for m in mergevars.keys():
            mmIndex = ommc.getQuestionIndexFromStrings(survey, mergevars[m])
            if mmIndex != None: 
                mergedict[mmIndex] = m
        
        
        extracted = ommc.extractFieldsFromResponses(survey, emailIndex, mergedict) 
        mailchimpBatch = mailchimpBatch + extracted

    ommc.subcribeNewUsers( mailchimpBatch )
コード例 #2
0
ファイル: tests.py プロジェクト: JohannMG/OM2MC-Python
def TESTgetQuestionIndexFromStrings():
    sur = {
        'LNGS': [
            {'QUES' : [
                    {'Id': 'wrong', 'Type': 7, 'Text': 'lorem ip', 'IsHiddenQues': False},
                    {'Id': 'wrong 2', 'Type': 5, 'Text': 'ringd zip dingding', 'IsHiddenQues': False},
                    {'Id': 'correct', 'Type': 7, 'Text': 'I want fjksd please', 'IsHiddenQues': False}
                ]
            }
        ]    
    }

    results = OMdata.getQuestionIndexFromStrings(sur, ['hnksf', 'zip'])

    if (results == 1): 
        print 'getQuestionIndexFromStrings() [PASSES]'
    else:  
        print 'getQuestionIndexFromStrings() [FAILS]'