Ejemplo n.º 1
0
 def create_new_advertisement(self):
     """ 确认创建新的广告 """
     ad_params = self.get_new_advertisement_params()
     if not all([ad_params["image"], ad_params["title"]]):
         p = InformationPopup("标题和图片不能为空!", self)
         p.exec_()
         return
     self.create_button.setEnabled(False)
     image_file = QFile(ad_params["image"])
     image_file.open(QFile.ReadOnly)
     file_dict = {"image": image_file}
     if ad_params["filepath"]:
         pdf_file = QFile(ad_params["filepath"])
         pdf_file.open(QFile.ReadOnly)
         file_dict["pdf_file"] = pdf_file
     text_dict = ad_params.copy()
     multipart_data = generate_multipart_data(text_dict, file_dict)
     # close后便无法生成multipartData
     # image_file.close()
     # if pdf_file:
     #     pdf_file.close()
     url = SERVER_API + 'advertisement/'
     request = QNetworkRequest(QUrl(url))
     request.setRawHeader("Authorization".encode("utf-8"),
                          get_user_token().encode("utf-8"))
     network_manager = getattr(qApp, "_network")
     reply = network_manager.post(request, multipart_data)
     reply.finished.connect(self.create_advertisement_reply)
     multipart_data.setParent(reply)
Ejemplo n.º 2
0
 def delete_report_reply():
     if reply.error():
         p = InformationPopup("删除失败", self)
     else:
         p = InformationPopup("删除成功", self)
         self.manager_table.removeRow(current_row)
     p.exec_()
     reply.deleteLater()
Ejemplo n.º 3
0
 def change_report_reply():
     if reply.error():
         p = InformationPopup("修改失败", self)
     else:
         p = InformationPopup("修改成功", self)
         text = "否" if self.manager_table.item(current_row,
                                               5).text() == "是" else "是"
         self.manager_table.item(current_row, 5).setText(text)
     p.exec_()
     reply.deleteLater()
Ejemplo n.º 4
0
 def delete_wechat_file_reply():
     """ 删除网络保存的文件返回 """
     if reply.error():
         p = InformationPopup("删除失败!", self)
         p.exec_()
     else:
         p = InformationPopup("删除成功!", self)
         p.exec_()
         self.file_table.removeRow(current_row)
     reply.deleteLater()
Ejemplo n.º 5
0
 def create_report_reply():
     if reply.error():
         message = "创建报告失败!"
     else:
         message = "创建报告成功!"
         self.file_table.removeRow(self.file_table.currentRow())
         self.clear_relative_variety()
     reply.deleteLater()
     p = InformationPopup(message, self)
     p.exec_()
Ejemplo n.º 6
0
 def create_report_reply():
     if reply.error():
         message = "创建报告失败!"
     else:
         message = "创建报告成功!"
         self.local_file_edit.clear()
         self.clear_relative_variety()
     reply.deleteLater()
     p = InformationPopup(message, self)
     p.exec_()
Ejemplo n.º 7
0
 def modify_finished():
     f_reply = self.sender()
     if f_reply.error():
         p_info = InformationPopup("修改失败了!\n只能修改自己发送的短信通", popup)
         p_info.exec_()
     else:
         p_info = InformationPopup("修改成功!", popup)
         p_info.exec_()
         popup.close()
         self.content_label.setText(
             popup.text_edit.toHtml())  # 设置修改后的内容
Ejemplo n.º 8
0
 def modify_advertisement_reply(self):
     """ 修改广告启用返回 """
     reply = self.sender()
     if reply.error():
         p = InformationPopup("修改启用失败", self)
         p.exec_()
     else:
         p = InformationPopup("修改启用成功", self)
         p.exec_()
         self.read_all_advertisements()
     reply.deleteLater()
Ejemplo n.º 9
0
 def delete_message_reply(self):
     """ 删除本条短信通返回 """
     reply = self.sender()
     if reply.error():
         logger.error("删除短信通错误:{}".format(reply.error()))
         p = InformationPopup("删除失败!\n您不能对他人的短信通进行这个操作!", self)
         p.exec_()
     else:
         p = InformationPopup("删除成功!", self)
         p.exec_()
         self.deleteLater()
     reply.deleteLater()
Ejemplo n.º 10
0
 def create_advertisement_reply(self):
     """ 创建广告返回 """
     reply = self.sender()
     reply.deleteLater()
     if reply.error():
         print(reply.readAll().data())
         message = "创建新广告失败!"
     else:
         message = "创建新广告成功!"
     p = InformationPopup(message, self)
     p.exec_()
     self.create_button.setEnabled(True)
Ejemplo n.º 11
0
 def exit_for_updating(self):
     """ 退出当前程序,启动更新更新 """
     # script_file = os.path.join(BASE_DIR, "AutoUpdate.exe")
     script_file = os.path.join(BASE_DIR, "Update.exe")
     is_close = True
     if os.path.exists(script_file):
         try:
             Popen(script_file, shell=False)
         except OSError as e:
             self.run_message.setText(str(e))
             is_close = False
     else:
         p = InformationPopup("更新程序丢失...", self)
         p.exec_()
         is_close = False
     if is_close:
         sys.exit()
Ejemplo n.º 12
0
 def create_report_file(self):
     """ 从网络文件创建报告 """
     # 验证是否能发送请求
     if not self.selected_varieties:
         p = InformationPopup("未选择关联品种", self)
         p.exec_()
         return
     # 公共body_data
     body_data = {
         "date": self.date_edit.text(),
         "relative_varieties": ";".join(self.selected_varieties),
         "report_type": self.report_type.currentData(),
         "rename_text": self.rename_edit.text().strip()
     }
     if self.local_file_path:  # 上传本地文件
         self.send_local_report(body_data)
     elif self.selected_file_path:  # 选择网络文件
         self.send_network_report(body_data.copy())
     else:
         p = InformationPopup("未选择相关报告文件", self)
         p.exec_()