def exportStoreRowForUpdate(cls, row_doc, template_name='', timezone=sateraito_inc.DEFAULT_TIMEZONE): export_line = '' # command export_line += 'IU' # store_id disp export_line += ',' + sateraito_func.escapeForCsv(row_doc.store_id_disp) # store_id (scan id) export_line += ',' + sateraito_func.escapeForCsv(row_doc.store_id) #name export_line += ',' + sateraito_func.escapeForCsv(row_doc.name) # reply_message export_line += ',' + sateraito_func.escapeForCsv(row_doc.reply_message) # qrcode_id export_line += ',' + sateraito_func.escapeForCsv(row_doc.qrcode_id) # qrcode_url export_line += ',' + sateraito_func.escapeForCsv(row_doc.qrcode_url) # reply_user # reply_user = row_doc.reply_user if row_doc.reply_user else [] # export_line += ',' + sateraito_func.escapeForCsv(''.join(reply_user)) # form_template export_line += ',' + sateraito_func.escapeForCsv(template_name) # memo export_line += ',' + sateraito_func.escapeForCsv(row_doc.memo) export_line += '\r\n' export_line = sateraito_func.washShiftJISErrorChar(export_line) return export_line
def exportStoreDataRowForUpdate(cls, row_doc, timezone=sateraito_inc.DEFAULT_TIMEZONE): export_line = '' # command export_line += 'IU' # store_id export_line += ',' + sateraito_func.escapeForCsv(row_doc['store_id']) # store_name export_line += ',' + sateraito_func.escapeForCsv( row_doc['store_name'] if row_doc.has_key('store_name') else '') #user_id export_line += ',' + sateraito_func.escapeForCsv(row_doc['user_id']) # last_name export_line += ',' + sateraito_func.escapeForCsv(row_doc['last_name']) # first_name export_line += ',' + sateraito_func.escapeForCsv(row_doc['first_name']) # mail_address export_line += ',' + sateraito_func.escapeForCsv( row_doc['mail_address']) # created_date export_line += ',' + sateraito_func.escapeForCsv( row_doc['created_date']) export_line += '\r\n' export_line = sateraito_func.washShiftJISErrorChar(export_line) return export_line
def exportDocRowForUpdateQA(cls, row_doc, timezone=sateraito_inc.DEFAULT_TIMEZONE): line_id = '' user_info = sateraito_db.User.getUserInfo(row_doc.author_user_id) #logging.info(user_info) if user_info: line_id = user_info['line_id'] #============================== #Parse Question & Answer if row_doc.contentQA is None: return '' content_values = json.JSONDecoder().decode( sateraito_func.noneToZeroStr(row_doc.contentQA)) #logging.info(content_values) #sort list content_values_new = sorted(content_values, cmp=ExportCsv.compareValue) export_line = '' for item in content_values_new: logging.info(item) export_line_item = '' # command # export_line_item += 'IU' # user_id export_line_item += sateraito_func.escapeForCsv( row_doc.author_user_id) # line_id export_line_item += ',' + sateraito_func.escapeForCsv(line_id) #store_id export_line_item += ',' + sateraito_func.escapeForCsv( row_doc.store_id) # template_name export_line_item += ',' + sateraito_func.escapeForCsv( row_doc.template_name) #questtion number export_line_item += ',' + sateraito_func.escapeForCsv( str(item['number'])) #questtion string export_line_item += ',' + sateraito_func.escapeForCsv( item['question']) #answer string: export_line_item += ',' + sateraito_func.escapeForCsv( item['answer']) # submit_date export_line_item += ',' + sateraito_func.toShortLocalTime( row_doc.submit_date, timezone=timezone) export_line_item += '\r\n' export_line_item = sateraito_func.washShiftJISErrorChar( export_line_item) export_line += export_line_item return export_line
def exportDocRowForUpdate(cls, row_doc, timezone=sateraito_inc.DEFAULT_TIMEZONE, columns=[]): author_name = '' author_email = '' line_id = '' user_info = sateraito_db.User.getUserInfo(row_doc.author_user_id) #logging.info(user_info) if user_info: author_name = '{0} {1}'.format(user_info['last_name'], user_info['first_name']) author_email = user_info['mail_address'] line_id = user_info['line_id'] export_line = '' # command export_line += 'IU' # doc_id export_line += ',' + sateraito_func.escapeForCsv(row_doc.doc_id) # user_id export_line += ',' + sateraito_func.escapeForCsv( row_doc.author_user_id) # line_id export_line += ',' + sateraito_func.escapeForCsv(line_id) # store_id export_line += ',' + sateraito_func.escapeForCsv(row_doc.store_id) # #author_name # export_line += ',' + sateraito_func.escapeForCsv(author_name) # # author_email # export_line += ',' + sateraito_func.escapeForCsv(author_email) #export doc value doc_values = json.JSONDecoder().decode( sateraito_func.noneToZeroStr(row_doc.doc_values)) keys = doc_values.keys() if (len(columns) > 0): for column in columns: if column in keys: export_line += ',' + sateraito_func.escapeForCsv( doc_values[column]) else: export_line += ',' else: for column in keys: if column != '': export_line += ',' + sateraito_func.escapeForCsv( doc_values[column]) export_line += '\r\n' export_line = sateraito_func.washShiftJISErrorChar(export_line) return export_line
def exportDocRowForUpdateQA2(cls, row_doc, timezone=sateraito_inc.DEFAULT_TIMEZONE): line_id = '' user_info = sateraito_db.User.getUserInfo(row_doc.author_user_id) #logging.info(user_info) if user_info: line_id = user_info['line_id'] #============================== #Parse Question & Answer QA_list = [] num_list = [] #export doc value doc_values = json.JSONDecoder().decode( sateraito_func.noneToZeroStr(row_doc.doc_values)) logging.info(doc_values) for column in doc_values.keys(): if ExportCsv.checkColQA(column): num = int(column[1:]) if not num in num_list: num_list.append(num) question_field = sateraito_inc.QA_QUESTION_FORMAT.format( num) answer_field = sateraito_inc.QA_ANSWER_FORMAT.format(num) if doc_values.has_key( question_field) and doc_values.has_key( answer_field): QA_list.append({ 'num_index': num, 'question': question_field, 'answer': answer_field }) if len(QA_list) > 0: QA_list_new = sorted(QA_list, key=lambda objeto: objeto['num_index']) QA_list = QA_list_new #logging.info('==========QA_new_list==============') #logging.info(QA_list_new) export_line = '' for item in QA_list: export_line_item = '' # command # export_line_item += 'IU' # line_id export_line_item += sateraito_func.escapeForCsv(line_id) #store_id export_line_item += ',' + sateraito_func.escapeForCsv( row_doc.store_id) # template_name export_line_item += ',' + sateraito_func.escapeForCsv( row_doc.template_name) #questtion number export_line_item += ',' + sateraito_func.escapeForCsv( str(item['num_index'])) #questtion string export_line_item += ',' + sateraito_func.escapeForCsv( doc_values[item['question']]) #answer string: export_line_item += ',' + sateraito_func.escapeForCsv( doc_values[item['answer']]) # submit_date export_line_item += ',' + sateraito_func.toShortLocalTime( row_doc.submit_date, timezone=timezone) export_line_item += '\r\n' export_line_item = sateraito_func.washShiftJISErrorChar( export_line_item) export_line += export_line_item return export_line