This Changes the calendar (aka the meetings) widget so it only shows on streams or teams. Additionally on the stream page, it shows the meetings upcoming for all the hubs that a user is a member of.
fixes #489
rebased onto baee8b5649d47f5785235ecd7f87affb83143d77
Metadata Update from @abompard: - Request assigned
There are two calls to invalidate() here.
invalidate()
However I'm thinking of a different approach. It will be common for widgets on stream pages to invalidate when the user hub config changes, since that's where the config is. So it should be centralized. I would recommend the following change:
diff --git a/hubs/models/hub.py b/hubs/models/hub.py index f09dbfdc..db58e228 100644 --- a/hubs/models/hub.py +++ b/hubs/models/hub.py @@ -214,7 +214,10 @@ class Hub(ObjectAuthzMixin, BASE): hubs.defaults.add_stream_widgets(self) def on_updated(self, old_config): - for widget_instance in self.widgets: + widgets = self.widgets + if self.hub_type == "user": + widgets.extend(Hub.by_name(self.name, "stream").widgets) + for widget_instance in widgets: if not widget_instance.enabled: continue widget = widget_instance.module
This way stream widgets that have asked to be reloaded on (user) hub config change will be reloaded too.
Whoops! The first one there is a mistake -- i had it in there for debugging to make it not use the cache when testing.
the reason for the other invalidate is because we are reading config values from group hubs here -- namely the calendar values of the hubs that the user is subscribed to. Does that patch above cover that too?
Indeed, it's more complex than I thought. But running invalidate() in the constructor basically means that you're not using the cache at all.
I'll try to think of something else.
OK, I think I have a solution. The solution is using fedmsg to publish config changes in Hubs, instead of directly injecting into the workers queue.
As a result, cached functions can write a should_invalidate() method that will listen for changes in other hubs, in your case the hubs that the user is subscribed to.
should_invalidate()
Please check out PR #518 for my implementation.
The only downside is that a new process must be run to emit fedmsg from Hubs (fedmsg-relay, but I have updated the honcho config file to run it. It works locally.
fedmsg-relay
Feel free to reach out to me if you have questions, it's probably still a bit rough around the edges.
I've rewritten the cached function to use the fedmsg publishing infra in #518. I've opened PR #520 so you can check it out.
Replaced by PR #520
Pull-Request has been closed by abompard
This Changes the calendar (aka the meetings) widget so it only
shows on streams or teams. Additionally on the stream page, it
shows the meetings upcoming for all the hubs that a user is a
member of.
fixes #489