Exemple #1
0
    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
Exemple #2
0
    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