Ejemplo n.º 1
0
 def get_edit_company_service(self, page_settings, company_sn=0):
     self.__reset_return_value()
     html = ""
     if company_sn > 0:
         vcms_db_agent = VcmsDbAgent()
         page_settings["company_sn"] = company_sn
         system_service = vcms_db_agent._get_system_service_data()
         company_service = vcms_db_agent._get_company_service_data(
             company_sn)
         service = {}
         for k, v in company_service.items():
             service[int(v["service_sn"])] = int(v["service_sn"])
         return_data = collections.OrderedDict()
         for k, v in system_service.items():
             if k not in service:
                 return_data[k] = v
         page_settings["per_product_image_cnt_list"] = reversed(
             range(
                 1,
                 (int(page_settings["per_product_image_cnt_setting"]) + 1)))
         page_settings["service_list"] = return_data
         page_settings[
             "company_name"] = vcms_db_agent._get_all_company_data(
             )[company_sn]["company_name"]
         html = render_template("tab_ui/vcms_edit_company_service.tpl",
                                data=page_settings)
     return html
Ejemplo n.º 2
0
 def get_edit_company_license_request(self, page_settings, company_sn=0):
     self.__reset_return_value()
     html = ""
     page_settings["company_license_request_tab"] = 13
     page_settings["add_company_license_request"] = 14
     if company_sn > 0:
         vcms_db_agent = VcmsDbAgent()
         vcms_license_db_agent = VcmsLicenseDbAgent()
         page_settings["company_sn"] = company_sn
         system_service = vcms_db_agent._get_system_service_data()
         company_service = vcms_db_agent._get_company_service_data(
             company_sn)
         license_encrypt_types = vcms_license_db_agent._get_all_license_encrypt_type_data(
         )
         license_trial_types = vcms_license_db_agent._get_all_license_trial_type_data(
         )
         license_id_types = vcms_license_db_agent._get_all_license_id_type_data(
         )
         # company bind service list
         service = {}
         for k, v in company_service.items():
             service[int(v["service_sn"])] = int(v["service_sn"])
         return_data = collections.OrderedDict()
         for k, v in system_service.items():
             if k in service:
                 return_data[k] = v
         page_settings["service_list"] = return_data
         # all license encrypt types
         license_encrypt_list = {}
         for k, v in license_encrypt_types.items():
             license_encrypt_list[str(v["sn"])] = v
         page_settings["license_encrypt_list"] = license_encrypt_list
         # all license trial types
         license_trial_list = {}
         for k, v in license_trial_types.items():
             license_trial_list[str(v["sn"])] = v
         page_settings["license_trial_list"] = license_trial_list
         # all license id types
         license_id_type_list = {}
         for k, v in license_id_types.items():
             license_id_type_list[str(v["sn"])] = v
         page_settings["license_id_type_list"] = license_id_type_list
         # set default start date , expire date
         _today = datetime.datetime.today().strftime("%Y-%m-%d")
         page_settings["version"] = "1.0.0"
         page_settings["start_date"] = _today
         page_settings["expire_date"] = _today
         page_settings["batch_license_count"] = 0
         page_settings[
             "company_name"] = vcms_db_agent._get_all_company_data(
             )[company_sn]["company_name"]
         html = render_template(
             "tab_ui/vcms_edit_company_license_request.tpl",
             data=page_settings)
     return html
Ejemplo n.º 3
0
 def get_edit_company_account(self, page_settings, company_sn=0):
     self.__reset_return_value()
     html = ""
     page_settings["company_account_tab"] = 7
     if company_sn > 0:
         return_data = collections.OrderedDict()
         vcms_db_agent = VcmsDbAgent()
         user_rank_list = vcms_db_agent._get_all_system_user_ranks()
         for k, v in user_rank_list.items():
             if int(k) == 3:
                 return_data[k] = v
         page_settings["company_sn"] = company_sn
         page_settings[
             "company_name"] = vcms_db_agent._get_all_company_data(
             )[company_sn]["company_name"]
         page_settings["user_rank_list"] = return_data
         html = render_template("tab_ui/vcms_edit_company_account.tpl",
                                data=page_settings)
     return html
Ejemplo n.º 4
0
 def set_bind_service_account(self, page_settings, parameter_dict):
     self.__reset_return_value()
     data_check = {"service_sn_1_error": page_settings["empty_cnt_error"]}
     company_sn = parameter_dict.get("company_sn")
     user_sn = parameter_dict.get("user_sn")
     error_data = 0
     vcms_db_agent = VcmsDbAgent()
     if company_sn is not None and company_sn != "":
         data_check["service_sn_1_error"] = ""
         if re.compile("^[0-9]*$").match(company_sn) is None:
             error_data += 1
             data_check["service_sn_1_error"] = page_settings[
                 "invalid_company_sn_error"]
         else:
             company_info = vcms_db_agent._get_all_company_data()
             if int(company_sn) not in company_info:
                 error_data += 1
                 data_check["service_sn_1_error"] = page_settings[
                     "empty_company_sn_error"]
     else:
         error_data += 1
         data_check["service_sn_1_error"] = page_settings[
             "company_sn_error"]
     if user_sn is not None and user_sn != "":
         if re.compile("^[\d]*$").match(user_sn) is None:
             error_data += 1
             data_check["service_sn_1_error"] = page_settings[
                 "user_sn_format_error"]
         else:
             user_info = vcms_db_agent._get_account_data(user_sn)
             if "admin_id" not in user_info:
                 error_data += 1
                 data_check["service_sn_1_error"] = page_settings[
                     "none_user_sn_error"]
             else:
                 company_sn = int(user_info["company_sn"])
     else:
         error_data += 1
     self.return_value["data"] = data_check
     if error_data == 0:
         if "company_service_sn" in parameter_dict:
             company_service_info = vcms_db_agent._get_company_service_data(
                 int(company_sn))
             user_permission = vcms_db_agent._get_user_service_data(
                 int(user_sn))
             user_permission_list = {}
             for k, v in user_permission.items():
                 user_permission_list[int(v["company_service_sn"])] = v
             vcms_db_agent._upd_all_user_service_permission_data(
                 int(user_sn), 0)
             for row in parameter_dict.getlist("company_service_sn"):
                 if int(row) in user_permission_list:
                     vcms_db_agent._upd_user_service_permission_data(
                         int(user_sn), int(row), 1)
                 else:
                     service_sn = company_service_info[int(
                         row)]["service_sn"]
                     vcms_db_agent._add_user_service_permission_data(
                         int(company_sn), int(user_sn), int(row),
                         int(service_sn))
         else:
             vcms_db_agent._upd_all_user_service_permission_data(
                 int(user_sn), 0)
         self.return_value["data"] = self.get_bind_service_account_list(
             page_settings, int(user_sn))
         self.return_value["message"] = page_settings["success_text"]
         self.return_value["code"] = 1
     return self.return_value