• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python template.renderScriptBlock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: _editCompany

    def _editCompany(self, request):
        (appchange, script, args, myId) = yield self._getBasicArgs(request)
        remove = utils.getRequestArg(request, 'action') == 'd'
        encodedCompanyId = utils.getRequestArg(request, 'id', sanitize=False)
        companyId = utils.decodeKey(encodedCompanyId) if encodedCompanyId else None

        if companyId and remove:
            db.remove(myId, "entities", companyId, "companies")
            request.write('$("#%s").remove();' % encodedCompanyId)
            return

        today = datetime.date.today()
        try:
            startYear = int(utils.getRequestArg(request, 'startyear'))
            startMonth = int(utils.getRequestArg(request, 'startmonth'))
            startDay = datetime.date(startYear, startMonth, 1)
        except (ValueError, TypeError):
            raise errors.InvalidRequest('Please give a valid start month and year')

        try:
            endYear = utils.getRequestArg(request, 'endyear')
            if not endYear:
                endYear = 9999
                endMonth = 12
            else:
                endYear = int(endYear)
                endMonth = int(utils.getRequestArg(request, 'endmonth'))
            endDay = datetime.date(endYear, endMonth, 1)
        except (ValueError, TypeError):
            raise errors.InvalidRequest('Please give a valid end month and year')

        if startDay > today or startDay > endDay or (endDay > today and endYear != 9999):
            raise errors.InvalidRequest('The start month/year and end month/year are invalid!')

        name = utils.getRequestArg(request, 'company')
        title = utils.getRequestArg(request, 'title')

        if not remove and not name:
            errors.MissingParams(['Name'])

        if companyId:
            db.remove(myId, "entities", companyId, "companies")

        newCompanyId = "%s%s:%s%s:%s" % (endYear, endMonth, startYear, startMonth, name)
        newCompanyVal = title
        db.insert(myId, "entities", newCompanyVal, newCompanyId, "companies")

        if companyId:
            yield t.renderScriptBlock(request, "settings.mako", "companyItem",
                                    False, "#"+encodedCompanyId, "replace",
                                    args=[newCompanyId, newCompanyVal])
        else:
            onload = """$('#company-empty-msg').remove();"""+\
                     """$('#addemp-wrap').replaceWith('<div id="addemp-wrap"><button class="button ajax" id="addedu-button" data-ref="/settings/company">Add Company</button></div>');"""
            yield t.renderScriptBlock(request, "settings.mako", "companyItem",
                                    False, "#companies-wrapper", "append", True,
                                    handlers={'onload': onload},
                                    args=[newCompanyId, newCompanyVal])
开发者ID:psunkari,项目名称:flocked-in,代码行数:58,代码来源:settings.py


示例17: _unblock

    def _unblock(self, request, data=None):
        myId = request.getSession(IAuthInfo).username
        group = data['id']
        user = data['uid']
        me = base.Entity(myId)

        yield Group.unblock(group, user, me)
        t.renderScriptBlock(request, "groups.mako", "groupRequestActions",
                            False, '#group-request-actions-%s-%s' % (user.id, group.id),
                            "set", args=[group.id, user.id, "unblock"])
开发者ID:psunkari,项目名称:flocked-in,代码行数:10,代码来源:groups.py


示例18: _unblockUser

    def _unblockUser(self, request, data=None):
        orgId = request.getSession(IAuthInfo).organization

        user = data['id']
        emailId = user.basic.get("emailId", None)

        yield db.remove(emailId, "userAuth", "isBlocked")
        yield db.remove(orgId, "blockedUsers", user.id)
        t.renderScriptBlock(request, "admin.mako", "admin_actions",
                                False, "#user-actions-%s" % (user.id),
                                "set", args=[user.id, 'unblocked'])
开发者ID:psunkari,项目名称:flocked-in,代码行数:11,代码来源:admin.py


示例19: _registerClient

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

        name = utils.getRequestArg(request, "name")
        desc = utils.getRequestArg(request, "desc")
        scope = utils.getRequestArg(request, "scope", multiValued=True)
        category = utils.getRequestArg(request, "category")
        redirect = utils.getRequestArg(request, "redirect", sanitize=False)

        if not name:
            raise errors.MissingParams(["Name"])

        if not scope:
            raise errors.MissingParams(["Permissions"])

        if category != "apikey" and not redirect:
            raise errors.MissingParams(["Redirect URL"])

        knownScopes = globals().get("scopes")
        unknownScopes = [x for x in scope if x not in knownScopes.keys()]
        if category not in ["webapp", "native", "apikey"] or unknownScopes:
            raise errors.BaseError("Invalid value sent for Type/Permissions")

        clientId = utils.getUniqueKey()
        clientSecret = utils.getRandomKey()

        meta = {
            "author": myId,
            "name": name,
            "org": myOrgId,
            "secret": utils.hashpass(clientSecret),
            "scope": " ".join(scope),
            "category": category,
        }

        if category != "apikey":
            meta["redirect"] = b64encode(redirect)
            meta["desc"] = desc
            yield db.batch_insert(clientId, "apps", {"meta": meta})
            yield db.insert(myId, "appsByOwner", "", clientId)
            yield db.insert(myOrgId, "appsByOwner", "", clientId)
        else:
            yield db.batch_insert(clientId, "apps", {"meta": meta})
            yield db.insert(myId, "entities", "", clientId, "apikeys")

        self.setTitle(request, name)

        args["clientId"] = clientId
        args["client"] = meta
        args["client"]["secret"] = clientSecret
        t.renderScriptBlock(request, "apps.mako", "registrationResults", landing, "#apps-contents", "set", **args)
开发者ID:psunkari,项目名称:flocked-in,代码行数:53,代码来源:apps.py


示例20: renderShareBlock

 def renderShareBlock(self, request, isAjax):
     t.renderScriptBlock(
         request,
         "feed.mako",
         "share_status",
         not isAjax,
         "#sharebar",
         "set",
         True,
         attrs={"publisherName": "status"},
         handlers={"onload": "(function(obj){$$.publisher.load(obj)})(this);"},
     )
开发者ID:psunkari,项目名称:flocked-in,代码行数:12,代码来源:status.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.User类代码示例发布时间:2022-05-27
下一篇:
Python p3.urlparse函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap