]> Softwares of Agnibho - medscript.git/commitdiff
Bugfix: remove attachment
authorAgnibho Mondal <mondal@agnibho.com>
Wed, 13 Sep 2023 21:58:52 +0000 (03:28 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Wed, 13 Sep 2023 21:58:52 +0000 (03:28 +0530)
filehandler.py
window.py

index 48aa5d5dcec415b27506318758235d4386bcc1be..63d6b03d763a09221a9e42d46f68b4d6d7b4dc47 100644 (file)
@@ -81,12 +81,18 @@ class FileHandler():
         except FileNotFoundError as e:
             print(e)
 
+    def delete_attachment(self, item):
+        try:
+            os.unlink(os.path.join(self.directory.name, "attachment", os.path.basename(item)))
+        except Exception as e:
+            print(e)
+
     def delete_sign(self):
         try:
             os.unlink(os.path.join(self.directory.name, "certificate.pem"))
             os.unlink(os.path.join(self.directory.name, "signature.p7m"))
         except Exception as e:
-            raise(e)
+            print(e)
 
     def is_signed(self):
         return(os.path.exists(os.path.join(self.directory.name, "certificate.pem")) and (os.path.exists(os.path.join(self.directory.name, "signature.p7m"))))
index d26f0f103f6070f81e7bddf74625a4f55b2db2a5..b1843f65a0b4440520b26e6667ae84ba3cda89e6 100644 (file)
--- a/window.py
+++ b/window.py
@@ -355,7 +355,12 @@ class MainWindow(QMainWindow):
             print(e)
 
     def remove_attachment(self):
-        self.input_attachment.takeItem(self.input_attachment.currentRow())
+        index=self.input_attachment.currentRow()
+        if(index>=0):
+            self.current_file.delete_attachment(self.input_attachment.item(index).text())
+            self.input_attachment.takeItem(index)
+        else:
+            QMessageBox.warning(self, "Select item", "Please select an attachment to remove.")
 
     def save_attachment(self):
         try: