Author: reinhard
Date: 2010-10-28 13:52:32 -0500 (Thu, 28 Oct 2010)
New Revision: 10221

Modified:
   trunk/gnue-forms/
   trunk/gnue-forms/src/GFObjects/GFBlock.py
Log:
Disallow "normal" insert operations when a block has an autosearch field, since
inserts in such blocks have to be done by entering the new key.



Property changes on: trunk/gnue-forms
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2010-10-27 23:12:56.453000069 +0200
committer: Reinhard Müller <[email protected]>
properties: 
        branch-nick: forms

   + timestamp: 2010-10-28 15:58:33.852999926 +0200
committer: Reinhard Müller <[email protected]>
properties: 
        branch-nick: forms

Name: bzr:file-ids
   - src/uidrivers/wx/widgets/button.py 
10...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2Fuidrivers%2Fwx%2Fwidgets%2Fbutton.py
src/uidrivers/wx/widgets/entry.py       
10...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2Fuidrivers%2Fwx%2Fwidgets%2Fentry.py

   + src/GFObjects/GFBlock.py   
1...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2FGFObjects%2FGFBlock.py

Name: bzr:revision-id:v4
   - 3116 [email protected]
3117 [email protected]
3118 [email protected]
3119 [email protected]
3120 [email protected]
3121 [email protected]
3122 [email protected]
3123 [email protected]
3124 [email protected]
3125 [email protected]
3126 [email protected]
3127 [email protected]
3128 [email protected]
3129 [email protected]
3130 [email protected]
3131 [email protected]
3132 [email protected]
3133 [email protected]
3134 [email protected]
3135 [email protected]
3136 [email protected]
3137 [email protected]
3138 [email protected]

   + 3116 [email protected]
3117 [email protected]
3118 [email protected]
3119 [email protected]
3120 [email protected]
3121 [email protected]
3122 [email protected]
3123 [email protected]
3124 [email protected]
3125 [email protected]
3126 [email protected]
3127 [email protected]
3128 [email protected]
3129 [email protected]
3130 [email protected]
3131 [email protected]
3132 [email protected]
3133 [email protected]
3134 [email protected]
3135 [email protected]
3136 [email protected]
3137 [email protected]
3138 [email protected]
3139 [email protected]

Name: bzr:text-parents
   - src/uidrivers/wx/widgets/button.py 
svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:10116
src/uidrivers/wx/widgets/entry.py       
[email protected]

   + src/GFObjects/GFBlock.py   
[email protected]


Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py   2010-10-28 18:52:29 UTC (rev 
10220)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py   2010-10-28 18:52:32 UTC (rev 
10221)
@@ -365,7 +365,7 @@
                 self.__scrolling_blocked = True
                 try:
                     if not self.__resultset.firstRecord():
-                        if self.editable in ('Y', 'new'):
+                        if self.__can_insert():
                             self.__resultset.insertRecord(self._lastValues)
                 finally:
                     self.__scrolling_blocked = False
@@ -772,7 +772,7 @@
 
         if self.__resultset.isLastRecord():
             if self.autoCreate and self.get_record_status() != 'empty' and \
-                    not self.editable in('update', 'N'):
+                    self.__can_insert():
                 self.new_record()
                 return True
             return False
@@ -1003,18 +1003,17 @@
                             result.append('last_record')
                         result.append('goto_record')
 
-                    if not self._form.readonly:
-                        if self.editable in ('Y', 'new') and status != 'empty':
-                            result.append('new_record')
-                            result.append('duplicate_record')
-                            if self.autoCreate and rs.isLastRecord():
-                                result.append('next_record')
+                    if self.__can_insert() and status != 'empty':
+                        result.append('new_record')
+                        result.append('duplicate_record')
+                        if self.autoCreate and rs.isLastRecord():
+                            result.append('next_record')
 
-                        if self.deletable:
-                            if status not in ('void', 'deleted'):
-                                result.append('delete_record')
-                            else:
-                                result.append('undelete_record')
+                    if self.__can_delete():
+                        if status not in ('void', 'deleted'):
+                            result.append('delete_record')
+                        else:
+                            result.append('undelete_record')
 
         return result
 
@@ -1637,6 +1636,34 @@
 
 
     # -------------------------------------------------------------------------
+    # Operations available through the user interface
+    # -------------------------------------------------------------------------
+
+    def __can_insert(self):
+
+        if self._form.readonly:
+            return False
+
+        if self.editable in ['N', 'update']:
+            return False
+
+        for field in self._fieldMap.itervalues():
+            if field.autosearch:
+                return False
+
+        return True
+
+    # -------------------------------------------------------------------------
+
+    def __can_delete(self):
+
+        if self._form.readonly:
+            return False
+
+        return self.deletable
+
+
+    # -------------------------------------------------------------------------
     # Create a condition tree
     # -------------------------------------------------------------------------
 


_______________________________________________
commit-gnue mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/commit-gnue

Reply via email to