当前位置: 首页>>代码示例>>Python>>正文


Python template.renderScriptBlock函数代码示例

本文整理汇总了Python中social.template.renderScriptBlock函数的典型用法代码示例。如果您正苦于以下问题:Python renderScriptBlock函数的具体用法?Python renderScriptBlock怎么用?Python renderScriptBlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了renderScriptBlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _listPresetTags

    def _listPresetTags(self, request):
        (appchange, script, args, myId) = yield self._getBasicArgs(request)
        orgId = args["orgId"]
        landing = not self._ajax

        args['title'] = 'Preset Tags'
        args['menuId'] = 'tags'
        args["viewType"] = "tags"

        if script and landing:
            t.render(request, "admin.mako", **args)

        if script and appchange:
            t.renderScriptBlock(request, "admin.mako", "layout",
                                    landing, "#mainbar", "set", **args)

        presetTags = yield db.get_slice(orgId, "orgPresetTags", count=100)
        presetTags = utils.columnsToDict(presetTags, ordered=True).values()
        if presetTags:
            tags_ = yield db.get_slice(orgId, "orgTags", presetTags)
            tags_ = utils.supercolumnsToDict(tags_)
        else:
            tags_ = {}

        args['tagsList'] = presetTags
        args['tags'] = tags_
        if script:
            t.renderScriptBlock(request, "admin.mako", "list_tags",
                                    landing, "#content", "set", **args)

        if not script:
            t.render(request, "admin.mako", **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:32,代码来源:admin.py

示例2: _addPresetTag

    def _addPresetTag(self, request):
        orgId = request.getSession(IAuthInfo).organization
        tagNames = utils.getRequestArg(request, 'tag')
        if not tagNames:
            return

        invalidTags = []
        tagNames = [x.strip().decode('utf-8', 'replace') for x in tagNames.split(',')]
        for tagName in tagNames:
            if len(tagName) < 50 and regex.match('^[\w-]*$', tagName):
                yield tags.ensureTag(request, tagName, orgId, True)
            else:
                invalidTags.append(tagName)

        presetTags = yield db.get_slice(orgId, "orgPresetTags")
        presetTags = utils.columnsToDict(presetTags, ordered=True).values()

        tags_ = yield db.get_slice(orgId, "orgTags", presetTags)
        tags_ = utils.supercolumnsToDict(tags_)
        args = {'tags': tags_, 'tagsList': presetTags}

        handlers = {}
        if invalidTags:
            if len(invalidTags) == 1:
                message = " %s is invalid tag." % (invalidTags[0])
            else:
                message = " %s are invalid tags. " % (",".join(invalidTags))
            errorMsg = "%s <br/>Tag can contain alpha-numeric characters or hyphen only. It cannot be more than 50 characters" % (message)
            handlers = {'onload': "$$.alerts.error('%s')" % (errorMsg)}

        t.renderScriptBlock(request, "admin.mako", "list_tags",
                            False, "#content", "set", True,
                            handlers=handlers, **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:33,代码来源:admin.py

示例3: _renderOrgInfo

    def _renderOrgInfo(self, request):
        (appchange, script, args, myId) = yield self._getBasicArgs(request)
        landing = not self._ajax

        args['title'] = "Update Company Info"
        args["menuId"] = "org"

        if script and landing:
            t.render(request, "admin.mako", **args)

        if script and appchange:
            t.renderScriptBlock(request, "admin.mako", "layout",
                                    landing, "#mainbar", "set", **args)

        args["viewType"] = "org"
        if script:
            handlers = {'onload': "$$.ui.bindFormSubmit('#orginfo-form');"}
            t.renderScriptBlock(request, "admin.mako", "orgInfo",
                                landing, "#content", "set", True,
                                handlers=handlers, **args)

        if script and landing:
            request.write("</body></html>")

        if not script:
            t.render(request, "admin.mako", **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:26,代码来源:admin.py

示例4: _renderKeywordMatches

    def _renderKeywordMatches(self, request):
        (appchange, script, args, myId) = yield self._getBasicArgs(request)
        landing = not self._ajax

        keyword = utils.getRequestArg(request, 'keyword')
        if not keyword:
            errors.MissingParams(['Keyword'])
        args["keyword"] = keyword

        start = utils.getRequestArg(request, "start") or ""
        args["start"] = start

        if script and landing:
            t.render(request, "keyword-matches.mako", **args)

        if script and appchange:
            t.renderScriptBlock(request, "keyword-matches.mako", "layout",
                                    landing, "#mainbar", "set", **args)

        keywordItems = yield self._getKeywordMatches(request, keyword,
                                                     start=start)
        args.update(keywordItems)

        if script:
            onload = "(function(obj){$$.convs.load(obj);})(this);"
            t.renderScriptBlock(request, "keyword-matches.mako", "feed",
                                    landing, "#convs-wrapper", "set", True,
                                    handlers={"onload": onload}, **args)

        if not script:
            t.render(request, "keyword-matches.mako", **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:31,代码来源:admin.py

示例5: _unfollow

    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])
开发者ID:psunkari,项目名称:flocked-in,代码行数:26,代码来源:tags.py

示例6: renderShareBlock

    def renderShareBlock(self, request, isAjax):
        authinfo = request.getSession(IAuthInfo)
        myId = authinfo.username
        orgId = authinfo.organization

        entities = base.EntitySet([myId, orgId])
        yield entities.fetchData()

        me = entities[myId]
        org = entities[orgId]
        args = {"myId": myId, "orgId": orgId, "me": me, "org": org}

        my_tz = timezone(me.basic["timezone"])
        utc_now = datetime.datetime.now(pytz.utc)
        mytz_now = utc_now.astimezone(my_tz)
        args.update({"my_tz": my_tz, "utc_now":utc_now, "mytz_now":mytz_now})

        onload = """
                (function(obj){
                    $$.publisher.load(obj);
                    $$.events.prepareDateTimePickers();
                    $$.events.autoFillUsers();
                })(this);
                """
        t.renderScriptBlock(request, "event.mako", "share_event",
                                not isAjax, "#sharebar", "set", True,
                                attrs={"publisherName": "event"},
                                handlers={"onload": onload}, **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:28,代码来源:event.py

示例7: _unsubscribe

    def _unsubscribe(self, request, data=None):
        authInfo = request.getSession(IAuthInfo)
        myId = authInfo.username

        group = data['id']
        _pg = data['_pg']
        me = base.Entity(myId)
        yield me.fetchData(['basic'])

        yield Group.unsubscribe(request, group, me)
        args = {"groupId": group.id, "me": me, "myGroups": [],
                "entities": {group.id: group}, "groupFollowers": {group.id: []},
                "pendingConnections": [], "isMember": False}
        t.renderScriptBlock(request, "group-feed.mako", "group_actions", False,
                            "#group-actions-%s" % (group.id), "set", **args)

        if _pg == '/group':
            onload = "(function(obj){$$.convs.load(obj);})(this);"
            onload += "$('#sharebar-attach-fileshare, #sharebar-attach-file-input').attr('disabled', 'disabled');"
            onload += "$('#sharebar-submit').attr('disabled', 'disabled');"
            onload += "$('#group-share-block').addClass('disabled');"
            onload += "$('#group-links').hide();"
            t.renderScriptBlock(request, "group-feed.mako", "feed",
                                False, "#user-feed", "set", True,
                                handlers={"onload": onload}, **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:25,代码来源:groups.py

示例8: _renderReportResponses

    def _renderReportResponses(self, request, convId, convMeta, args):
        reportId = convMeta.get('reportId', None)
        args['convMeta'] = convMeta
        script = args["script"]
        myId = args["myId"]
        landing = not self._ajax

        if script:
            t.renderScriptBlock(request, "item-report.mako", "item_report",
                                landing, "#report-contents", "set", **args)

        if reportId:
            reportResponses = yield db.get_slice(reportId, "itemResponses")
            reportResponseKeys, toFetchEntities = [], []
            reportResponseActions = {}

            for response in reportResponses:
                userKey, responseKey, action = response.column.value.split(":")
                reportResponseKeys.append(responseKey)
                reportResponseActions[responseKey] = action

            fetchedResponses = yield db.multiget_slice(reportResponseKeys, "items", ["meta"])
            fetchedResponses = utils.multiSuperColumnsToDict(fetchedResponses)

            args["reportId"] = reportId
            args["reportItems"] = fetchedResponses
            args["responseKeys"] = reportResponseKeys
            args["reportResponseActions"] = reportResponseActions

            #Show comments from report only if I am the owner or the reporter
            if script and myId in [convMeta["owner"], convMeta["reportedBy"]]:
                t.renderScriptBlock(request, "item-report.mako", 'report_comments',
                                    landing, '#report-comments', 'set', **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:33,代码来源:item.py

示例9: _renderEditGroup

    def _renderEditGroup(self, request, data=None):
        appchange, script, args, myId = yield self._getBasicArgs(request)
        landing = not self._ajax

        group = data['id']
        args["menuId"] = "settings"
        args["groupId"] = group.id
        args["entities"] = base.EntitySet(group)
        args["heading"] = group.basic['name']

        if myId not in group.admins:
            raise errors.PermissionDenied('You should be an administrator to edit group meta data')

        if script and landing:
            t.render(request, "group-settings.mako", **args)
        if script and appchange:
            t.renderScriptBlock(request, "group-settings.mako", "layout",
                                landing, "#mainbar", "set", **args)
        if script:
            handlers = {}
            handlers["onload"] = """$$.ui.bindFormSubmit('#group-form');"""
            t.renderScriptBlock(request, "group-settings.mako", "edit_group",
                                landing, "#center-content", "set", True,
                                handlers=handlers, **args)
        else:
            t.render(request, "group-settings.mako", **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:26,代码来源:groups.py

示例10: _comment

    def _comment(self, request, data=None):

        authInfo = request.getSession(IAuthInfo)
        myId = authInfo.username
        orgId = authInfo.organization
        convId, conv = data['parent']
        fids = data['fId']
        comment, snippet = data['comment']
        review = data['_review']

        itemId, convId, items, keywords = yield Item._comment(convId, conv, comment, snippet, myId, orgId, False, review, fids)

        if keywords:
            block = t.getBlock('item.mako', 'requireReviewDlg', keywords=keywords, convId=convId)
            request.write('$$.convs.reviewRequired(%s, "%s");' % (json.dumps(block), convId))
            return

        # Finally, update the UI
        entities = base.EntitySet([myId])
        yield entities.fetchData()
        args = {"entities": entities, "items": items, "me": entities[myId]}

        numShowing = utils.getRequestArg(request, "nc") or "0"
        numShowing = int(numShowing) + 1
        responseCount = items[convId]['meta']['responseCount']
        isItemView = (utils.getRequestArg(request, "_pg") == "/item")
        t.renderScriptBlock(request, 'item.mako', 'conv_comments_head',
                            False, '#comments-header-%s' % (convId), 'set',
                            args=[convId, responseCount, numShowing, isItemView], **args)
        onload = """(function(){$('.comment-input', '#comment-form-%s').val(''); $('[name=\"nc\"]', '#comment-form-%s').val('%s');})();$('#comment-attach-%s-uploaded').empty()""" % (convId, convId, numShowing, convId)
        t.renderScriptBlock(request, 'item.mako', 'conv_comment', False,
                            '#comments-%s' % convId, 'append', True,
                            handlers={"onload": onload},
                            args=[convId, itemId], **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:34,代码来源:item.py

示例11: _renderMore

    def _renderMore(self, request, data=None):
        myId = request.getSession(IAuthInfo).username

        group = data['id']
        start = data['start']
        itemType = data['type']
        me = base.Entity(myId)
        me_d = me.fetchData()
        args = {'itemType': itemType, 'groupId': group.id, "me": me}

        isMember = yield db.get_count(group.id, "groupMembers", start=myId, finish=myId)
        if isMember:
            feedItems = yield Feed.get(request.getSession(IAuthInfo),
                                       feedId=group.id, start=start,
                                       itemType=itemType)
            args.update(feedItems)
        else:
            args["conversations"] = []
            args["entities"] = {}
        yield me_d
        args["isMember"] = isMember
        args["entities"].update(group)
        args['entities'].update(me)

        onload = "(function(obj){$$.convs.load(obj);})(this);"
        t.renderScriptBlock(request, "group-feed.mako", "feed", False,
                            "#next-load-wrapper", "replace", True,
                            handlers={"onload": onload}, **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:28,代码来源:groups.py

示例12: _renderChooseAudience

    def _renderChooseAudience(self, request):
        (appchange, script, args, myId) = yield self._getBasicArgs(request)

        onload = "$('form').html5form({messages: 'en'});"
        t.renderScriptBlock(request, "feed.mako", "customAudience", False,
                            "#custom-audience-dlg", "set", True,
                            handlers={"onload": onload}, **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:7,代码来源:feed.py

示例13: renderSuggestion

 def renderSuggestion(res):
     suggestions, entities = res
     t.renderScriptBlock(request, "feed.mako", "_suggestions",
                         False, "#suggestions", "set", True,
                         relations = relation,
                         suggestions = suggestions,
                         entities=entities)
开发者ID:psunkari,项目名称:flocked-in,代码行数:7,代码来源:profile.py

示例14: _renderClientDetails

    def _renderClientDetails(self, request, clientId):
        (appchange, script, args, myId) = yield self._getBasicArgs(request)
        landing = not self._ajax

        args["detail"] = "apps"

        if script and landing:
            t.render(request, "apps.mako", **args)

        if appchange and script:
            t.renderScriptBlock(request, "apps.mako", "layout", landing, "#mainbar", "set", **args)

        client = yield db.get_slice(clientId, "apps")
        client = utils.supercolumnsToDict(client)
        if not client:
            raise errors.InvalidApp(clientId)

        args.update({"client": client, "clientId": clientId})
        if script:
            self.setTitle(request, client["meta"]["name"])

        author = base.Entity(client["meta"]["author"])
        yield author.fetchData()
        args["entities"] = base.EntitySet(author)

        if script:
            t.renderScriptBlock(request, "apps.mako", "appDetails", landing, "#apps-contents", "set", **args)
        else:
            t.render(request, "apps.mako", **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:29,代码来源:apps.py

示例15: _attendance

    def _attendance(self, request):
        itemId, item = yield utils.getValidItemId(request, "id",
                                                  columns=["invitees"])
        list_type = utils.getRequestArg(request, 'type') or "yes"
        user_list = []

        if itemId and list_type in ["yes", "no", "maybe"]:
            cols = yield db.get_slice(itemId, "eventResponses")
            res = utils.columnsToDict(cols)
            for rsvp in res.keys():
                resp = rsvp.split(":")[0]
                uid = rsvp.split(":")[1]
                if resp == list_type:
                    if uid in item["invitees"] and \
                      item["invitees"][uid] == list_type:
                        user_list.insert(0, uid)
                    else:
                        user_list.append(uid)

            invited = user_list
            owner = item["meta"].get("owner")

            entities = base.EntitySet(invited+[owner])
            yield entities.fetchData()

            args = {"users": invited, "entities": entities}
            args['title'] = {"yes":_("People attending this event"),
                             "no": _("People not attending this event"),
                             "maybe": _("People who may attend this event")
                             }[list_type]

            t.renderScriptBlock(request, "item.mako", "userListDialog", False,
                                    "#invitee-dlg-%s"%(itemId), "set", **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:33,代码来源:event.py


注:本文中的social.template.renderScriptBlock函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。