Esempio n. 1
0
 def get(self):
     data = self.get_pro_data()
     svc = ApplyBackups(self, {"user_id": self.current_user.id})
     pro_backups_res = svc.get_list()
     page = self.getPage(pro_backups_res.data)
     data.update(page=page)
     return self.render_to_string("admin/apply/backup/index.html", **data)
Esempio n. 2
0
 def get(self):
     data = self.get_pro_data()
     svc = ApplyBackups(self, {"user_id": self.current_user.id})
     pro_backups_res = svc.get_list()
     page = self.getPage(pro_backups_res.data)
     data.update(page=page)
     return self.render_to_string("admin/apply/backup/index.html", **data)
Esempio n. 3
0
 def post(self):
     svc = ApplyBackups(self)
     pro_backup_res = svc.do_backups()
     pro_id = self.args.get("pro_id")
     data = self.get_pro_data(pro_id=pro_id)
     # svc = ApplyLoadBalance(self)
     # loadbalance_res = svc.get_loadbalance()
     # svc = ApplyBackups(self)
     # backups_res = svc.get_backups()
     data.update(
         pro_backup_res=pro_backup_res
     )  # , loadbalance_res=loadbalance_res, backups_res=backups_res)
     logger.info(pro_backup_res)
     if pro_backup_res.return_code == 0:
         self.add_message(
             u"定期备份信息添加成功!%s" %
             STATUS_PRO_TABLES.get(pro_backup_res.data.status).todo_value,
             level="success")
         tmpl = self.render_to_string(
             "admin/guide/_step_3_backup_detail.html", **data)
         publish_notice_checker.delay(self.current_user.id)
     else:
         tmpl = self.render_to_string("admin/guide/_step_3_backup.html",
                                      **data)
         self.add_message(
             u"定期备份信息添加失败!(%s)(%s)" %
             (pro_backup_res.return_code, pro_backup_res.return_message),
             level="warning")
     messages_tmpl = self.render_to_string("admin/base/base_messages.html")
     return simplejson.dumps(
         self.success(data={
             "tmpl": tmpl,
             "messages_tmpl": messages_tmpl
         }))
Esempio n. 4
0
 def get(self, **kwargs):
     svc = ApplyBackups(self, {"id": kwargs["id"]})
     pro_backup_res = svc.get_info()
     data = {
         "pro_backup_res": pro_backup_res,
         "pro_table": "pro_backup",
     }
     # logger.info(pro_backup_res.data)
     return self.render_to_string("admin/check/_event_pro_backup_detail.html", **data)
Esempio n. 5
0
 def get(self):
     svc = ApplyBackups(self)
     pro_backup_res = svc.get_info()
     if pro_backup_res.return_code < 0:
         raise SystemError(pro_backup_res.return_code, pro_backup_res.return_message)
     logger.info(pro_backup_res)
     data = {
         "pro_backup_res": pro_backup_res,
     }
     return self.render_to_string("admin/apply/backup/detail.html", **data)
Esempio n. 6
0
 def get(self):
     # pro_id = self.args.get("pro_id")
     # user_id = self.args.get("user_id", 0)
     data = self.get_pro_data()
     if self.kwargs["name"] == "apply.backup.edit":
         svc = ApplyBackups(self)
         # pro_users_res = svc.get_list()
         pro_backup_res = svc.get_info()
         data.update(pro_backup_res=pro_backup_res)
     return self.render_to_string("admin/apply/backup/add.html", **data)
Esempio n. 7
0
 def get(self):
     # pro_id = self.args.get("pro_id")
     # user_id = self.args.get("user_id", 0)
     data = self.get_pro_data()
     if self.kwargs["name"] == "apply.backup.edit":
         svc = ApplyBackups(self)
         # pro_users_res = svc.get_list()
         pro_backup_res = svc.get_info()
         data.update(pro_backup_res=pro_backup_res)
     return self.render_to_string("admin/apply/backup/add.html", **data)
Esempio n. 8
0
 def get(self, **kwargs):
     svc = ApplyBackups(self, {"id": kwargs["id"]})
     pro_backup_res = svc.get_info()
     data = {
         "pro_backup_res": pro_backup_res,
         "pro_table": "pro_backup",
     }
     # logger.info(pro_backup_res.data)
     return self.render_to_string(
         "admin/check/_event_pro_backup_detail.html", **data)
Esempio n. 9
0
 def get(self):
     svc = ApplyBackups(self)
     pro_backup_res = svc.get_info()
     if pro_backup_res.return_code < 0:
         raise SystemError(pro_backup_res.return_code,
                           pro_backup_res.return_message)
     logger.info(pro_backup_res)
     data = {
         "pro_backup_res": pro_backup_res,
     }
     return self.render_to_string("admin/apply/backup/detail.html", **data)
