本文整理汇总了Python中tracim.model.data.Content.get_label方法的典型用法代码示例。如果您正苦于以下问题:Python Content.get_label方法的具体用法?Python Content.get_label怎么用?Python Content.get_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.model.data.Content
的用法示例。
在下文中一共展示了Content.get_label方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compare_content_for_sorting_by_type_and_name
# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_label [as 别名]
def compare_content_for_sorting_by_type_and_name(content1: Content,
content2: Content):
"""
:param content1:
:param content2:
:return: 1 if content1 > content2
-1 if content1 < content2
0 if content1 = content2
"""
if content1.type==content2.type:
if content1.get_label().lower()>content2.get_label().lower():
return 1
elif content1.get_label().lower()<content2.get_label().lower():
return -1
return 0
else:
# TODO - D.A. - 2014-12-02 - Manage Content Types Dynamically
content_type_order = [ContentType.Folder, ContentType.Page, ContentType.Thread, ContentType.File]
result = content_type_order.index(content1.type)-content_type_order.index(content2.type)
if result<0:
return -1
elif result>0:
return 1
else:
return 0
示例2: serialize_content_for_general_list
# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_label [as 别名]
def serialize_content_for_general_list(content: Content, context: Context):
content_type = ContentType(content.type)
last_activity_date = content.get_last_activity_date()
last_activity_date_formatted = format_datetime(last_activity_date,
locale=tg.i18n.get_lang()[0])
last_activity_label = format_timedelta(
datetime.utcnow() - last_activity_date,
locale=tg.i18n.get_lang()[0],
)
last_activity_label = last_activity_label.replace(' ', '\u00A0') # espace insécable
return DictLikeClass(
id=content.content_id,
folder = DictLikeClass({'id': content.parent_id}) if content.parent else None,
workspace=context.toDict(content.workspace) if content.workspace else None,
label=content.get_label(),
url=ContentType.fill_url(content),
type=DictLikeClass(content_type.toDict()),
status=context.toDict(content.get_status()),
is_deleted=content.is_deleted,
is_archived=content.is_archived,
is_editable=content.is_editable,
last_activity = DictLikeClass({'date': last_activity_date,
'label': last_activity_date_formatted,
'delta': last_activity_label})
)
示例3: serialize_content_for_menu_api
# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_label [as 别名]
def serialize_content_for_menu_api(content: Content, context: Context):
content_id = content.content_id
workspace_id = content.workspace_id
has_children = False
if content.type == ContentType.Folder:
has_children = content.get_child_nb(ContentType.Any) > 0
result = DictLikeClass(
id = CST.TREEVIEW_MENU.ID_TEMPLATE__FULL.format(workspace_id, content_id),
children = has_children,
text = content.get_label(),
a_attr = { 'href' : context.url(ContentType.fill_url(content))},
li_attr = { 'title': content.get_label(), 'class': 'tracim-tree-item-is-a-folder' },
type = content.type,
state = { 'opened': True if ContentType.Folder!=content.type else False, 'selected': False }
)
return result
示例4: serialize_node_for_thread_list
# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_label [as 别名]
def serialize_node_for_thread_list(content: Content, context: Context):
if content.type==ContentType.Thread:
return DictLikeClass(
id = content.content_id,
url=ContentType.fill_url(content),
label=content.get_label(),
status=context.toDict(content.get_status()),
folder=context.toDict(content.parent),
workspace=context.toDict(content.workspace) if content.workspace else None,
comment_nb=len(content.get_comments())
)
if content.type==ContentType.Folder:
return Context(CTX.DEFAULT).toDict(content)
raise NotImplementedError
示例5: _build_email_body
# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_label [as 别名]
def _build_email_body(self, mako_template_filepath: str, role: UserRoleInWorkspace, content: Content, actor: User) -> str:
"""
Build an email body and return it as a string
:param mako_template_filepath: the absolute path to the mako template to be used for email body building
:param role: the role related to user to whom the email must be sent. The role is required (and not the user only) in order to show in the mail why the user receive the notification
:param content: the content item related to the notification
:param actor: the user at the origin of the action / notification (for example the one who wrote a comment
:param config: the global configuration
:return: the built email body as string. In case of multipart email, this method must be called one time for text and one time for html
"""
logger.debug(self, 'Building email content from MAKO template {}'.format(mako_template_filepath))
template = Template(filename=mako_template_filepath)
# TODO - D.A. - 2014-11-06 - move this
# Import is here for circular import problem
import tracim.lib.helpers as helpers
dictified_item = Context(CTX.EMAIL_NOTIFICATION, self._global_config.WEBSITE_BASE_URL).toDict(content)
dictified_actor = Context(CTX.DEFAULT).toDict(actor)
main_title = dictified_item.label
content_intro = ''
content_text = ''
call_to_action_text = ''
action = content.get_last_action().id
if ActionDescription.COMMENT == action:
content_intro = _('<span id="content-intro-username">{}</span> added a comment:').format(actor.display_name)
content_text = content.description
call_to_action_text = _('Answer')
elif ActionDescription.CREATION == action:
# Default values (if not overriden)
content_text = content.description
call_to_action_text = _('View online')
if ContentType.Thread == content.type:
call_to_action_text = _('Answer')
content_intro = _('<span id="content-intro-username">{}</span> started a thread entitled:').format(actor.display_name)
content_text = '<p id="content-body-intro">{}</p>'.format(content.label) + \
content.get_last_comment_from(actor).description
elif ContentType.File == content.type:
content_intro = _('<span id="content-intro-username">{}</span> added a file entitled:').format(actor.display_name)
if content.description:
content_text = content.description
else:
content_text = '<span id="content-body-only-title">{}</span>'.format(content.label)
elif ContentType.Page == content.type:
content_intro = _('<span id="content-intro-username">{}</span> added a page entitled:').format(actor.display_name)
content_text = '<span id="content-body-only-title">{}</span>'.format(content.label)
elif ActionDescription.REVISION == action:
content_text = content.description
call_to_action_text = _('View online')
if ContentType.File == content.type:
content_intro = _('<span id="content-intro-username">{}</span> uploaded a new revision.').format(actor.display_name)
content_text = ''
elif ContentType.Page == content.type:
content_intro = _('<span id="content-intro-username">{}</span> updated this page.').format(actor.display_name)
previous_revision = content.get_previous_revision()
title_diff = ''
if previous_revision.label != content.label:
title_diff = htmldiff(previous_revision.label, content.label)
content_text = _('<p id="content-body-intro">Here is an overview of the changes:</p>')+ \
title_diff + \
htmldiff(previous_revision.description, content.description)
elif ContentType.Thread == content.type:
content_intro = _('<span id="content-intro-username">{}</span> updated the thread description.').format(actor.display_name)
previous_revision = content.get_previous_revision()
title_diff = ''
if previous_revision.label != content.label:
title_diff = htmldiff(previous_revision.label, content.label)
content_text = _('<p id="content-body-intro">Here is an overview of the changes:</p>')+ \
title_diff + \
htmldiff(previous_revision.description, content.description)
# elif ContentType.Thread == content.type:
# content_intro = _('<span id="content-intro-username">{}</span> updated this page.').format(actor.display_name)
# previous_revision = content.get_previous_revision()
# content_text = _('<p id="content-body-intro">Here is an overview of the changes:</p>')+ \
# htmldiff(previous_revision.description, content.description)
elif ActionDescription.EDITION == action:
call_to_action_text = _('View online')
if ContentType.File == content.type:
content_intro = _('<span id="content-intro-username">{}</span> updated the file description.').format(actor.display_name)
content_text = '<p id="content-body-intro">{}</p>'.format(content.get_label()) + \
content.description
if '' == content_intro and content_text == '':
# Skip notification, but it's not normal
logger.error(
#.........这里部分代码省略.........