示例#1
0
 def get(self):
     data = self.get_pro_data()
     svc = ApplyPublish(self, {"user_id": self.current_user.id})
     pro_publishs_res = svc.get_list()
     page = self.getPage(pro_publishs_res.data)
     data.update(page=page)
     return self.render_to_string("admin/apply/publish/index.html", **data)
示例#2
0
 def get(self):
     data = self.get_pro_data()
     svc = ApplyPublish(self, {"user_id": self.current_user.id})
     pro_publishs_res = svc.get_list()
     page = self.getPage(pro_publishs_res.data)
     data.update(page=page)
     return self.render_to_string("admin/apply/publish/index.html", **data)
示例#3
0
 def get(self, **kwargs):
     svc = ApplyPublish(self, {"id": kwargs["id"]})
     pro_publish_res = svc.get_publish()
     data = {
         "pro_publish_res": pro_publish_res,
         "pro_table": "pro_publish",
     }
     # logger.info(pro_publish_res.data)
     return self.render_to_string("admin/check/_event_pro_publish_detail.html", **data)
示例#4
0
 def get(self):
     svc = ApplyPublish(self)
     pro_publish_res = svc.get_publish()
     if pro_publish_res.return_code < 0:
         raise SystemError(pro_publish_res.return_code, pro_publish_res.return_message)
     logger.info(pro_publish_res)
     data = {
         "pro_publish_res": pro_publish_res,
     }
     return self.render_to_string("admin/apply/publish/detail.html", **data)
示例#5
0
 def get(self, **kwargs):
     svc = ApplyPublish(self, {"id": kwargs["id"]})
     pro_publish_res = svc.get_publish()
     data = {
         "pro_publish_res": pro_publish_res,
         "pro_table": "pro_publish",
     }
     # logger.info(pro_publish_res.data)
     return self.render_to_string(
         "admin/check/_event_pro_publish_detail.html", **data)
示例#6
0
 def get(self):
     svc = ApplyPublish(self)
     pro_publish_res = svc.get_publish()
     if pro_publish_res.return_code < 0:
         raise SystemError(pro_publish_res.return_code,
                           pro_publish_res.return_message)
     logger.info(pro_publish_res)
     data = {
         "pro_publish_res": pro_publish_res,
     }
     return self.render_to_string("admin/apply/publish/detail.html", **data)
示例#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()
     action_url = self.reverse_url(self.kwargs["name"])
     data.update(action_url=action_url)
     if self.kwargs["name"] == "apply.publish.edit":
         svc = ApplyPublish(self)
         # pro_users_res = svc.get_list()
         pro_publish_res = svc.get_publish()
         data.update(pro_publish_res=pro_publish_res)
     return self.render_to_string("admin/apply/publish/add.html", **data)
示例#8
0
 def get(self):
     # pro_id = self.args.get("pro_id")
     # user_id = self.args.get("user_id", 0)
     data = self.get_pro_data()
     action_url = self.reverse_url(self.kwargs["name"])
     data.update(action_url=action_url)
     if self.kwargs["name"] == "apply.publish.edit":
         svc = ApplyPublish(self)
         # pro_users_res = svc.get_list()
         pro_publish_res = svc.get_publish()
         data.update(pro_publish_res=pro_publish_res)
     return self.render_to_string("admin/apply/publish/add.html", **data)
