def renderActions(ign): if isFeed: d = people.get_suggestions(request, constants.SUGGESTION_PER_PAGE, mini=True) def renderSuggestion(res): suggestions, entities = res t.renderScriptBlock(request, "feed.mako", "_suggestions", False, "#suggestions", "set", True, relations = relation, suggestions = suggestions, entities=entities) d.addCallback(renderSuggestion) return d else: t.renderScriptBlock(request, "profile.mako", "user_actions", False, "#user-actions-%s"%targetId, "set", args=[targetId, True], **data) return defer.succeed([])
def _render(self, request, entityId, start, itemType): (appchange, script, args, myId) = yield self._getBasicArgs(request) itemType = utils.getRequestArg(request, 'type') start = utils.getRequestArg(request, "start") or '' landing = not self._ajax myOrgId = args["orgId"] feedTitle = _("News Feed") menuId = "feed" if entityId: entity = base.Entity(entityId) yield entity.fetchData(['basic', 'admins']) if not entity.basic: raise errors.InvalidEntity("feed", entityId) entityType = entity.basic['type'] orgId = entity.basic["org"] if entityType != "org" else entityId if myOrgId != orgId: raise errors.EntityAccessDenied("organization", entityId) if entityType == 'org': menuId = "org" feedTitle = _("Company Feed: %s") % entity.basic["name"] elif entityType == 'group': request.redirect("/group?id=%s"%(entityId)) defer.returnValue(None) elif entityId != myId: raise errors.EntityAccessDenied("user", entityId) feedId = entityId or myId args["feedTitle"] = feedTitle args["menuId"] = menuId args["feedId"] = feedId if script and landing: t.render(request, "feed.mako", **args) request.write('<script>$("#invite-form").html5form({messages: "en"})</script>') elif script and appchange: onload = '$("#invite-form").html5form({messages: "en"})' t.renderScriptBlock(request, "feed.mako", "layout", landing, "#mainbar", "set", handlers={'onload':onload}, **args) elif script and feedTitle: t.renderScriptBlock(request, "feed.mako", "feed_title", landing, "#title", "set", True, handlers={"onload": "$$.menu.selectItem('%s')"%(menuId)}, **args) if script: handlers = {} handlers["onload"] = handlers.get("onload", "") +\ "$$.files.init('sharebar-attach');" t.renderScriptBlock(request, "feed.mako", "share_block", landing, "#share-block", "set", handlers=handlers, **args) yield self.renderShareBlock(request, "status") feedItems = yield Feed.get(request.getSession(IAuthInfo), feedId=feedId, start=start, itemType=itemType) args.update(feedItems) args['itemType'] = itemType suggestions, entities = yield people.get_suggestions(request, SUGGESTION_PER_PAGE, mini=True) args["suggestions"] = suggestions if "entities" not in args: args["entities"] = entities else: for entity in entities.keys(): if entity not in args["entities"].keys(): args["entities"][entity] = entities[entity] if script: onload = """ (function(obj){$$.convs.load(obj);})(this); $('#feed-side-block-container').empty(); """ t.renderScriptBlock(request, "feed.mako", "feed", landing, "#user-feed", "set", True, handlers={"onload": onload}, **args) t.renderScriptBlock(request, "feed.mako", "feedFilterBar", landing, "#feed-filter-bar", "set", True, args=[itemType], **args) t.renderScriptBlock(request, "feed.mako", "_suggestions", landing, "#suggestions", "set", True, **args) for pluginType in plugins: plugin = plugins[pluginType] if hasattr(plugin, 'renderFeedSideBlock'): if not entityId: entityId = myId yield plugin.renderFeedSideBlock(request, landing, entityId, args) if script and landing: request.write("</body></html>") if not script: t.render(request, "feed.mako", **args)