Пример #1
0
 def get(self):
     data = self.get_pro_data(pro_id=self.args.get("pro_id"))
     svc = ProResourceApplyService(self)
     pro_resource_apply_res = svc.get_resource()
     data.update(dict(pro_resource_apply_res=pro_resource_apply_res))
     return self.render_to_string("admin/apply/resource/pay_history.html",
                                  **data)
Пример #2
0
 def get(self):
     if self.kwargs["name"] == "apply.resource.add":
         data = self.get_pro_data()
         return self.render_to_string("admin/apply/resource/add.html",
                                      **data)
     else:
         data = self.get_pro_data()
         svc = ProResourceApplyService(self)
         pro_resource_apply_res = svc.get_resource()
         if self.kwargs["name"] == "apply.resource.pay":
             data.update(
                 dict(pro_resource_apply_res=pro_resource_apply_res))
             return self.render_to_string("admin/apply/resource/pay.html",
                                          **data)
         svc = ProjectService(self)
         env_resource_value_res = svc.load_env_resource_values()
         env_internet_ip_types_res = svc.load_env_internet_ip_types()
         data.update(
             dict(
                 pro_resource_apply_res=pro_resource_apply_res,
                 env_internet_ip_types_res=env_internet_ip_types_res,
                 env_resource_value_res=env_resource_value_res,
             ))
         return self.render_to_string("admin/apply/resource/edit.html",
                                      **data)
Пример #3
0
 def get(self, **kwargs):
     svc = ProResourceApplyService(self, kwargs)
     resource_res = svc.get_resource()
     if isinstance(resource_res, Exception):
         raise resource_res
     data = self.get_pro_info_res(kwargs["pro_id"])
     return self.render_to_string("admin/guide/step1.html", **data)
Пример #4
0
    def post(self, **kwargs):
        data = self.get_pro_data()
        svc = ProResourceApplyService(self, self.args)
        pro_resource_apply_res = svc.get_resource()
        logger.info("[pro_resource_apply_res] %s" % pro_resource_apply_res)
        fee_res = svc.generate_fee()
        svc = ProjectService(self)
        env_resource_value_res = svc.load_env_resource_values()
        env_internet_ip_types_res = svc.load_env_internet_ip_types()
        data.update(dict(
            fee_res = fee_res,
            pro_resource_apply_res = pro_resource_apply_res,
            env_internet_ip_types_res = env_internet_ip_types_res,
            env_resource_value_res = env_resource_value_res,
        ))
        logger.info(fee_res)
        if fee_res.return_code == 0:
            self.add_message(u"费用计算成功!单月费用 %s(元/月)×有效期 %s(月)=总费用 %s(元)" % (fee_res.data["unit_fee"], self.args.get('period'), fee_res.data["total_fee"]), level="success")
        else:

            if fee_res.return_code == ERROR.database_save_err.errcode:
                return_messages = fee_res.return_messages
                self.add_message(u"费用计算失败!", level="warning")
                for msg in return_messages:
                    self.add_message(u"%s" % msg, level="warning")
            else:
                self.add_message(u"费用计算失败! %s(%s)" % (fee_res.return_code, fee_res.return_message), level="warning")

        messages_tmpl = self.render_to_string("admin/base/base_messages.html")
        tmpl = self.render_to_string("admin/guide/_step_1_res_fee_form.html", **data)
        # tmpl = self.render_to_string("admin/apply/resource/add_pjax.html", **data)
        return simplejson.dumps(self.success(data={"tmpl": tmpl, "messages_tmpl": messages_tmpl}))
Пример #5
0
 def get(self):
     svc = ProResourceApplyService(self)
     pro_resource_apply_res = svc.get_resource()
     if pro_resource_apply_res.return_code < 0:
         raise SystemError(pro_resource_apply_res.return_code, pro_resource_apply_res.return_message)
     logger.info(pro_resource_apply_res)
     data = {
         "pro_resource_apply_res": pro_resource_apply_res,
     }
     return self.render_to_string("admin/apply/resource/detail.html", **data)
