Beispiel #1
0
 def get_bind_service_account_list(self, page_settings, user_sn=0):
     self.__reset_return_value()
     html = ""
     page_settings["user_sn"] = user_sn
     page_settings["bind_service_tab"] = 12
     if int(user_sn) > 0:
         vcms_db_agent = VcmsDbAgent()
         user_info = vcms_db_agent._get_account_data(int(user_sn))
         page_settings["company_sn"] = int(user_info["company_sn"])
         company_service_info = vcms_db_agent._get_company_service_data(
             int(user_info["company_sn"]))
         user_service_info = vcms_db_agent._get_user_service_data(
             int(user_sn))
         enabled_service = {}
         for k1, v1 in user_service_info.items():
             if int(v1["enabled"]) == 1:
                 enabled_service[int(v1["company_service_sn"])] = v1
         for k1, v1 in company_service_info.items():
             if k1 in enabled_service:
                 company_service_info[k1]["user_enabled"] = 1
             else:
                 company_service_info[k1]["user_enabled"] = 0
         page_settings["company_service_list"] = company_service_info
         html = render_template("tab_ui/vcms_bind_service_account.tpl",
                                data=page_settings)
     return html
Beispiel #2
0
 def change_account_pwd(self, page_settings, parameter_dict):
     self.__reset_return_value()
     data_check = {
         "user_sn_error": page_settings["empty_cnt_error"],
         "npwd_error": page_settings["empty_cnt_error"],
         "cpwd_error": page_settings["empty_cnt_error"]
     }
     user_sn = parameter_dict.get("user_sn")
     new_password = parameter_dict.get("new_password")
     confirm_password = parameter_dict.get("confirm_password")
     vcms_db_agent = VcmsDbAgent()
     error_data = 0
     company_sn = 0
     if user_sn is not None and user_sn != "":
         data_check["user_sn_error"] = ""
         if re.compile("^[\d]*$").match(user_sn) is None:
             error_data += 1
             data_check["user_sn_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["user_sn_error"] = page_settings[
                     "none_user_sn_error"]
             else:
                 company_sn = int(user_info["company_sn"])
     else:
         error_data += 1
     if new_password is not None and new_password != "":
         data_check["npwd_error"] = ""
     else:
         error_data += 1
     if confirm_password is not None and confirm_password != "":
         data_check["npwd_error"] = ""
         if confirm_password != new_password:
             error_data += 1
             data_check["cpwd_error"] = page_settings["confirm_pwd_error"]
     else:
         error_data += 1
     self.return_value["data"] = data_check
     if error_data == 0:
         hash2 = hashlib.md5()
         hash2.update(new_password.encode('utf-8'))
         pwd = str(hash2.hexdigest())
         if vcms_db_agent._upd_account_pwd(user_sn, pwd) == 1:
             self.return_value["data"] = self.get_company_account_list(
                 page_settings, company_sn)
             self.return_value["message"] = page_settings["success_text"]
             self.return_value["code"] = 1
     return self.return_value
Beispiel #3
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