本文整理汇总了Python中karl.models.interfaces.ICommunity.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python ICommunity.providedBy方法的具体用法?Python ICommunity.providedBy怎么用?Python ICommunity.providedBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karl.models.interfaces.ICommunity
的用法示例。
在下文中一共展示了ICommunity.providedBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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
示例2: redirect_community_view
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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))
示例3: visit
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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))
示例4: tabs
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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
示例5: visit
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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))
示例6: tabs
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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
示例7: community_recent_items_ajax_view
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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}
示例8: community_members_ajax_view
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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}
示例9: redirect_community_view
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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)
示例10: leave_community_view
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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)
示例11: show_community_view
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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,
)
示例12: searchresults_view
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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
示例13: related_communities_ajax_view
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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}
示例14: leave
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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
示例15: searchresults_view
# 需要导入模块: from karl.models.interfaces import ICommunity [as 别名]
# 或者: from karl.models.interfaces.ICommunity import providedBy [as 别名]
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