changeset 9b4d9d92f0fa in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=9b4d9d92f0fa
description:
        Allow sharing view searches

        We add a rule to give read access to all view searches without a user.
        We manage the delete access on client side thanks to the _delete 
attribute.
        If the user does not have the delete right, the bookmark star is 
disabled.

        issue9515
        review323751002
diffstat:

 tryton/common/common.py                              |   2 +-
 tryton/gui/window/view_form/view/screen_container.py |  21 ++++++++++++-------
 2 files changed, 14 insertions(+), 9 deletions(-)

diffs (66 lines):

diff -r 5a2777308527 -r 9b4d9d92f0fa tryton/common/common.py
--- a/tryton/common/common.py   Thu Sep 24 22:43:50 2020 +0200
+++ b/tryton/common/common.py   Thu Sep 24 23:00:52 2020 +0200
@@ -259,7 +259,7 @@
                         }])
         except RPCException:
             return
-        self.searches.setdefault(model, []).append((id_, name, domain))
+        self.searches.setdefault(model, []).append((id_, name, domain, True))
 
     def remove(self, model, id_):
         try:
diff -r 5a2777308527 -r 9b4d9d92f0fa 
tryton/gui/window/view_form/view/screen_container.py
--- a/tryton/gui/window/view_form/view/screen_container.py      Thu Sep 24 
22:43:50 2020 +0200
+++ b/tryton/gui/window/view_form/view/screen_container.py      Thu Sep 24 
23:00:52 2020 +0200
@@ -242,7 +242,7 @@
                     widget_allocation.x, widget_allocation.y)
                 return (x, y + widget_allocation.height, False)
 
-            for id_, name, domain in self.bookmarks():
+            for id_, name, domain, access in self.bookmarks():
                 menuitem = Gtk.MenuItem(label=name)
                 menuitem.connect('activate', self.bookmark_activate, domain)
                 menu.add(menuitem)
@@ -407,9 +407,10 @@
         self.bookmark_match()
 
     def bookmarks(self):
-        for id_, name, domain in common.VIEW_SEARCH[self.screen.model_name]:
+        for id_, name, domain, access in common.VIEW_SEARCH[
+                self.screen.model_name]:
             if self.screen.domain_parser.stringable(domain):
-                yield id_, name, domain
+                yield id_, name, domain, access
 
     def bookmark_activate(self, menuitem, domain):
         self.set_text(self.screen.domain_parser.string(domain))
@@ -419,11 +420,7 @@
         current_text = self.get_text()
         if current_text:
             current_domain = self.screen.domain_parser.parse(current_text)
-            self.search_entry.set_icon_activatable(
-                Gtk.EntryIconPosition.SECONDARY, bool(current_text))
-            self.search_entry.set_icon_sensitive(
-                Gtk.EntryIconPosition.SECONDARY, bool(current_text))
-            for id_, name, domain in self.bookmarks():
+            for id_, name, domain, access in self.bookmarks():
                 text = self.screen.domain_parser.string(domain)
                 domain = self.screen.domain_parser.parse(text)
                 if (text == current_text
@@ -435,7 +432,15 @@
                     self.search_entry.set_icon_tooltip_text(
                         Gtk.EntryIconPosition.SECONDARY,
                         _('Remove this bookmark'))
+                    self.search_entry.set_icon_activatable(
+                        Gtk.EntryIconPosition.SECONDARY, access)
+                    self.search_entry.set_icon_sensitive(
+                        Gtk.EntryIconPosition.SECONDARY, access)
                     return id_
+            self.search_entry.set_icon_activatable(
+                Gtk.EntryIconPosition.SECONDARY, bool(current_text))
+            self.search_entry.set_icon_sensitive(
+                Gtk.EntryIconPosition.SECONDARY, bool(current_text))
         self.search_entry.set_icon_from_pixbuf(
             Gtk.EntryIconPosition.SECONDARY,
             common.IconFactory.get_pixbuf(

Reply via email to