Esempio n. 10
0
 def post(self):
     svc = ApplyBackups(self)
     backups_res = svc.do_backups()
     if backups_res.return_code == 0:
         self.add_message(u"定期备份申请成功!%s" % STATUS_PRO_TABLES.get(backups_res.data.status).todo_value, level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message(u"定期备份申请失败!(%s)(%s)" % (backups_res.return_code, backups_res.return_message), level="warning")
     pro_id = self.args.get("pro_id")
     svc = ApplyLoadBalance(self)
     loadbalance_res = svc.get_loadbalance()
     data = self.get_pro_data(pro_id=pro_id)
     data.update(backups_res=backups_res, loadbalance_res=loadbalance_res)
     logger.info(backups_res)
     tmpl = self.render_to_string("admin/apply/service/add_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))
Esempio n. 11
0
 def post(self):
     id_list = self.get_arguments("id")
     svc = ApplyBackups(self, {"id_list": id_list})
     del_res = svc.do_del_pro_backup()
     logger.info(del_res)
     if del_res.return_code == 0:
         self.add_message(u"定期备份信息删除成功!", level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message(u"定期备份信息删除失败!(%s)(%s)" % (del_res.return_code, del_res.return_message), level="warning")
     data = self.get_pro_data()
     svc = ApplyBackups(self, {"user_id": self.current_user.id})
     pro_backups_res = svc.get_list()
     page = self.getPage(pro_backups_res.data)
     data.update(page=page)
     tmpl = self.render_to_string("admin/apply/backup/index_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))
Esempio n. 12
0
 def post(self):
     svc = ApplyBackups(self)
     pro_backup_res = svc.do_backups()
     pro_id = self.args.get("pro_id")
     data = self.get_pro_data(pro_id=pro_id)
     # svc = ApplyLoadBalance(self)
     # loadbalance_res = svc.get_loadbalance()
     # svc = ApplyBackups(self)
     # backups_res = svc.get_backups()
     data.update(pro_backup_res=pro_backup_res) # , loadbalance_res=loadbalance_res, backups_res=backups_res)
     logger.info(pro_backup_res)
     if pro_backup_res.return_code == 0:
         self.add_message(u"定期备份信息添加成功!%s" % STATUS_PRO_TABLES.get(pro_backup_res.data.status).todo_value, level="success")
         tmpl = self.render_to_string("admin/guide/_step_3_backup_detail.html", **data)
         publish_notice_checker.delay(self.current_user.id)
     else:
         tmpl = self.render_to_string("admin/guide/_step_3_backup.html", **data)
         self.add_message(u"定期备份信息添加失败!(%s)(%s)" % (pro_backup_res.return_code, pro_backup_res.return_message), level="warning")
     messages_tmpl = self.render_to_string("admin/base/base_messages.html")
     return simplejson.dumps(self.success(data={"tmpl": tmpl, "messages_tmpl": messages_tmpl}))
Esempio n. 13
0
 def get(self):
     pro_id = self.args.get("pro_id")
     data = self.get_pro_data(pro_id=pro_id)
     svc = ApplyPublish(self)
     publish_res = svc.get_publish()
     svc = ApplyLoadBalance(self)
     pro_loadbalance_res = svc.get_loadbalance()
     svc = ApplyBackups(self)
     backups_res = svc.get_backups()
     data.update(publish_res=publish_res,
                 pro_loadbalance_res=pro_loadbalance_res,
                 backups_res=backups_res)
     backups = backups_res.data
     logger.info(backups)
     # if backups:
     #     logger.info(backups.plot)
     # else:
     #     logger.info("[]")
     # pro_info_res = data["pro_info_res"]
     # applies = pro_info_res.data.pro_resource_applies
     # logger.info(len(applies))
     # last_apply = applies[-1]
     # logger.info(last_apply.as_dict())
     return self.render_to_string("admin/apply/service/add.html", **data)
Esempio n. 14
0
 def post(self):
     id_list = self.get_arguments("id")
     svc = ApplyBackups(self, {"id_list": id_list})
     del_res = svc.do_del_pro_backup()
     logger.info(del_res)
     if del_res.return_code == 0:
         self.add_message(u"定期备份信息删除成功!", level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message(u"定期备份信息删除失败!(%s)(%s)" %
                          (del_res.return_code, del_res.return_message),
                          level="warning")
     data = self.get_pro_data()
     svc = ApplyBackups(self, {"user_id": self.current_user.id})
     pro_backups_res = svc.get_list()
     page = self.getPage(pro_backups_res.data)
     data.update(page=page)
     tmpl = self.render_to_string("admin/apply/backup/index_pjax.html",
                                  **data)
     return simplejson.dumps(self.success(data=tmpl))
Esempio n. 15
0
    def publish_tasks(self,
                      user_id,
                      pro_id=None,
                      action="on_task",
                      do_publish=True):
        logger.info("------[publish_tasks]------")

        user_svc = PtUserService(self, {"user_id": user_id, "pro_id": pro_id})
        pt_user_res = user_svc.get_info()
        logger.info(pt_user_res)
        current_perms = pt_user_res.data.get_current_perms()
        imchecker = pt_user_res.data.imchecker
        # if "pro_resource_apply.check" in pt_user_res.data.get_current_perms():
        #     imchecker = True
        # else:
        #     imchecker = False
        # 获取任务列表
        svc = ActHistoryService(self, {"user_id": user_id, "pro_id": pro_id})
        tasks_res = svc.get_res_tasks()
        data = {
            "tasks_res": tasks_res,
            "task_list": tasks_res.data,
            "imchecker": imchecker,
            "current_perms": current_perms,
            "STATUS_RESOURCE": STATUS_RESOURCE
        }

        # 获取用户申请列表
        svc = ProUserService(self, {"user_id": user_id, "pro_id": pro_id})
        pro_user_list_res = svc.get_list()
        if imchecker:
            pro_user_list = [
                i for i in pro_user_list_res.data
                if i.status == STATUS_PRO_TABLES.APPLIED
            ]
        else:
            pro_user_list = [
                i for i in pro_user_list_res.data if i.status in
                [STATUS_PRO_TABLES.REFUSED, STATUS_PRO_TABLES.CHECKED]
            ]
        data.update({
            "pro_user_list": pro_user_list,
            "imchecker": imchecker,
            "STATUS_PRO_TABLES": STATUS_PRO_TABLES
        })
        # logger.info(pro_user_list)

        # 获取互联网发布申请列表
        svc = ApplyPublish(self, {"user_id": user_id, "pro_id": pro_id})
        pro_publish_list_res = svc.get_list()
        # logger.info(pro_publish_list_res.data)
        if imchecker:
            pro_publish_list = [
                i for i in pro_publish_list_res.data
                if i.status == STATUS_PRO_TABLES.APPLIED
            ]
        else:
            pro_publish_list = [
                i for i in pro_publish_list_res.data if i.status in
                [STATUS_PRO_TABLES.REFUSED, STATUS_PRO_TABLES.CHECKED]
            ]
        data.update({
            "pro_publish_list": pro_publish_list,
            "imchecker": imchecker,
            "STATUS_PRO_TABLES": STATUS_PRO_TABLES
        })

        # 获取负载均衡申请列表
        svc = ApplyLoadBalance(self, {"user_id": user_id, "pro_id": pro_id})
        pro_balance_list_res = svc.get_list()
        # logger.info(pro_balance_list_res.data)
        if imchecker:
            pro_balance_list = [
                i for i in pro_balance_list_res.data
                if i.status == STATUS_PRO_TABLES.APPLIED
            ]
        else:
            pro_balance_list = [
                i for i in pro_balance_list_res.data if i.status in
                [STATUS_PRO_TABLES.REFUSED, STATUS_PRO_TABLES.CHECKED]
            ]
        data.update({
            "pro_balance_list": pro_balance_list,
            "imchecker": imchecker,
            "STATUS_PRO_TABLES": STATUS_PRO_TABLES
        })

        # 获取定期备份申请列表
        svc = ApplyBackups(self, {"user_id": user_id, "pro_id": pro_id})
        pro_backup_list_res = svc.get_list()
        # logger.info(pro_backup_list_res.data)
        if imchecker:
            pro_backup_list = [
                i for i in pro_backup_list_res.data
                if i.status == STATUS_PRO_TABLES.APPLIED
            ]
        else:
            pro_backup_list = [
                i for i in pro_backup_list_res.data if i.status in
                [STATUS_PRO_TABLES.REFUSED, STATUS_PRO_TABLES.CHECKED]
            ]
        data.update({
            "pro_backup_list": pro_backup_list,
            "imchecker": imchecker,
            "STATUS_PRO_TABLES": STATUS_PRO_TABLES
        })

        # 获取定期备份申请列表
        svc = EventService(self, {"user_id": user_id, "pro_id": pro_id})
        pro_event_list_res = svc.get_list()
        # logger.info(pro_event_list_res.data)
        if imchecker:
            pro_event_list = [
                i for i in pro_event_list_res.data
                if i.status == STATUS_PRO_TABLES.APPLIED
            ]
        else:
            pro_event_list = [
                i for i in pro_event_list_res.data if i.status in
                [STATUS_PRO_TABLES.REFUSED, STATUS_PRO_TABLES.CHECKED]
            ]
        data.update({
            "pro_event_list": pro_event_list,
            "imchecker": imchecker,
            "STATUS_PRO_TABLES": STATUS_PRO_TABLES
        })

        # 获取任务列表总和
        pro_tables_total = len(pro_user_list) + len(pro_publish_list) + len(
            pro_balance_list) + len(pro_backup_list) + len(pro_event_list)
        logger.info("len(pro_user_list): %s" % len(pro_user_list))
        logger.info("len(pro_publish_list): %s" % len(pro_publish_list))
        logger.info("len(pro_balance_list): %s" % len(pro_balance_list))
        logger.info("len(pro_backup_list): %s" % len(pro_backup_list))
        logger.info("len(pro_event_list): %s" % len(pro_event_list))
        data["pro_tables_total"] = pro_tables_total
        data["tasks_total"] = len(tasks_res.data)
        logger.info("total: %s" % pro_tables_total)
        logger.info("tasks_total: %s" % len(tasks_res.data))
        if do_publish:
            self.do_publish(user_id, action, **data)
        return self.success(data=data)