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


Python interfaces.ICommunity类代码示例

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


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

示例1: visit

    def visit(self, context):
        if IProfile.providedBy(context):
            users = find_users(context)
            person = self._get_person(context.__name__)
            person['first_last'] = ' '.join(
                (context.firstname, context.lastname))
            person['create_date'] = context.created
            person['is_staff'] = users.member_of_group(
                context.__name__, 'group.KarlStaff')
            person['location'] = context.location
            person['department'] = context.department

            tags = find_tags(context)
            person['tags'] = len(tags.getTags(users=[context.__name__]))

        elif ICommunity.providedBy(context):
            for id in context.member_names:
                self._get_person(id)['membership'] += 1
            for id in context.moderator_names:
                self._get_person(id)['communities_moderator'] += 1

        else:
            creator = getattr(context, 'creator', None)
            if creator is not None:
                person = self._get_person(creator)
                person['content_created'] += 1
                if context.created > self.one_month_ago:
                    person['created_this_month'] += 1
开发者ID:boothead,项目名称:karl,代码行数:28,代码来源:generate_stats.py

示例2: redirect_community_view

def redirect_community_view(context, request):
    assert ICommunity.providedBy(context), str(type(context))

    default_tool = getattr(context, 'default_tool', None)
    if not default_tool:
        default_tool = 'view.html'
    return HTTPFound(location=model_url(context, request, default_tool))
开发者ID:boothead,项目名称:karl,代码行数:7,代码来源:community.py

示例3: visit

    def visit(node):
        if not (ICommunity.providedBy(node) or
                getattr(node, '__parent__', None) is None):
            for ancestor in visit(node.__parent__):
                yield ancestor

        yield dict(title=title_or_id(node), href=resource_url(node, request))
开发者ID:Falmarri,项目名称:karl,代码行数:7,代码来源:imagedrawer.py

示例4: tabs

    def tabs(self):
        if self._tabs is None:

            found_current = False

            overview_css_class = ""

            if ICommunity.providedBy(self.request.context) and self.request.view_name in ["", "view.html"]:
                overview_css_class = "curr"
                found_current = True

            tabs = [
                {
                    "url": resource_url(self.context, self.request, "view.html"),
                    "css_class": overview_css_class,
                    "name": "OVERVIEW",
                }
            ]

            for toolinfo in get_listitems(IToolFactory):
                toolfactory = toolinfo["component"]
                if toolfactory.is_present(self.context, self.request):
                    info = {}
                    info["url"] = toolfactory.tab_url(self.context, self.request)
                    info["css_class"] = ""
                    if not found_current:
                        if toolfactory.is_current(self.context, self.request):
                            info["css_class"] = "curr"
                            found_current = True
                    info["name"] = toolinfo["title"].upper()
                    tabs.append(info)

            self._tabs = tabs

        return self._tabs
开发者ID:Falmarri,项目名称:karl,代码行数:35,代码来源:adapters.py

示例5: visit

    def visit(node):
        if not (ICommunity.providedBy(node) or
                getattr(node, '__parent__', None) is None):
            for ancestor in visit(node.__parent__):
                yield ancestor

        yield dict(title=node.title, href=model_url(node, request))
开发者ID:boothead,项目名称:karl,代码行数:7,代码来源:imagedrawer.py

示例6: tabs

    def tabs(self):
        if self._tabs is None:

            found_current = False

            overview_css_class = ''

            if ( ICommunity.providedBy(self.request.context) and
                 self.request.view_name in ['','view.html','ux2_view.html'] ):
                overview_css_class = 'curr'
                found_current = True

            tabs = [
                {'url':resource_url(self.context, self.request, 'view.html'),
                 'css_class':overview_css_class,
                 'name':'OVERVIEW'}
                ]

            for toolinfo in get_listitems(IToolFactory):
                toolfactory = toolinfo['component']
                if toolfactory.is_present(self.context, self.request):
                    info = {}
                    info['url'] = toolfactory.tab_url(self.context,
                                                      self.request)
                    info['css_class'] = ''
                    if not found_current:
                        if toolfactory.is_current(self.context, self.request):
                            info['css_class'] = 'curr'
                            found_current = True
                    info['name'] = toolinfo['title'].upper()
                    tabs.append(info)

            self._tabs = tabs

        return self._tabs