Пример #6
0
 def do_mail(self):
     kw = {"res_id": 10}
     svc = ProResourceApplyService(self, kw)
     resource_res = svc.get_resource()
     data = {
         "resource_apply": resource_res.data,
         "STATUS_RESOURCE": STATUS_RESOURCE,
         "getattr": getattr
     }
     return self.render_to_string("admin/mail/pro_resource_apply_to_admin.html", **data)
Пример #7
0
 def get(self):
     svc = ProResourceApplyService(self)
     pro_resource_apply_res = svc.get_resource()
     if pro_resource_apply_res.return_code < 0:
         raise SystemError(pro_resource_apply_res.return_code,
                           pro_resource_apply_res.return_message)
     logger.info(pro_resource_apply_res)
     data = {
         "pro_resource_apply_res": pro_resource_apply_res,
     }
     return self.render_to_string("admin/apply/resource/detail.html",
                                  **data)
Пример #8
0
 def get(self, **kwargs):
     kw = {}
     kw.update(self.args)
     kw.update(kwargs)
     svc = ProResourceApplyService(self, kw)
     resource_res = svc.get_resource()
     if isinstance(resource_res, Exception):
         raise resource_res
     data = {
         "resource_res": resource_res,
     }
     return self.render_to_string("admin/pro_resource/index.html", **data)
Пример #9
0
 def delete(self, **kwargs):
     svc = ProResourceApplyService(self, kwargs)
     delete_res = svc.do_delete()
     resource_res = svc.get_resource()
     if isinstance(delete_res, Exception):
         raise resource_res
     data = self.get_pro_info_res(kwargs["pro_id"])
     self.add_message("云资源[%s-%s]申请删除成功!"% (delete_res.data.project.name, delete_res.data.desc), level="success")
     # logger.info("\t [data]: %s" % data )
     # logger.info("\t [data pro_info_res]: %s" % data["pro_info_res"])
     tmpl = self.render_to_string("admin/guide/step1_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))
Пример #10
0
 def post(self, **kwargs):
     svc = ProResourceApplyService(self, kwargs)
     start_res = svc.set_start()
     resource_res = svc.get_resource()
     if isinstance(resource_res, Exception):
         raise resource_res
     data = self.get_pro_info_res(kwargs["pro_id"])
     data.update(dict(last_apply=data["pro_info_res"].data.last_apply))
     self.add_message("云资源[%s-%s]环境启用时间设置成功!" % (start_res.data.project.name, start_res.data.desc), level="success", post_action=True)
     # logger.info("\t [data]: %s" % data )
     # logger.info("\t [data pro_info_res]: %s" % data["pro_info_res"])
     tmpl = self.render_to_string("admin/guide/_step_3_start_date.html", **data)
     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, **kwargs):
        data = self.get_pro_data()
        svc = ProResourceApplyService(self, self.args)
        pro_resource_apply_res = svc.get_resource()
        logger.info("[pro_resource_apply_res] %s" % pro_resource_apply_res)
        fee_res = svc.generate_fee()
        svc = ProjectService(self)
        env_resource_value_res = svc.load_env_resource_values()
        env_internet_ip_types_res = svc.load_env_internet_ip_types()
        data.update(
            dict(
                fee_res=fee_res,
                pro_resource_apply_res=pro_resource_apply_res,
                env_internet_ip_types_res=env_internet_ip_types_res,
                env_resource_value_res=env_resource_value_res,
            ))
        logger.info(fee_res)
        if fee_res.return_code == 0:
            self.add_message(
                u"费用计算成功!单月费用 %s(元/月)×有效期 %s(月)=总费用 %s(元)" %
                (fee_res.data["unit_fee"], self.args.get('period'),
                 fee_res.data["total_fee"]),
                level="success")
        else:

            if fee_res.return_code == ERROR.database_save_err.errcode:
                return_messages = fee_res.return_messages
                self.add_message(u"费用计算失败!", level="warning")
                for msg in return_messages:
                    self.add_message(u"%s" % msg, level="warning")
            else:
                self.add_message(u"费用计算失败! %s(%s)" %
                                 (fee_res.return_code, fee_res.return_message),
                                 level="warning")

        messages_tmpl = self.render_to_string("admin/base/base_messages.html")
        tmpl = self.render_to_string("admin/guide/_step_1_res_fee_form.html",
                                     **data)
        # tmpl = self.render_to_string("admin/apply/resource/add_pjax.html", **data)
        return simplejson.dumps(
            self.success(data={
                "tmpl": tmpl,
                "messages_tmpl": messages_tmpl
            }))
