def __feedback_process(self, feedback_title, feedback_details): feedback_module = self.db.query(FeedBackModule).filter( FeedBackModule.issues_title == feedback_title).first() if feedback_module is not None: logging.error("feedback issues is exist") return False date_kits = DateToolKits() random_str = ''.join(random.sample(string.digits, 4)) serial_number = date_kits.get_now_str() + random_str logging.info("serial_number:" + serial_number) feedback_module = FeedBackModule() feedback_module.serial_number = serial_number feedback_module.issues_title = feedback_title feedback_module.issues_details = feedback_details feedback_module.solution_methods = "unknown" feedback_module.report_user_name = self.get_current_user() feedback_module.resolved_user_name = "unknown" feedback_module.status = "open" self.db.add(feedback_module) self.db.commit() return True
def __set_attendance_leave_accept_by_user_name(self, user_name): attendance = self.db.query(AttendanceModule).filter(AttendanceModule.user_name == user_name).first() if attendance is not None: score_criteria = self.db.query(ScoringCriteriaModule).filter(ScoringCriteriaModule.id == attendance.absence_id).first() # 1. 更新积分表 user_score = self.db.query(ScoreInfoModule).filter(ScoreInfoModule.user_name == user_name).first() score = user_score.current_scores + score_criteria.score_value recharge = False if user_score.purchase_points is True: if score > DefaultScoreConfig.current_scores: recharge = True if user_score and score_criteria: self.db.query(ScoreInfoModule).filter(ScoreInfoModule.user_name == user_name).update({ ScoreInfoModule.last_scores: user_score.current_scores, ScoreInfoModule.current_scores: score, ScoreInfoModule.purchase_points: recharge, }) self.db.commit() else: return False # 2. 更新出勤表 date_kits = DateToolKits() self.db.query(AttendanceModule).filter(AttendanceModule.user_name == user_name).update({ AttendanceModule.checked_in: True, AttendanceModule.attended: True, AttendanceModule.absence_apply_accept: True, AttendanceModule.checked_in_time: date_kits.get_now_str(), }) self.db.commit() logging.info("modify attendance succeed") # 3.更新积分历史信息表 date_kits = DateToolKits() history_module = ScoringHistoryModule() history_module.user_name = user_name history_module.criteria_id = score_criteria.id history_module.criteria_name = score_criteria.criteria_name history_module.score_value = score_criteria.score_value # 对应分数 history_module.transactor = self.get_current_user() # 处理人 history_module.date_time = date_kits.get_now_time() # 处理时间 self.db.add(history_module) self.db.commit() opt = "absent sub score" self.record_operation_history(user_name, opt) return True else: logging.error("modify attendance failed") return False
def __attendance_sign_by_user_name(self, user_name): attendance = self.db.query(AttendanceModule).filter(AttendanceModule.user_name == user_name).first() date_kits = DateToolKits() if attendance is not None: # 1.更新签到表 self.db.query(AttendanceModule).filter(AttendanceModule.user_name == user_name).update({ AttendanceModule.checked_in: True, AttendanceModule.attended: True, AttendanceModule.absence_apply_accept: False, AttendanceModule.checked_in_time: date_kits.get_now_str() }) self.db.commit() logging.info("=====>modify attendance succeed") # 2. 如果是组织者,加分 organizer = self.db.query(OrganizerInfoModule).filter(OrganizerInfoModule.user_name == user_name).first() if organizer: logging.info("=====>%s is current organizer" % user_name) if organizer.current is True: logging.info("*******>%s is current organizer" % user_name) # 2.1. 更新积分表 score_criteria = self.db.query(ScoringCriteriaModule).filter( ScoringCriteriaModule.criteria_name == "例会主持").first() user_score = self.db.query(ScoreInfoModule).filter(ScoreInfoModule.user_name == user_name).first() if user_score and score_criteria: self.db.query(ScoreInfoModule).filter(ScoreInfoModule.user_name == user_name).update({ ScoreInfoModule.last_scores: user_score.current_scores, ScoreInfoModule.current_scores: user_score.current_scores + score_criteria.score_value, }) self.db.commit() # 2.2. 更新积分历史信息表 date_kits = DateToolKits() history_module = ScoringHistoryModule() history_module.user_name = user_name history_module.criteria_id = score_criteria.id history_module.criteria_name = score_criteria.criteria_name history_module.score_value = score_criteria.score_value # 对应分数 history_module.transactor = self.get_current_user() # 处理人 history_module.date_time = date_kits.get_now_time() # 处理时间 self.db.add(history_module) self.db.commit() opt = "add organizer score" self.record_operation_history(user_name, opt) return True else: logging.error("modify attendance failed") return False