changeset 36:15de081140ff

Fix bug #65379: Error when signing or verifiying and no record is selected
author Luis Falcon <falcon@gnuhealth.org>
date Tue, 27 Feb 2024 21:01:32 +0000
parents a51927f44d36
children 7081596ec015
files crypto/__init__.py
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/crypto/__init__.py
+++ b/crypto/__init__.py
@@ -55,6 +55,14 @@
         To avoid signing unwanted / unread documents
     """
 
+    # Allow only one record
+    if (len(data['ids']) == 0):
+        warning(
+            _('Please choose one record to sign / encrypt'),
+            _('You need to select a record.'),
+        )
+        return
+
     if (len(data['ids']) > 1):
         warning(
             _('For security reasons, Please sign one document at a time'),
@@ -141,6 +149,24 @@
             _('Gnupg python module is not found!'))
         return
 
+
+    # Allow only one record
+    if (len(data['ids']) == 0):
+        warning(
+            _('Please choose one record to verify'),
+            _('You need to select a record.'),
+        )
+        return
+
+    if (len(data['ids']) > 1):
+        warning(
+            _('Please verify one document at a time'),
+            _('Multiple records selected !'),
+        )
+        return
+
+
+
     gpg = gnupg.GPG()
     gpg.encoding = 'utf-8'