def sendEmailforContinue(): now = datetime.datetime.now() ts = now.strftime('%Y-%m-%d') feedbacks = feedbackDB.search_feedback() for fb in feedbacks: sendflag = commonFunctions.scheduleDay(fb.fDate, 2) if sendflag == 1: uId = entityInfoDB.search_uId_entity(fb.eId) user = userInfoDB.search_user(uId) emailContent = "Dear " + user.name +",\n\nThere is an entity which hasn't finished verification for two weeks. check details. \n\n Regards\n Women In Australia" name = user.role emailAddr = user.addr # testing subject = "Entity Status Checking" mail(emailContent, name, emailAddr, subject) entities = entityInfoDB.search_entitiesDB() for en in entities: sendflag = commonFunctions.scheduleDay(en.eSubDate, 2) if sendflag == 1: user = userInfoDB.search_user(en.euId) emailContent = "Dear " + user.name + ",\n\nThere is an entity which hasn't finished verification for two weeks. check details. \n\n Regards\n Women In Australia" name = user.role emailAddr = user.addr # testing subject = "Entity Status Checking" mail(emailContent, name, emailAddr, subject) print('do func2 time:',ts) time.sleep(5)
def fetch_message_function(): # data = request.get_data() # json_data = json.loads(data) # uId = json_data['uId'] uId = request.values.get("uId") msgs = messageDB.search_message_uId(uId) if msgs is None: return jsonify('No message.') resultMsg = dict() resultMsg['message'] = [] if msgs is not None: for al in msgs: result = dict() result['mId']= al.mId result['eId']= al.eId sender = userInfoDB.search_user(al.uId) result['sender'] = sender.uName receiver = userInfoDB.search_user(al.tuId) result['receiver'] = receiver.uName result['senderEmail'] = sender.email result['receiverEmail'] = receiver.email result['time']= al.time result['message']= al.message print(al.message) result['isRead']= al.isRead resultMsg['message'].append(result) print(resultMsg) return jsonify(resultMsg)
def approve_entity_function(): data = request.get_data() json_data = json.loads(data) print(json_data) eId = json_data['eId'] uId = json_data['vuId'] en = entityInfoDB.search_entity(eId) print(uId) u = userInfoDB.search_user(uId) if u is None: return jsonify('uId Error') if en is None: return jsonify('eId Error') if en.eStatus == '8': return jsonify('false') print(u.role) if u.role == 'Manager': if en.eStatus == '7': return jsonify('false') if u.role == 'Curator': if en.eStatus == '4' or en.eStatus == '7': return jsonify('false') date = time.strftime('%Y-%m-%d', time.localtime(time.time())) # Approved date en.eSubDate = date print(u.role) if u.role == 'Manager': print('en.status') en.eStatus = '7' if u.role == 'Curator': en.eStatus = '4' fd = feedbackDB.search_feedback_eId(eId) if fd is not None: feedbackDB.dele_feedbackFdb(eId) fnum = feedbackDB.search_feedback_num() + 1 fId = 'FB_' + str(fnum) date = time.strftime('%Y-%m-%d', time.localtime(time.time())) fb = Model.Feedback(fId, json_data['eId'], uId, json.dumps(json_data['feedback']), date) feedbackDB.add_feedback2db(fb) entityInfoDB.update_entity2db(en) user = userInfoDB.search_user(en.euId) if user is not None: url = '' #json_data['url'] if user.uvs == '0': if u.role == 'Manager': SendEmail.releaseEntityEmail(user, url) else: SendEmail.approveEntityEmail(user, url) return jsonify('true')
def reject_entity_function(): data = request.get_data() json_data = json.loads(data) print(json_data) eId = json_data['eId'] role = json_data['role'] uId = json_data['vuId'] user = userInfoDB.search_user(uId) if user is None: return jsonify('uId Error') en = entityInfoDB.search_entity(eId) if en is None: return jsonify('eId error') if en.eStatus == '8': return jsonify('false') if role == 'Manager': if en.eStatus == '7': return jsonify('false') if role == 'Curator': if en.eStatus == '4' or en.eStatus == '7': return jsonify('false') en.eStatus = '8' date = time.strftime('%Y-%m-%d', time.localtime(time.time())) # Rejected date en.eSubDate = date entityInfoDB.update_entity2db(en) fnum = feedbackDB.search_feedback_num() + 1 fId = 'FB_' + str(fnum) date = time.strftime('%Y-%m-%d', time.localtime(time.time())) fb = Model.Feedback(fId, json_data['eId'], uId, json.dumps(json_data['feedback']), date) feedbackDB.add_feedback2db(fb) user = userInfoDB.search_user(en.euId) if user is not None: url = '' #json_data['url'] if user.uvs == '0': SendEmail.rejectEntityEmail(user, url) return jsonify('true')
def message_detail_function(): mId = request.values.get("mId") al = messageDB.search_message_mId(mId) if al is None: return jsonify('mId error.') resultMsg = dict() resultMsg['message'] = [] # if msgs is not None: # for al in msgs: result = dict() result['mId'] = al.mId result['uId'] = al.uId sender = userInfoDB.search_user(al.uId) result['sender'] = sender.uName receiver = userInfoDB.search_user(al.tuId) result['receiver'] = receiver.uName result['time'] = al.time result['message'] = al.message result['isRead'] = al.isRead result['senderEmail'] = sender.email resultMsg['message'].append(result) print(resultMsg) return jsonify(resultMsg)