本文整理汇总了Python中karl.views.api.TemplateAPI.is_taggable方法的典型用法代码示例。如果您正苦于以下问题:Python TemplateAPI.is_taggable方法的具体用法?Python TemplateAPI.is_taggable怎么用?Python TemplateAPI.is_taggable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karl.views.api.TemplateAPI
的用法示例。
在下文中一共展示了TemplateAPI.is_taggable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_blogentry_view
# 需要导入模块: from karl.views.api import TemplateAPI [as 别名]
# 或者: from karl.views.api.TemplateAPI import is_taggable [as 别名]
def show_blogentry_view(context, request):
post_url = resource_url(context, request, "comments", "add_comment.html")
workflow = get_workflow(IBlogEntry, 'security', context)
if workflow is None:
security_states = []
else:
security_states = get_security_states(workflow, context, request)
page_title = context.title
api = TemplateAPI(context, request, page_title)
client_json_data = dict(
tagbox=get_tags_client_data(context, request))
actions = []
if has_permission('edit', context, request):
actions.append(('Edit', 'edit.html'))
if has_permission('edit', context, request):
actions.append(('Delete', 'delete.html'))
if has_permission('administer', context, request):
actions.append(('Advanced', 'advanced.html'))
api.is_taggable = True
byline_info = getMultiAdapter((context, request), IBylineInfo)
blog = find_interface(context, IBlog)
backto = {
'href': resource_url(blog, request),
'title': blog.title,
}
comments = get_comment_data(context, context['comments'], api, request)
comment_form = get_comment_form(context, context['comments'], api, request)
return dict(
api=api,
actions=actions,
comments=comments,
attachments=fetch_attachments(
context['attachments'], request),
head_data=convert_to_script(client_json_data),
comment_form=comment_form,
post_url=post_url,
byline_info=byline_info,
backto=backto,
security_states=security_states,
)
示例2: show_blogentry_view
# 需要导入模块: from karl.views.api import TemplateAPI [as 别名]
# 或者: from karl.views.api.TemplateAPI import is_taggable [as 别名]
def show_blogentry_view(context, request):
post_url = resource_url(context, request, "comments", "add_comment.html")
karldates = getUtility(IKarlDates)
profiles = find_profiles(context)
workflow = get_workflow(IBlogEntry, 'security', context)
if workflow is None:
security_states = []
else:
security_states = get_security_states(workflow, context, request)
# Convert blog comments into a digestable form for the template
comments = []
page_title = context.title
api = TemplateAPI(context, request, page_title)
for comment in context['comments'].values():
profile = profiles.get(comment.creator)
author_name = profile.title
author_url = resource_url(profile, request)
newc = {}
newc['id'] = comment.__name__
if has_permission('edit', comment, request):
newc['edit_url'] = resource_url(comment, request, 'edit.html')
else:
newc['edit_url'] = None
if has_permission('delete', comment, request):
newc['delete_url'] = resource_url(comment, request, 'delete.html')
else:
newc['delete_url'] = None
if has_permission('administer', comment, request):
newc['advanced_url'] = resource_url(comment, request, 'advanced.html')
else:
newc['advanced_url'] = None
# Display portrait
photo = profile.get('photo')
if photo is not None:
photo_url = thumb_url(photo, request, PROFILE_THUMB_SIZE)
else:
photo_url = api.static_url + "/images/defaultUser.gif"
newc["portrait_url"] = photo_url
newc['author_url'] = author_url
newc['author_name'] = author_name
newc['date'] = karldates(comment.created, 'longform')
newc['timestamp'] = comment.created
newc['text'] = comment.text
# Fetch the attachments info
newc['attachments'] = fetch_attachments(comment, request)
comments.append(newc)
comments.sort(key=lambda c: c['timestamp'])
client_json_data = dict(
tagbox = get_tags_client_data(context, request),
)
actions = []
if has_permission('edit', context, request):
actions.append(('Edit', 'edit.html'))
if has_permission('edit', context, request):
actions.append(('Delete', 'delete.html'))
if has_permission('administer', context, request):
actions.append(('Advanced', 'advanced.html'))
api.is_taggable = True
byline_info = getMultiAdapter((context, request), IBylineInfo)
blog = find_interface(context, IBlog)
backto = {
'href': resource_url(blog, request),
'title': blog.title,
}
# manually construct formish comment form
controller = AddCommentFormController(context['comments'], request)
form_schema = schemaish.Structure()
form_fields = controller.form_fields()
for fieldname, field in form_fields:
form_schema.add(fieldname, field)
form_action_url = '%sadd_comment.html' % resource_url(context['comments'],
request)
comment_form = Form(form_schema, add_default_action=False, name='save',
action_url=form_action_url)
form_defaults = controller.form_defaults()
comment_form.defaults = form_defaults
request.form_defaults = form_defaults
form_actions = [FormAction('submit', 'submit'),
FormAction('cancel', 'cancel', validate=False)]
for action in form_actions:
comment_form.add_action(action.name, action.title)
widgets = controller.form_widgets(form_fields)
#.........这里部分代码省略.........
示例3: show_blogentry_view
# 需要导入模块: from karl.views.api import TemplateAPI [as 别名]
# 或者: from karl.views.api.TemplateAPI import is_taggable [as 别名]
def show_blogentry_view(context, request):
post_url = model_url(context, request, "comments", "add_comment.html")
karldates = getUtility(IKarlDates)
profiles = find_profiles(context)
workflow = get_workflow(IBlogEntry, 'security', context)
if workflow is None:
security_states = []
else:
security_states = get_security_states(workflow, context, request)
# Convert blog comments into a digestable form for the template
comments = []
page_title = context.title
api = TemplateAPI(context, request, page_title)
for comment in context['comments'].values():
profile = profiles.get(comment.creator)
author_name = profile.title
author_url = model_url(profile, request)
newc = {}
newc['id'] = comment.__name__
if has_permission('edit', comment, request):
newc['edit_url'] = model_url(comment, request, 'edit.html')
else:
newc['edit_url'] = None
if has_permission('delete', comment, request):
newc['delete_url'] = model_url(comment, request, 'delete.html')
else:
newc['delete_url'] = None
# Display portrait
photo = profile.get_photo()
photo_url = {}
if photo is not None:
photo_url = model_url(photo, request)
else:
photo_url = api.static_url + "/images/defaultUser.gif"
newc["portrait_url"] = photo_url
newc['author_url'] = author_url
newc['author_name'] = author_name
newc['date'] = karldates(comment.created, 'longform')
newc['timestamp'] = comment.created
newc['text'] = comment.text
# Fetch the attachments info
newc['attachments'] = fetch_attachments(comment, request)
comments.append(newc)
comments.sort(key=lambda c: c['timestamp'])
client_json_data = dict(
tagbox = get_tags_client_data(context, request),
)
actions = []
if has_permission('edit', context, request):
actions.append(('Edit', 'edit.html'))
if has_permission('edit', context, request):
actions.append(('Delete', 'delete.html'))
api.is_taggable = True
byline_info = getMultiAdapter((context, request), IBylineInfo)
blog = find_interface(context, IBlog)
backto = {
'href': model_url(blog, request),
'title': blog.title,
}
return render_template_to_response(
'templates/show_blogentry.pt',
api=api,
actions=actions,
comments=comments,
attachments=fetch_attachments(context['attachments'], request),
head_data=convert_to_script(client_json_data),
formfields=api.formfields,
post_url=post_url,
byline_info=byline_info,
backto=backto,
security_states = security_states,
)