def _unfollow(self, request): authInfo = request.getSession(IAuthInfo) myId = authInfo.username orgId = authInfo.organization tagId, tag = yield utils.getValidTagId(request, "id") count = int(tag[tagId].get('followersCount', 0)) if count % 5 == 3: count = yield db.get_count(tagId, "tagFollowers") count = count - 1 if count > 0 else count yield db.remove(tagId, 'tagFollowers', myId) yield db.insert(orgId, "orgTags", str(count), "followersCount", tagId) tag[tagId]['followersCount'] = count args = {'tags': tag} args['tagsFollowing'] = [] fromListTags = (utils.getRequestArg(request, '_pg') == '/tags/list') if fromListTags: t.renderScriptBlock(request, "tags.mako", "_displayTag", False, "#tag-%s" % tagId, "replace", args=[tagId], **args) else: t.renderScriptBlock(request, 'tags.mako', "tag_actions", False, "#tag-actions-%s" % (tagId), "set", args=[tagId, False, False])
def _renderMore(self, request): (appchange, script, args, myId) = yield self._getBasicArgs(request) (tagId, tagInfo) = yield utils.getValidTagId(request, 'id') start = utils.getRequestArg(request, 'start') or "" tagItems = yield self._getTagItems(request, tagId, start=start) args.update(tagItems) args["tagId"] = tagId onload = "(function(obj){$$.convs.load(obj);})(this);" t.renderScriptBlock(request, "tags.mako", "items", False, "#next-load-wrapper", "replace", True, handlers={"onload": onload}, **args)
def _render(self, request): (appchange, script, args, myId) = yield self._getBasicArgs(request) landing = not self._ajax (tagId, tagInfo) = yield utils.getValidTagId(request, 'id') args["tags"] = tagInfo args["tagId"] = tagId args["tagFollowing"] = False args["menuId"] = "tags" if script and landing: t.render(request, "tags.mako", **args) if script and appchange: t.renderScriptBlock(request, "tags.mako", "layout", landing, "#mainbar", "set", **args) try: yield db.get(tagId, "tagFollowers", myId) args["tagFollowing"] = True except ttypes.NotFoundException: pass if script: t.renderScriptBlock(request, "tags.mako", "header", landing, "#tags-header", "set", **args) start = utils.getRequestArg(request, "start") or '' tagItems = yield self._getTagItems(request, tagId, start=start) args.update(tagItems) if script: onload = """ (function(obj){$$.convs.load(obj);})(this); $('form').html5form({messages: 'en'}); """ t.renderScriptBlock(request, "tags.mako", "itemsLayout", landing, "#content", "set", True, handlers={"onload": onload}, **args) if not script: t.render(request, "tags.mako", **args)