Fix favorite star on community home - Generating context with group for the org page
Fix #1632 (closed)
Issue description
Clicking on the star in community home header (e.g. https://gitter.im/viktomas-godu) doesn't result in adding group to favourites. This is caused by group being missing in window.troupeContext
and consequently in backbone model. more in #1632 (closed)
Root cause and description of the fix
The the org renderer uses uses basic context as a tropueContext
this context contains only user information. So when it gets serialized and then in the browser populates the backbone model, the whole group set of information is missing. This didn't cause more severe trouble because everything on the page gets rendered on the server.
Fix has been implemented by extending basic context with serialized group as a part of the cleanup the org renderer now uses troupeContext.group
instead of serializing it again
Manual testing
- I've tested that the star button works as expected
- I've touched twitter share URL so I tested that the share button still has correct group URL
Endnote
This MR took me all the way from UI view events to the express routes on the server. It was a long journey but I've learnt more about:
- Backbone model and collections
- Server side vs client side rendering
- troupeContext and sanitizing mongoDB entities