开发者ID:claytron,项目名称:karl,代码行数:35,代码来源:adapters.py

示例7: community_recent_items_ajax_view

def community_recent_items_ajax_view(context, request):
    assert ICommunity.providedBy(context), str(type(context))

    recent_items = []
    recent_items_batch = get_recent_items_batch(context, request, 5)
    for item in recent_items_batch["entries"]:
        adapted = getMultiAdapter((item, request), IGridEntryInfo)
        recent_items.append(adapted)

    return {'items': recent_items}
开发者ID:lslaz1,项目名称:karl,代码行数:10,代码来源:community.py

示例8: community_members_ajax_view

def community_members_ajax_view(context, request):
    assert ICommunity.providedBy(context), str(type(context))

    members = []
    members_batch = get_members_batch(context, request, 5)
    for item in members_batch:
        adapted = getMultiAdapter((item, request), IGridEntryInfo)
        adapted.moderator = item.__name__ in context.moderator_names
        members.append(adapted)

    return {'items': members}
开发者ID:lslaz1,项目名称:karl,代码行数:11,代码来源:community.py

示例9: redirect_community_view

def redirect_community_view(context, request):
    assert ICommunity.providedBy(context), str(type(context))

    default_tool = getattr(context, 'default_tool', None)
    if not default_tool:
        default_tool = 'view.html'
    # Preserve status_message=, etc in query string
    query = request.GET
    if query:
        location = resource_url(context, request, default_tool, query=query)
    else:
        location = resource_url(context, request, default_tool)
    return HTTPFound(location=location)
开发者ID:lslaz1,项目名称:karl,代码行数:13,代码来源:community.py

示例10: leave_community_view

def leave_community_view(context, request):
    """
    Users can leaver a community they are a member of
    """
    assert ICommunity.providedBy(context)
    profiles = find_profiles(context)
    user = authenticated_userid(request)
    profile = profiles[user]
    community_users = find_users(context)
    community_users.remove_group(profile.__name__, context.members_group_name)
    status_message = "You are no longer a member of this community!"
    community_href = resource_url(context, request,
                                  query={"status_message": status_message})
    return HTTPFound(location=community_href)
开发者ID:lslaz1,项目名称:karl,代码行数:14,代码来源:community.py

示例11: show_community_view

def show_community_view(context, request):
    assert ICommunity.providedBy(context), str(type(context))

    user = authenticated_userid(request)
    page_title = 'View Community ' + context.title
    api = TemplateAPI(context, request, page_title)

    # provide client data for rendering current tags in the tagbox
    tagquery = getMultiAdapter((context, request), ITagQuery)
    client_json_data = dict(
        tagbox = dict(
            docid = tagquery.docid,
            records = tagquery.tagswithcounts,
            ),
        )

    # Filter the actions based on permission
    actions = []
    if has_permission(MODERATE, context, request):
        actions.append(('Edit', 'edit.html'))

    # If user has permission to see this view then has permission to join.
    if not(user in context.member_names or user in context.moderator_names):
        actions.append(('Join', 'join.html'))

    if has_permission(DELETE_COMMUNITY, context, request):
        actions.append(('Delete', 'delete.html'))

    recent_items = []
    recent_items_batch = get_recent_items_batch(context, request)
    for item in recent_items_batch["entries"]:
        adapted = getMultiAdapter((item, request), IGridEntryInfo)
        recent_items.append(adapted)

    feed_url = model_url(context, request, "atom.xml")
    return render_template_to_response(
        'templates/community.pt',
        api=api,
        actions=actions,
        recent_items=recent_items,
        batch_info=recent_items_batch,
        head_data=convert_to_script(client_json_data),
        feed_url=feed_url,
    )