示例#9
0
 def post(self):
     id_list = self.get_arguments("id")
     svc = ApplyPublish(self, {"id_list": id_list})
     del_res = svc.do_del_pro_publish()
     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 = ApplyPublish(self, {"user_id": self.current_user.id})
     pro_publishs_res = svc.get_list()
     page = self.getPage(pro_publishs_res.data)
     data.update(page=page)
     tmpl = self.render_to_string("admin/apply/publish/index_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))
示例#10
0
 def post(self):
     svc = ApplyPublish(self)
     pro_publish_res = svc.do_publish()
     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_publish_res=pro_publish_res) # , loadbalance_res=loadbalance_res, backups_res=backups_res)
     logger.info(pro_publish_res)
     if pro_publish_res.return_code == 0:
         self.add_message(u"互联网发布信息添加成功!%s" % STATUS_PRO_TABLES.get(pro_publish_res.data.status).todo_value, level="success")
         tmpl = self.render_to_string("admin/guide/_step_3_publish_detail.html", **data)
         publish_notice_checker.delay(self.current_user.id)
     else:
         tmpl = self.render_to_string("admin/guide/_step_3_publish.html", **data)
         self.add_message(u"互联网发布信息添加失败!(%s)(%s)" % (pro_publish_res.return_code, pro_publish_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}))
示例#11
0
 def post(self):
     svc = ApplyPublish(self)
     pro_publish_res = svc.do_publish()
     logger.info(pro_publish_res)
     if pro_publish_res.return_code == 0:
         pro_id = self.args.get("pro_id")
         data = self.get_pro_data(pro_id=pro_id)
         data.update(pro_publish_res=pro_publish_res)
         self.add_message(u"互联网发布信息添加成功!%s" % STATUS_PRO_TABLES.get(pro_publish_res.data.status).todo_value, level="success")
         tmpl = self.render_to_string("admin/guide/_step_3_publish_detail.html", **data)
         publish_notice_checker.delay(self.current_user.id)
         mail_title = u"%s申请的互联网信息添加成功!待受理" % (
             self.current_user.username or self.current_user.email,
         )
         mail_html = self.render_to_string("admin/mail/pro_publish.html", mail_title=mail_title, **data)
         sendMail.delay("*****@*****.**", admin_emails, mail_title, mail_html)
     else:
         data = self.get_pro_data()
         data.update(pro_publish_res=pro_publish_res)
         tmpl = self.render_to_string("admin/guide/_step_3_publish.html", **data)
         self.add_message(u"互联网发布信息添加失败!(%s)(%s)" % (pro_publish_res.return_code, pro_publish_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}))
示例#12
0
 def post(self):
     svc = ApplyPublish(self)
     pro_publish_res = svc.do_publish()
     logger.info(pro_publish_res)
     if pro_publish_res.return_code == 0:
         pro_id = self.args.get("pro_id")
         data = self.get_pro_data(pro_id=pro_id)
         data.update(pro_publish_res=pro_publish_res)
         self.add_message(
             u"互联网发布信息添加成功!%s" %
             STATUS_PRO_TABLES.get(pro_publish_res.data.status).todo_value,
             level="success")
         tmpl = self.render_to_string(
             "admin/guide/_step_3_publish_detail.html", **data)
         publish_notice_checker.delay(self.current_user.id)
         mail_title = u"%s申请的互联网信息添加成功!待受理" % (self.current_user.username
                                               or self.current_user.email, )
         mail_html = self.render_to_string("admin/mail/pro_publish.html",
                                           mail_title=mail_title,
                                           **data)
         sendMail.delay("*****@*****.**", admin_emails, mail_title,
                        mail_html)
     else:
         data = self.get_pro_data()
         data.update(pro_publish_res=pro_publish_res)
         tmpl = self.render_to_string("admin/guide/_step_3_publish.html",
                                      **data)
         self.add_message(
             u"互联网发布信息添加失败!(%s)(%s)" %
             (pro_publish_res.return_code, pro_publish_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
         }))
示例#13
0
 def post(self):
     id_list = self.get_arguments("id")
     svc = ApplyPublish(self, {"id_list": id_list})
     del_res = svc.do_del_pro_publish()
     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 = ApplyPublish(self, {"user_id": self.current_user.id})
     pro_publishs_res = svc.get_list()
     page = self.getPage(pro_publishs_res.data)
     data.update(page=page)
     tmpl = self.render_to_string("admin/apply/publish/index_pjax.html",
                                  **data)
     return simplejson.dumps(self.success(data=tmpl))
示例#14
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)
示例#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)