def wrapper(self, *args, **kwargs): logging.info("[decorator]:post authorization") response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() response["status"] = False response["message"] = "无权限操作!" # 1、判断是否有登录,没有登录 if self.session["authorized"] is None or self.session[ "authorized"] is False: self.write(json.dumps(response)) return # 2、只有管理员有权限的页面只需判断管理员权限即可 if admin_only is True: logging.info("[decorator]:admin only is true") if self.session["admin"] is None or self.session[ "admin"] is False: self.write(json.dumps(response)) logging.warning("[decorator]:current user is No admin") return # 3、其他页面需要判断管理权限或者组织者权限 if self.session["admin"] is None or self.session["admin"] is False: if self.session["organizer"] is None or self.session[ "organizer"] is False: self.write(json.dumps(response)) logging.warning( "[decorator]:current user is No admin or organizer") return return method(self, *args, **kwargs)
def __exchange_apply_by_user_name(self, user_name, present_id): present_exchange = self.db.query(ExchangeRulesModule).filter( ExchangeRulesModule.id == present_id).first() # 1、判断规则是否存在 if present_exchange is None: logging.info("present min point is None") return False # 2、判断当前可兑换积分是否满足当前需要兑换物品的最小积分 current = self.__get_current_point(user_name) if current["exchange"] < present_exchange.exchange_min_score: logging.info( "current point [%d], need point [%d]" % (current["exchange"], present_exchange.exchange_min_score)) return False logging.info("current point [%d], exchanged point [%d]" % (current["current"], current["exchange"])) date_kits = DateToolKits() exchange_apply = ExchangeApplyModule() exchange_apply.exchange_accept = False exchange_apply.exchange_status = "apply" exchange_apply.user_name = user_name exchange_apply.current_scores = current["current"] exchange_apply.exchange_item = present_exchange.exchange_rule_name exchange_apply.datetime = date_kits.get_now_time() exchange_apply.need_score = present_exchange.exchange_rule_score self.db.add(exchange_apply) self.db.commit() return True
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() operation = self.get_argument("operation") # present = self.get_argument("present") present_id = self.get_argument("present_id") user_name = self.get_current_user() if operation == "exchange": ret = self.__exchange_apply_by_user_name(user_name, present_id) if ret is True: response["status"] = True response["message"] = "申请成功!" response["data"] = date_kits.get_now_day_str() opt = "apply a exchange, username: "******"status"] = False response["message"] = "积分兑换失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() operation = self.get_argument("operation") issues_id = self.get_argument("issues_id") prepare_score = self.get_argument("prepare_score") novel_score = self.get_argument("novel_score") report_score = self.get_argument("report_score") logging.info( "operation:%s, issues_id:%s,prepare_score:%s,novel_score:%s,report_score:%s" % (operation, issues_id, prepare_score, novel_score, report_score)) if operation == "evaluate": ret, message = self.__evaluate_by_issues_id( issues_id, prepare_score, novel_score, report_score) if ret is True: response["status"] = True response["message"] = "评价成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = message response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() operation = self.get_argument("operation") organizer_name = self.get_argument("organizer_name") organizer_id = self.get_argument("organizer_id") organizer_date = self.get_argument("time_date") logging.info(" organizer_id: " + organizer_id + " organizer_name: " + organizer_name + " organizer_date:" + organizer_date) if operation == "assign": ret = self.__assign_organizer_by_name(organizer_name, organizer_id, organizer_date) if ret is True: response["status"] = True response["message"] = "指定成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "指定失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
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 post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() operation = self.get_argument("operation") topic_user = self.get_argument("topic_user") topic_name = self.get_argument("topic_name") topic_brief = self.get_argument("topic_brief") topic_date = self.get_argument("topic_date") topic_id = self.get_argument("issues_id") issues_type = self.get_argument("issues_type", "designate") if operation == "add": ret = self.__add_topics(topic_user, topic_name, topic_brief, topic_date, issues_type) if ret is True: response["status"] = True response["message"] = "新增成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前议题已存在" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "delete": ret = self.__delete_topic_by_id(topic_id) if ret is True: response["status"] = True response["message"] = "删除成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前积分规则不支持" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "modify": ret = self.__modify_topic_by_id(topic_id, topic_user, topic_name, topic_brief, topic_date) if ret is True: response["status"] = True response["message"] = "修改成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前议题已存在" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def __set_attendance_absent_by_user_name(self, user_name, absent_id): 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 == absent_id).first() # 1.更新积分表 user_point = self.db.query(ScoreInfoModule).filter(ScoreInfoModule.user_name == user_name).first() score = user_point.current_scores + score_criteria.score_value recharge = False if user_point.purchase_points is True: if score > DefaultScoreConfig.current_scores: recharge = True if user_point and score_criteria: self.db.query(ScoreInfoModule).filter(ScoreInfoModule.user_name == user_name).update({ ScoreInfoModule.last_scores: user_point.current_scores, ScoreInfoModule.current_scores: score, ScoreInfoModule.purchase_points: recharge, }) self.db.commit() else: return False # 2. 更新出勤表 self.db.query(AttendanceModule).filter(AttendanceModule.user_name == user_name).update({ AttendanceModule.checked_in: True, AttendanceModule.attended: True, AttendanceModule.absence_apply_accept: True, }) 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 __evaluate_by_issues_id(self, issues_id, prepare_score, novel_score, report_score): issues_module = self.db.query(IssuesInfoModule).filter( IssuesInfoModule.id == issues_id).first() if issues_module is None: return False, "没有待评价议题" user_name = self.get_current_user() if user_name is None: return False, "获取用户失败" evaluation = self.db.query(EvaluationInfoModule).filter(EvaluationInfoModule.issues_id == issues_id).\ filter(EvaluationInfoModule.evaluate_user_name == user_name).first() if evaluation: self.db.query(EvaluationInfoModule).filter( EvaluationInfoModule.issues_id == issues_id).update( {EvaluationInfoModule.evaluate_finish: False}) self.db.commit() logging.info("already evaluate") return False, "您已评价该议题" date_kits = DateToolKits() evaluation_module = EvaluationInfoModule() evaluation_module.issues_id = issues_module.id # 议题ID evaluation_module.issues_title = issues_module.issues_title # 议题名称 evaluation_module.keynote_user_name = issues_module.user_name # 主讲人用户名 evaluation_module.evaluate_user_name = user_name # 评价者用户名 evaluation_module.evaluate_time = date_kits.get_now_time() # 评价时间 evaluation_module.issues_prepare_score = prepare_score # 议题准备情况得分 evaluation_module.issues_content_score = novel_score # 议题内容得分 evaluation_module.issues_lecture_score = report_score # 演讲情况得分 evaluation_module.issues_reserved_score = 0 # 保留备用 evaluation_module.evaluate_finish = False # 是否结束评价 self.db.add(evaluation_module) self.db.commit() logging.info("issues_evaluate_count:%d" % issues_module.issues_evaluate_count) self.db.query(IssuesInfoModule).filter( IssuesInfoModule.id == issues_id).update({ IssuesInfoModule.issues_evaluate_count: issues_module.issues_evaluate_count + 1, }) self.db.commit() return True, "评价议题成功"
def wrapper(self, *args, **kwargs): logging.info("[decorator]:post authorization") response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() response["status"] = False response["message"] = "请先登录!" # 1、判断是否有登录,没有登录 if self.session["authorized"] is None or self.session[ "authorized"] is False: self.write(json.dumps(response)) return return method(self, *args, **kwargs)
def __check_date_time_is_valid(self): date_time_valid = False date_kits = DateToolKits() meetings = self.db.query(MeetingInfoModule).filter(MeetingInfoModule.current_meeting == True).all() min_date_time = meetings[0].meeting_date if meetings: for meeting in meetings: if date_kits.compare_time_src_less_then_dest(min_date_time, meeting.meeting_date) is False: min_date_time = meeting.meeting_date logging.info(min_date_time) if date_kits.compare_time_src_less_then_dest(min_date_time, date_kits.get_now_time()) is True: date_time_valid = True logging.info(date_time_valid) return date_time_valid
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() operation = self.get_argument("operation") serial_number = self.get_argument("serial_number") user_name = self.get_current_user() if operation == "delete_history": ret = self.__delete_history_opinions_by_serial_number( serial_number) if ret is True: response["status"] = True response["message"] = "删除问题记录成功" response["data"] = date_kits.get_now_day_str() opt = "delete feedback history: " + serial_number self.record_operation_history(user_name, opt) self.write(json.dumps(response)) else: response["status"] = False response["message"] = "删除问题记录失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() operation = self.get_argument("operation") serial_number = self.get_argument("serial_number") resolved_status = self.get_argument("resolved_status") solution_methods = self.get_argument("solution_methods") if operation == "resolved": ret = self.__update_opinions_by_serial_number( serial_number, resolved_status, solution_methods) if ret is True: response["status"] = True response["message"] = "更新问题状态失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "更新问题状态成功" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() operation = self.get_argument("operation") issues_id = self.get_argument("issues_id") logging.info("operation:" + operation + " issues_id:" + issues_id) if operation == "evaluate_finish": ret = self.__finish_issues_evaluation(issues_id) if ret is True: response["status"] = True response["message"] = "结束评价成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "结束评价失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def __update_opinions_by_serial_number(self, serial_number, status, solution): opinions = self.db.query(FeedBackModule).filter( FeedBackModule.serial_number == serial_number).first() if opinions is None: return False date = DateToolKits() self.db.query(FeedBackModule).filter( FeedBackModule.serial_number == serial_number).update({ FeedBackModule.status: status, FeedBackModule.solution_methods: solution, FeedBackModule.resolved_date: date.get_now_day_str(), FeedBackModule.resolved_user_name: self.get_current_user() }) self.db.commit() logging.info("update feedback status ok") return True
def __leave_apply_by_id(self, user_name, leave_id, leave_date): criteria = self.db.query(ScoringCriteriaModule).filter( ScoringCriteriaModule.id == leave_id).first() if criteria is None: logging.error("not scoring criteria exist, leave_id = %s" % leave_id) return False attendance = self.db.query(AttendanceModule).filter( AttendanceModule.user_name == user_name).first() if attendance is None: logging.error("not attendance exist user_name=%s" % user_name) return False date_kits = DateToolKits() absence_apply_time = date_kits.get_now_time() # 申请时间 self.db.query(AttendanceModule).filter( AttendanceModule.user_name == user_name).update({ AttendanceModule.absence_reason: criteria.criteria_name, AttendanceModule.absence_id: criteria.id, AttendanceModule.attended: False, AttendanceModule.absence_apply_accept: False, AttendanceModule.absence_apply_time: absence_apply_time, AttendanceModule.date_time: leave_date, }) self.db.commit() logging.info("user leave apply succeed") return True
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
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() operation = self.get_argument("operation") topic_name = self.get_argument("topic_name") topic_brief = self.get_argument("topic_brief") topic_date = self.get_argument("topic_date") user_name = self.get_current_user() logging.info(topic_date) time_diff = date_kits.cac_time_diff_with_current_by_str(topic_date) logging.info("time diff:" + str(time_diff)) valid_time = date_kits.check_time_is_ok(topic_date) if valid_time is False: response["status"] = False response["message"] = "选择时间不能早已当前时间!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "apply_issues": ret = self.__add_topics(user_name, topic_name, topic_brief, topic_date) if ret is True: response["status"] = True response["message"] = "新增成功!" response["data"] = date_kits.get_now_day_str() opt = "apply a issues, title: " + topic_name self.record_operation_history(user_name, opt) self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前议题已存在" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() operation = self.get_argument("operation") user_name = self.get_argument("user_name") leave_id = self.get_argument("leave_id", 0) leave_date = self.get_argument("leave_date", "none") logging.info( "operation:%s , user_name: %s, leave_id:%s leave_date: %s" % (operation, user_name, leave_id, leave_date)) if operation == "absent_apply": logging.info(leave_date) time_diff = date_kits.cac_time_diff_with_current_by_str(leave_date) logging.info("time diff:" + str(time_diff)) valid_time = date_kits.check_time_is_ok(leave_date) if valid_time is False: response["status"] = False response["message"] = "选择时间不能早已当前时间!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) logging.info("time out of range") return ret = self.__leave_apply_by_id(user_name, leave_id, leave_date) if ret is True: response["status"] = True response["message"] = "申请成功!" response["data"] = date_kits.get_now_day_str() opt = "apply a absent, username: "******"status"] = False response["message"] = "申请失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() user_name = self.get_argument("user_name") old_pass_word = self.get_argument("old_password") new_pass_word = self.get_argument("new_password") confirm = self.get_argument("confirm") logging.info( "user_name:%s old_pass_word:%s new_pass_word:%s confirm:%s" % (user_name, old_pass_word, new_pass_word, confirm)) if new_pass_word != confirm: response["status"] = False response["message"] = "两次输入的密码不一致!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if new_pass_word == old_pass_word: response["status"] = False response["message"] = "新密码不能等于老密码!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return ret = self.__modify_passwd_by_user_name(user_name, old_pass_word, new_pass_word) if ret is True: response["status"] = True response["message"] = "修改密码成功!" response["data"] = date_kits.get_now_day_str() opt = "modify password by " + user_name self.record_operation_history(user_name, opt) self.write(json.dumps(response)) else: response["status"] = False response["message"] = "修改密码失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() operation = self.get_argument("operation") issues_id = self.get_argument("issues_id") logging.info("operation:%s, issues_id:%s" % (operation, issues_id)) interested = False if operation == "interested": interested = True elif operation == "uninterested": interested = False else: response["status"] = False response["message"] = "异常失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return user_name = self.get_current_user() ret, message = self.__mark_interested_by_issues_id( issues_id, interested, user_name) if ret is True: response["status"] = True response["message"] = "反馈成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = message response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def __finish_issues_evaluation(self, issues_id): issues = self.db.query(IssuesInfoModule).filter( IssuesInfoModule.id == issues_id).first() if issues is None: return False # 1、计算议题得分 evaluation_module = self.db.query(EvaluationInfoModule).filter( EvaluationInfoModule.issues_id == issues_id).filter( EvaluationInfoModule.evaluate_finish == False).all() if evaluation_module is None: return False date_time = DateToolKits().get_now_time() issues_prepare_score = 0 issues_content_score = 0 issues_lecture_score = 0 evaluation_count = 0 for evaluation in evaluation_module: logging.info("====》evaluation_count:%d" % evaluation_count) evaluation_count = evaluation_count + 1 issues_prepare_score = issues_prepare_score + evaluation.issues_prepare_score issues_content_score = issues_content_score + evaluation.issues_content_score issues_lecture_score = issues_lecture_score + evaluation.issues_lecture_score self.db.query(EvaluationInfoModule).filter( EvaluationInfoModule.id == evaluation.id).update({ EvaluationInfoModule.evaluate_finish: True, EvaluationInfoModule.date_time: date_time, }) self.db.commit() logging.info("evaluation_count:%d" % evaluation_count) if evaluation_count is not 0: issues_prepare_score = issues_prepare_score / evaluation_count issues_content_score = issues_content_score / evaluation_count issues_lecture_score = issues_lecture_score / evaluation_count else: return False logging.info( "issues_prepare_score:%d, issues_content_score:%d, issues_lecture_score:%d" % (issues_prepare_score, issues_content_score, issues_lecture_score)) last_score = (issues_prepare_score + issues_content_score + issues_lecture_score) / 3 logging.info("last_score:%d, evaluation_count:%d" % (last_score, evaluation_count)) # 2、将议题标记为结束 self.db.query(IssuesInfoModule).filter( IssuesInfoModule.id == issues_id).update({ IssuesInfoModule.issues_evaluate_finish: True, IssuesInfoModule.issues_score: last_score, }) self.db.commit() # 3、更新用户得分信息 real_score = last_score # 3.1 是否是系统用户 if issues.is_system_user is True: # 3.2 是否是主动申请 if issues.voluntary_apply is True: score_rule = self.db.query(ScoringCriteriaModule).\ filter(ScoringCriteriaModule.criteria_name == "主动申报").first() if score_rule: real_score = last_score + score_rule.score_value logging.info("current issues is apply, add %d" % score_rule.score_value) history_module = ScoringHistoryModule() history_module.user_name = issues.user_name history_module.criteria_id = score_rule.id history_module.criteria_name = score_rule.criteria_name history_module.score_value = score_rule.score_value # 对应分数 history_module.transactor = self.get_current_user() # 处理人 history_module.date_time = date_time # 处理时间 self.db.add(history_module) self.db.commit() opt = "add issues apply score" self.record_operation_history(issues.user_name, opt) user_point = self.db.query(ScoreInfoModule).filter( ScoreInfoModule.user_name == issues.user_name).first() if user_point: self.db.query(ScoreInfoModule).filter( ScoreInfoModule.user_name == issues.user_name).update({ ScoreInfoModule.last_scores: user_point.current_scores, ScoreInfoModule.current_scores: user_point.current_scores + real_score, }) self.db.commit() logging.info("update user score Succeed") else: logging.info("update user score failed") # 4、更新用户得分历史信息 score_rule = self.db.query(ScoringCriteriaModule).filter(ScoringCriteriaModule.criteria_name == "议题得分") \ .first() if score_rule: history_module = ScoringHistoryModule() history_module.user_name = issues.user_name history_module.criteria_id = score_rule.id history_module.criteria_name = score_rule.criteria_name history_module.score_value = last_score # 对应分数 history_module.transactor = self.get_current_user() # 处理人 history_module.date_time = date_time # 处理时间 self.db.add(history_module) self.db.commit() opt = "add issues score" self.record_operation_history(issues.user_name, opt) return True
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() operation = self.get_argument("operation") user_name = self.get_argument("user_name") uid = self.get_argument("id") user_role = self.get_argument("role") logging.info("operation:%s , user_name: %s, role:%s id: %s" % (operation, user_name, user_role, uid)) if uid.isdigit() is False: response["status"] = False response["message"] = "id只支持数字!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return str_tmp = uid.encode("ascii") user_id = int(str_tmp) auth = self.__auth_check_by_user_name(self.session["user_name"]) if auth is False: response["status"] = False response["message"] = "您无权限操作!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "delete": ret = self.__delete_user_by_name(user_name) if ret is True: response["status"] = True response["message"] = "删除成功!" response["data"] = date_kits.get_now_day_str() opt = "delete user" self.record_operation_history(user_name, opt) self.write(json.dumps(response)) else: response["status"] = False response["message"] = "删除失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) self.__delete_point_by_name(user_name) return if operation == "modify": ret = self.__modify_user_info_by_id(user_id, user_name, user_role) if ret is True: response["status"] = True response["message"] = "修改成功!" response["data"] = date_kits.get_now_day_str() opt = "modify user role to " + user_role self.record_operation_history(user_name, opt) self.write(json.dumps(response)) else: response["status"] = False response["message"] = "修改失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "add": ret = self.__add_user(user_name, user_role) if ret is True: response["status"] = True response["message"] = "新增成功!" response["data"] = date_kits.get_now_day_str() opt = "add user" self.record_operation_history(user_name, opt) self.write(json.dumps(response)) else: response["status"] = False response["message"] = "当前用户已存在" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "show_pwd": ret, pass_word = self.__show_user_pass_word(user_name) if ret is True: response["status"] = True response["message"] = pass_word response["data"] = date_kits.get_now_day_str() opt = "show user password" self.record_operation_history(user_name, opt) self.write(json.dumps(response)) else: response["status"] = False response["message"] = pass_word response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() operation = self.get_argument("operation") user_name = self.get_argument("user_name", "unknown") absent_id = self.get_argument("absent_id", -1) logging.info("operation:%s , user_name: %s" % (operation, user_name)) if operation == "leave_accept": flags = self.__check_date_time_is_valid() if flags is False: response["status"] = False response["message"] = "时间未到,不允许签到!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return ret = self.__set_attendance_leave_accept_by_user_name(user_name) if ret is True: response["status"] = True response["message"] = "处理成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "签到失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "leave_reject": flags = self.__check_date_time_is_valid() if flags is False: response["status"] = False response["message"] = "时间未到,不允许签到!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return ret = self.__set_attendance_leave_reject_by_user_name(user_name) if ret is True: response["status"] = True response["message"] = "处理成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "签到失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "sign": flags = self.__check_date_time_is_valid() if flags is False: response["status"] = False response["message"] = "时间未到,不允许签到!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return ret = self.__attendance_sign_by_user_name(user_name) if ret is True: response["status"] = True response["message"] = "处理成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "签到失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "absent": flags = self.__check_date_time_is_valid() if flags is False: response["status"] = False response["message"] = "时间未到,不允许签到!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return ret = self.__set_attendance_absent_by_user_name(user_name, absent_id) if ret is True: response["status"] = True response["message"] = "处理成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "签到失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "start_sign": ret = self.__start_attendance_sign() if ret is True: response["status"] = True response["message"] = "处理成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "签到失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "reset_sign_table": ret = self.__reset_attendance_sign_tables() if ret is True: response["status"] = True response["message"] = "复位签到表成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "复位签到表失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return response["status"] = False response["message"] = "找不到对应的操作!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() operation = self.get_argument("operation") deduct_name = self.get_argument("deduct_name") deduct_id = self.get_argument("id") deduct_points = self.get_argument("deduct_points") str_subtraction = self.get_argument("subtraction") subtraction = True if str_subtraction == "false": subtraction = False if operation == "add": ret = self.__add_deduct(deduct_name, deduct_points, subtraction) if ret is True: response["status"] = True response["message"] = "新增成功!" response["data"] = date_kits.get_now_day_str() opt = "add credits rule: " + deduct_name self.record_operation_history(self.session["user_name"], opt) self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前积分规则已存在" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "delete": ret = self.__delete_deduct_by_id(deduct_id) if ret is True: response["status"] = True response["message"] = "删除成功!" response["data"] = date_kits.get_now_day_str() opt = "delete credits rule: " + deduct_name self.record_operation_history(self.session["user_name"], opt) self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前积分规则不支持" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "modify": ret = self.__modify_deduct_by_id(deduct_id, deduct_points) if ret is True: response["status"] = True response["message"] = "删除成功!" response["data"] = date_kits.get_now_day_str() opt = "modify credits rule" self.record_operation_history(self.session["user_name"], opt) self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前用户已存在" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() response["data"] = date_kits.get_now_day_str() rule_name = "none" rule_id = 0 need_score = 0 exchange_min_score = 0 exchange_id = 0 user_name = "none" operation = self.get_argument("operation") if operation == "exchange_reject" or operation == "exchange_confirm": exchange_id = self.get_argument("exchange_id") user_name = self.get_argument("user_name") else: rule_name = self.get_argument("rule_name") rule_id = self.get_argument("id") need_score = self.get_argument("need_score") exchange_min_score = self.get_argument("exchange_min_score") logging.info(" rule_name:" + rule_name + " rule_id:" + rule_id + " need_score:" + need_score + " exchange_min_score:" + exchange_min_score) if operation == "add": ret = self.__add_exchange_rule(rule_name, need_score, exchange_min_score) if ret is True: response["status"] = True response["message"] = "新增成功!" response["data"] = date_kits.get_now_day_str() opt = "add exchange rule: " + rule_name self.record_operation_history(self.session["user_name"], opt) self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前积分规则已存在" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "delete": ret = self.__delete_rule_by_id(rule_id) if ret is True: response["status"] = True response["message"] = "删除成功!" response["data"] = date_kits.get_now_day_str() opt = "delete exchange rule" self.record_operation_history(self.session["user_name"], opt) self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前积分规则不支持" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "modify": ret = self.__modify_rule_by_id(rule_id, need_score, exchange_min_score) if ret is True: response["status"] = True response["message"] = "删除成功!" response["data"] = date_kits.get_now_day_str() opt = "modify exchange rule" self.record_operation_history(self.session["user_name"], opt) self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "当前用户已存在" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "exchange_confirm": ret = self.__exchange_item_confirm(exchange_id, user_name) if ret is True: response["status"] = True response["message"] = "兑换成功!" response["data"] = date_kits.get_now_day_str() opt = "confirm exchanged,id:" + exchange_id self.record_operation_history(user_name, opt) self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "兑换失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "exchange_reject": ret = self.__exchange_item_reject(exchange_id) if ret is True: response["status"] = True response["message"] = "取消兑换成功!" response["data"] = date_kits.get_now_day_str() opt = "reject exchanged,id:" + exchange_id self.record_operation_history(user_name, opt) self.write(json.dumps(response)) return else: response["status"] = False response["message"] = "取消兑换失败" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def post(self): operation = "none" feedback_title = "none" feedback_details = "none" serial_number = "0" response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() operation = self.get_argument("operation") if operation == "feedback": feedback_title = self.get_argument("feedback_title", "none") feedback_details = self.get_argument("feedback_details", "none") logging.info( "operation:%s , feedback_title: %s, feedback_details:%s" % (operation, feedback_title, feedback_details)) else: serial_number = self.get_argument("serial_number", "0") logging.info("operation:%s , serial_number:%s" % (operation, serial_number)) if operation == "feedback": ret = self.__feedback_process(feedback_title, feedback_details) if ret is True: response["status"] = True response["message"] = "反馈成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "反馈失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "succeed": ret = self.__feedback_regression_succeed_process(serial_number) if ret is True: response["status"] = True response["message"] = "提交成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "提交失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "failure": ret = self.__feedback_regression_failure_process(serial_number) if ret is True: response["status"] = True response["message"] = "提交成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "提交失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return
def __mark_interested_by_issues_id(self, issues_id, interested, user_name): issues_module = self.db.query(IssuesInfoModule).filter( IssuesInfoModule.id == issues_id).first() if issues_module: assessment_module = self.db.query(AssessmentInfoModule).filter(AssessmentInfoModule.issues_id == issues_id).\ filter(AssessmentInfoModule.assessment_user_name == user_name).first() interested_count = issues_module.interested_count uninterested_count = issues_module.uninterested_count date_kits = DateToolKits() # 已存在 if assessment_module: if interested is True: if assessment_module.interested is True: return True, "评估议题成功" else: interested_count = interested_count + 1 uninterested_count = uninterested_count - 1 else: if assessment_module.interested is False: return True, "评估议题成功" else: interested_count = interested_count - 1 uninterested_count = uninterested_count + 1 self.db.query(AssessmentInfoModule).filter( AssessmentInfoModule.issues_id == issues_id).update({ AssessmentInfoModule.interested: interested, }) self.db.commit() self.db.query(IssuesInfoModule).filter( IssuesInfoModule.id == issues_id).update({ IssuesInfoModule.interested_count: interested_count, IssuesInfoModule.uninterested_count: uninterested_count, }) self.db.commit() return True, "评估议题成功" else: # 不存在 assessments = AssessmentInfoModule() assessments.issues_id = issues_id # 议题ID assessments.assessment_user_name = user_name # 评估者 assessments.assessment_time = date_kits.get_now_time() # 评估时间 assessments.assessment_finish = False if interested is True: assessments.interested = True interested_count = interested_count + 1 else: assessments.interested = False uninterested_count = uninterested_count + 1 self.db.add(assessments) self.db.commit() self.db.query(IssuesInfoModule).filter( IssuesInfoModule.id == issues_id).update({ IssuesInfoModule.interested_count: interested_count, IssuesInfoModule.uninterested_count: uninterested_count, }) self.db.commit() return True, "评估议题成功" else: return False, "没有待评估议题"
def post(self): response = {"status": True, "data": "", "message": "failed"} date_kits = DateToolKits() operation = self.get_argument("operation") issues_id = self.get_argument("issues_id") keynote_user_name = self.get_argument("keynote_user_name") meeting_room = self.get_argument("meeting_room") meeting_date = self.get_argument("meeting_date") issues_title = self.get_argument("issues_title") logging.info("issues_id: " + issues_id) if operation == "modify": ret = self.__modify_meeting_info_by_issues_id( issues_id, meeting_room, meeting_date) if ret is True: response["status"] = True response["message"] = "修改成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "修改失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "add": ret = self.__add_meeting_info(issues_id, keynote_user_name, meeting_room, meeting_date, issues_title) if ret is True: response["status"] = True response["message"] = "修改成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "修改失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "del": ret = self.__delete_meeting_info_by_id(issues_id) if ret is True: response["status"] = True response["message"] = "删除当前会议成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "删除当前会议失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "set_current": ret = self.__set_meeting_to_current(issues_id) if ret is True: response["status"] = True response["message"] = "设置为当前议题成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "设置当前议题失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "issues_finish": ret = self.__finish_current_meeting(issues_id) if ret is True: response["status"] = True response["message"] = "结束当前会议成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "结束当前会议失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return if operation == "issues_cancel": ret = self.__cancel_current_meeting(issues_id) if ret is True: response["status"] = True response["message"] = "取消当前会议成功!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) else: response["status"] = False response["message"] = "取消当前会议失败!" response["data"] = date_kits.get_now_day_str() self.write(json.dumps(response)) return