def add_attribute_portrait(uid, attribute_name, attribute_value, submit_user): status = False # identify the user exist # identify the attribute exist # identify the attribute exist in user_portrait # add attribute in user_portrait # submit user should has power to change???without try: user_result = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source'] except: return 'no user' try: attribute_result = es.get(index=attribute_index_name, doc_type=user_index_type, id=attribute_name)['_source'] except: return 'no attribute' attribute_value_list = json.loads(attribute_result['value']) if attribute_value not in attribute_value_list: return 'no attribute value' if attribute_name in user_result: return 'attribute exist' add_attribute_dict = {attribute_name: attribute_value} es.update(index=user_index_name, doc_type=user_index_type, id=uid, body={'doc':body}) status = True return status
def add_tag2group(uid_list, attribute_name, attribute_value): status = False #identify the attribute exist #for uid in uid_list #identify the attribute not in this user #add tag to this user try: attribute_exist = es_tag.get(index=attribute_index_name, doc_type=attribute_index_type, id=attribute_name)['_source'] except: return 'no attribute' attribute_exist_value_list = attribute_exist['attribute_value'].split('&') if attribute_value not in attribute_exist_value_list: return 'no attribute value' for uid in uid_list: try: user_exist = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source'] except: user_exist = {} if user_exist and attribute_name not in user_exist: add_attribute_dict = {attribute_name: attribute_value} es.update(index=user_index_name, doc_type=user_index_type, id=uid, body={'doc': add_attribute_dict}) status = True return status
def change_attribute_portrait(uid, attribute_name, attribute_value, submit_user): status = False #identify the user exist #identify the attribute exist #identify the attribute value exist #identify the submit_user have been admitted----without try: user_exist = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source'] except: return 'no user' try: attribute_result = es_tag.get(index=attribute_index_name, doc_type=attribute_index_type, id=attribute_name)['_source'] except: return 'no attribute' value_list = attribute_result['attribute_value'].split('&') if attribute_value not in value_list: return 'no attribute value' change_attribute_dict = {attribute_name: attribute_value} es.update(index=user_index_name, doc_type=user_index_type, id=uid, body={'doc': change_attribute_dict}) status = True return status
def add_attribute_portrait(uid, attribute_name, attribute_value, submit_user): status = False # identify the user exist # identify the attribute exist # identify the attribute exist in user_portrait # add attribute in user_portrait try: user_result = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source'] except: return 'no user' try: attribute_result = es_tag.get(index=attribute_index_name, doc_type=attribute_index_type, id=attribute_name)['_source'] except: return 'no attribute' attribute_value_list = attribute_result['attribute_value'].split('&') if attribute_value not in attribute_value_list: return 'no attribute value' if attribute_name in user_result: return 'attribute exist' add_attribute_dict = {attribute_name: attribute_value} es.update(index=user_index_name, doc_type=user_index_type, id=uid, body={'doc': add_attribute_dict}) status = True return status
def change_attribute_portrait(uid, attribute_name, attribute_value, submit_user): status = False #identify the user exist #identify the attribute exist #identify the attribute value exist #identify the submit_user have been admitted----without try: user_exist = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source'] except: return 'no user' try: attribute_result = es.get(index=attribute_index_name, doc_type=user_index_type, id=uid)['_source'] except: return 'no attribute' value_list = json.loads(attribute_result['value']) if attribute_value not in value_list: return 'no attribute value' es.update(index=user_index_name, doc_type=user_index_type, id=uid, body={'doc':body}) status = True return status
def add_tag2group(uid_list, attribute_name, attribute_value): status = False #identify the attribute exist #for uid in uid_list #identify the attribute not in this user #add tag to this user try: attribute_exist = es.get(index=attribute_index_name, doc_type=attribute_index_type, id=attribute_name)['_source'] except: return 'no attribute' attribute_exist_value_list = attribute_exist['attribute_value'].split('&') if attribute_value not in attribute_exist_value_list: return 'no attribute value' for uid in uid_list: try: user_exist = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source'] except: user_exist = {} if user_exist and attribute_name not in user_exist: add_attribute_dict = {attribute_name: attribute_value} es.update(index=user_index_name, doc_type=user_index_type, id=uid, body={'doc':add_attribute_dict}) status = True return status
def add_attribute_portrait(uid, attribute_name, attribute_value, submit_user): status = False # identify the user exist # identify the attribute exist # identify the attribute exist in user_portrait # add attribute in user_portrait try: user_result = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source'] except: return 'no user' try: attribute_result = es_tag.get(index=attribute_index_name, doc_type=attribute_index_type, id=attribute_name)['_source'] except: return 'no attribute' attribute_value_list = attribute_result['attribute_value'].split('&') if attribute_value not in attribute_value_list: return 'no attribute value' if attribute_name in user_result: return 'attribute exist' add_attribute_dict = {attribute_name: attribute_value} es.update(index=user_index_name, doc_type=user_index_type, id=uid, body={'doc':add_attribute_dict}) status = True return status