Disable new and save buttons when the user is not allowed to create new records

The revision update should not overrule the model access.

issue4902
review24611002
This commit is contained in:
Pablo Padulles committed 2016-01-21 10:23:12 +01:00
1 parent 6ef13d27c0
commit c3ee8e2dea
1 file changed
+11 -8
+11 -8
View File
@@ -133,12 +133,7 @@ class Form(SignalEvent, TabContent):
style.bg[gtk.STATE_INSENSITIVE])
self.widget.pack_start(url_entry, False, False)
access = common.MODELACCESS[self.model]
for button, access_type in (
('new', 'create'),
('save', 'write'),
):
self.buttons[button].props.sensitive = access[access_type]
self.set_buttons_sensitive()
self.screen.signal_connect(self, 'record-message',
self._record_message)
@@ -297,8 +292,16 @@ class Form(SignalEvent, TabContent):
self.title.set_label('%s @ %s' % (self.name, revision))
else:
self.title.set_label(self.name)
for button in ('new', 'save'):
self.buttons[button].props.sensitive = not revision
self.set_buttons_sensitive(revision)
def set_buttons_sensitive(self, revision=None):
if not revision:
access = common.MODELACCESS[self.model]
for button, access_type in [('new', 'create'), ('save', 'write')]:
self.buttons[button].props.sensitive = access[access_type]
else:
for button in ['new', 'save']:
self.buttons[button].props.sensitive = False
def sig_remove(self, widget=None):
if not common.MODELACCESS[self.model]['delete']: