#330 Don't try to display widgets that have been deactivated or removed
Merged 7 years ago by abompard. Opened 7 years ago by abompard.
abompard/fedora-hubs fix-removed-widgets  into  develop

file modified
+4 -2
@@ -263,13 +263,15 @@ 

      @property

      def left_widgets(self):

          return sorted(

-             [w for w in self.widgets if w.left],

+             [w for w in self.widgets

+              if w.plugin in hubs.widgets.registry and w.left],

              key=lambda w: w.index)

  

      @property

      def right_widgets(self):

          return sorted(

-             [w for w in self.widgets if not w.left],

+             [w for w in self.widgets

+              if w.plugin in hubs.widgets.registry and not w.left],

              key=lambda w: w.index)

  

      @property

file modified
+11 -4
@@ -154,7 +154,14 @@ 

                            username=username,

                            visited_hub=hub)

  

- 

- 

- 

- 

+     def test_removed_widget(self):

+         hub = hubs.models.Hub.get("ralph")

+         widget = hubs.models.Widget(

+             hub=hub, plugin="does-not-exist",

+             left=True, index=-1, _config="{}")

+         self.session.add(widget)

+         self.assertNotIn(

+             "does-not-exist", [w.plugin for w in hub.left_widgets])

+         widget.left = False

+         self.assertNotIn(

+             "does-not-exist", [w.plugin for w in hub.right_widgets])

Before this commit, deactivating a widget class in the config when it had already been instanciated caused a 500 error.

Pull-Request has been merged by abompard

7 years ago