Пример #1
0
def get_data_sender(manager, submission):
    if submission.owner_uid:
        try:
            data_sender_entity = Contact.get(manager, submission.owner_uid)
            return data_sender_entity.value("name"), data_sender_entity.short_code, data_sender_entity.id
        except Exception as e:
            pass #ignore and sending unknown datasender for backward compatibility.
    return NOT_AVAILABLE_DS, NOT_AVAILABLE
Пример #2
0
def _find_reporter_name(dbm, row):
    try:
        if row.value["owner_uid"]:
            data_sender_entity = Contact.get(dbm, row.value["owner_uid"])
            name = data_sender_entity.value('name')
            return name
    except Exception:
        pass
    return ""
Пример #3
0
def _lookup_contact_by_uid(dbm, uid):
    try:
        if uid:
            entity = Contact.get(dbm, uid)
            if entity.value('name'):
                return entity.value('name'), entity.short_code
            return entity.value('mobile_number'), entity.short_code
    except Exception:
        pass
    return UNKNOWN, UNKNOWN
Пример #4
0
def _contact_dict(entity_doc, dbm, form_model):
    contact = Contact.get(dbm, entity_doc.id)
    fields, labels, codes = get_entity_type_fields(dbm, form_model.form_code)
    data = tabulate_data(contact, form_model, codes)
    dictionary = OrderedDict()
    for index in range(0, len(fields)):
        dictionary.update({fields[index]: data['cols'][index]})
    dictionary.update({"entity_type": REPORTER_ENTITY_TYPE})
    dictionary.update({"void": contact.is_void()})

    return dictionary
Пример #5
0
 def _data_sender(self):
     try:
         data_sender = Contact.get(self.dbm, self.survey_response.owner_uid)
         #todo Do we need to store datasender question code information in enriched survey response?
         return self._get_data_sender_info_dict(data_sender, '')
     except:
         return {
             'id': self.ds_mobile_number,
             'last_name': None,
             'mobile_number': self.ds_mobile_number,
             'question_code': None,
             'deleted': None
         }
Пример #6
0
def _lookup_contact_by_uid(dbm, uid):
    ds_dict = {}
    try:
        if uid:
            contact = Contact.get(dbm, uid)
            mobile_number = contact.value('mobile_number')
            name = contact.value('name')
            ds_dict['mobile_number'] = mobile_number
            ds_dict['name'] = name if name else mobile_number
            ds_dict['email'] = contact.value('email') if contact.value(
                'email') else UNKNOWN
            ds_dict['location'] = contact.value('location') if contact.value(
                'location') else []
            ds_dict['geo_code'] = contact.geometry.get(
                'coordinates') if contact.geometry.get('coordinates') else []
            ds_dict['id'] = contact.short_code
    except Exception:
        pass
    return ds_dict