Пример #12
0
 def get(self):
     if self.kwargs["name"] == "apply.resource.add":
         data = self.get_pro_data()
         return self.render_to_string("admin/apply/resource/add.html", **data)
     else:
         data = self.get_pro_data()
         svc = ProResourceApplyService(self)
         pro_resource_apply_res = svc.get_resource()
         if self.kwargs["name"] == "apply.resource.pay":
             data.update(dict(pro_resource_apply_res=pro_resource_apply_res))
             return self.render_to_string("admin/apply/resource/pay.html", **data)
         svc = ProjectService(self)
         env_resource_value_res = svc.load_env_resource_values()
         env_internet_ip_types_res = svc.load_env_internet_ip_types()
         data.update(dict(
             pro_resource_apply_res = pro_resource_apply_res,
             env_internet_ip_types_res = env_internet_ip_types_res,
             env_resource_value_res = env_resource_value_res,
         ))
         return self.render_to_string("admin/apply/resource/edit.html", **data)
Пример #13
0
 def do_notice_user(self, json_message):
     svc = ProResourceApplyService(self, {"res_id": json_message["res_id"]})
     resource_res = svc.get_resource()
     user_id = resource_res.data.user_id
     svc = ActHistoryService(self, {"user_id": user_id})
     tasks_res = svc.get_res_tasks()
     logger.info(resource_res.data.user_id)
     logger.info(resource_res.data.checker_id)
     data = {
         "tasks_res": tasks_res,
         "imchecker": False,
         "STATUS_RESOURCE": STATUS_RESOURCE
     }
     chat = {
         "user_id": user_id,
         "data": resource_res.data.as_dict(),
         "html": self.render_to_string("admin/notice/tasks.html", **data)
     }
     logger.error(chat)
     chat.update(json_message)
     EchoWebSocket.send_message(chat)
Пример #14
0
 def get(self, **kwargs):
     data = self.get_pro_info_res(kwargs["pro_id"])
     pro_info_res = data["pro_info_res"]
     if pro_info_res.return_code == 0:
         pro_info = pro_info_res["data"]
         res_apply_id = pro_info.last_apply.id if pro_info.last_apply else 0
     else:
         res_apply_id = 0
     kwargs["res_apply_id"] = res_apply_id
     svc = ProResourceApplyService(self, kwargs)
     pro_resource_apply_res = svc.get_resource()
     logger.info("[pro_resource_apply_res] %s" % pro_resource_apply_res)
     svc = ProjectService(self)
     env_resource_value_res = svc.load_env_resource_values()
     env_internet_ip_types_res = svc.load_env_internet_ip_types()
     data.update(dict(
         pro_resource_apply_res = pro_resource_apply_res,
         env_internet_ip_types_res = env_internet_ip_types_res,
         env_resource_value_res = env_resource_value_res,
     ))
     return self.render_to_string("admin/guide/step1.html", **data)
Пример #15
0
 def do_notice_user(self, json_message):
     svc = ProResourceApplyService(self, {"res_id": json_message["res_id"]})
     resource_res = svc.get_resource()
     user_id = resource_res.data.user_id
     svc = ActHistoryService(self, {"user_id": user_id})
     tasks_res = svc.get_res_tasks()
     logger.info(resource_res.data.user_id)
     logger.info(resource_res.data.checker_id)
     data = {
         "tasks_res": tasks_res,
         "imchecker": False,
         "STATUS_RESOURCE": STATUS_RESOURCE
     }
     chat = {
         "user_id": user_id,
         "data": resource_res.data.as_dict(),
         "html": self.render_to_string("admin/notice/tasks.html", **data)
     }
     logger.error(chat)
     chat.update(json_message)
     EchoWebSocket.send_message(chat)
Пример #16
0
 def get(self):
     data = self.get_pro_data(pro_id=self.args.get("pro_id"))
     svc = ProResourceApplyService(self)
     pro_resource_apply_res = svc.get_resource()
     data.update(dict(pro_resource_apply_res=pro_resource_apply_res))
     return self.render_to_string("admin/apply/resource/pay_history.html", **data)