开发者ID:boothead,项目名称:karl,代码行数:44,代码来源:community.py

示例12: searchresults_view

def searchresults_view(context, request):
    # We can get here from either the LiveSearch or advanced search
    # screens

    page_title = "Search Results"
    api = TemplateAPI(context, request, page_title)
    if ICommunity.providedBy(context):
        layout = api.community_layout
        community = context.title
    else:
        layout = api.generic_layout
        community = None

    batch = None
    terms = ()
    error = None

    try:
        batch, terms = get_batch(context, request)
    except ParseError, e:
        error = "Error: %s" % e
开发者ID:boothead,项目名称:karl,代码行数:21,代码来源:search.py

示例13: related_communities_ajax_view

def related_communities_ajax_view(context, request):
    assert ICommunity.providedBy(context), str(type(context))

    related = []
    principals = effective_principals(request)
    searcher = ICatalogSearch(context)
    search = ' OR '.join(context.title.lower().split())
    total, docids, resolver = searcher(interfaces=[ICommunity],
                                       limit=5,
                                       reverse=True,
                                       sort_index="modified_date",
                                       texts=search,
                                       allowed={'query': principals,
                                                'operator': 'or'},
                                       )
    for docid in docids:
        model = resolver(docid)
        if model is not None:
            if model is not context:
                adapted = getMultiAdapter((model, request), IGridEntryInfo)
                related.append(adapted)

    return {'items': related}
开发者ID:lslaz1,项目名称:karl,代码行数:23,代码来源:community.py

示例14: leave

 def leave(self, context):
     if ICommunity.providedBy(context):
         assert context is self.community
         self.row['community_tags'] = len(self.row['community_tags'])
         self.rows.append(self.row)
         self.row = self.community = None
开发者ID:boothead,项目名称:karl,代码行数:6,代码来源:generate_stats.py

示例15: searchresults_view

def searchresults_view(context, request):
    request.unicode_errors = 'ignore'
    page_title = 'Search Results'
    api = TemplateAPI(context, request, page_title)
    if ICommunity.providedBy(context):
        layout = api.community_layout
        community = context.title
    else:
        layout = api.generic_layout
        community = None

    batch = None
    terms = ()
    error = None
    params = request.params.copy()
    if 'batch_start' in params:
        del params['batch_start']
    if 'batch_size' in params:
        del params['batch_size']

    kind_knob = []
    selected_kind = params.get('kind')
    for o in get_listitems(IGroupSearchFactory):
        component = o['component']
        if not component.advanced_search:
            continue
        kind = o['name']
        query = params.copy()
        query['kind'] = kind
        kind_knob.append({
            'name': kind,
            'title': o['title'],
            'icon': component.icon,
            'url': model_url(context, request, request.view_name,
                             query=query),
            'selected': kind == selected_kind,
        })
    query = params.copy()
    if 'kind' in query:
        del query['kind']
    kind_knob.insert(0, {
        'name': 'all_content',
        'title': 'All Content',
        'description': 'All Content',
        'icon': None,
        'url': model_url(context, request, request.view_name, query=query),
        'selected': not selected_kind,
    })

    since_knob = []
    selected_since = params.get('since')
    for id in since_order:
        option = since_options[id].copy()
        query = params.copy()
        if id is not None:
            query['since'] = id
        elif 'since' in query:
            del query['since']
        option['url'] = model_url(context, request, request.view_name,
                                  query=query)
        option['selected'] = id == selected_since
        since_knob.append(option)

    start_time = time.time()
    try:
        batch, terms = get_batch(context, request)
    except ParseError, e:
        error = 'Error: %s' % e
开发者ID:cguardia,项目名称:karl,代码行数:68,代码来源:search.py


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