def add_person_comment(person_id, message): ''' Adds a comment to a person after enriching it with meta-data (date+time) @param person_id: person id to assign the comment to @type person_id: int @param message: defines the comment to set @type message: string @return the message incl. the metadata if everything was fine, False on err @rtype: string or boolean ''' msg = "" pid = -1 try: msg = str(message) pid = int(person_id) except (ValueError, TypeError): return False strtimestamp = strftime("%Y-%m-%d %H:%M:%S", gmtime()) msg = escape(msg, quote=True) dbmsg = "%s;;;%s" % (strtimestamp, msg) dbapi.set_person_data(pid, "comment", dbmsg) return dbmsg
def add_person_external_id(person_id, ext_sys, ext_id, userinfo=''): ''' Adds an external id for the person @param person_id: person id @type person_id: int @param ext_sys: external system @type ext_sys: str @param ext_id: external id @type ext_id: str ''' if userinfo.count('||'): uid = userinfo.split('||')[0] else: uid = '' tag = 'extid:%s' % ext_sys dbapi.set_person_data(person_id, tag, ext_id) log_value = '%s %s %s' % (person_id, tag, ext_id) dbapi.insert_user_log(userinfo, person_id, 'data_insertion', 'CMPUI_addexternalid', log_value, 'External id manually added.', userid=uid)