本文整理汇总了Python中taiga.front.templatetags.functions.resolve函数的典型用法代码示例。如果您正苦于以下问题:Python resolve函数的具体用法?Python resolve怎么用?Python resolve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolve函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run
def run(self, root):
links = root.getiterator("a")
for a in links:
href = a.get("href", "")
if SLUG_RE.search(href):
# [wiki](wiki_page) -> <a href="FRONT_HOST/.../wiki/wiki_page" ...
url = resolve("wiki", self.project.slug, href)
a.set("href", url)
a.set("class", "reference wiki")
elif href and href[0] == "/":
# [some link](/some/link) -> <a href="FRONT_HOST/some/link" ...
url = "{}{}".format(resolve("home"), href[1:])
a.set("href", url)
开发者ID:cubettech,项目名称:taiga-back,代码行数:15,代码来源:wikilinks.py
示例2: handleMatch
def handleMatch(self, m):
obj_ref = m.group(2)
instance = get_instance_by_ref(self.project.id, obj_ref)
if instance is None or instance.content_object is None:
return "#{}".format(obj_ref)
subject = instance.content_object.subject
if instance.content_type.model == "epic":
html_classes = "reference epic"
elif instance.content_type.model == "userstory":
html_classes = "reference user-story"
elif instance.content_type.model == "task":
html_classes = "reference task"
elif instance.content_type.model == "issue":
html_classes = "reference issue"
else:
return "#{}".format(obj_ref)
url = resolve(instance.content_type.model, self.project.slug, obj_ref)
link_text = "#{}".format(obj_ref)
a = etree.Element('a')
a.text = link_text
a.set('href', url)
a.set('title', "#{} {}".format(obj_ref, subject))
a.set('class', html_classes)
self.md.extracted_data['references'].append(instance.content_object)
return a
开发者ID:taigaio,项目名称:taiga-back,代码行数:33,代码来源:references.py
示例3: run
def run(self, root):
home_url = resolve("home")
links = root.getiterator("a")
for a in links:
href = a.get("href", "")
url = a.get("href", "")
if url.endswith("/"):
url = url[:-1]
if not url.startswith(home_url):
a.set("target", "_blank")
开发者ID:cubettech,项目名称:taiga-back,代码行数:11,代码来源:target_link.py
示例4: handleMatch
def handleMatch(self, m):
label = m.group(2).strip()
url = resolve("wiki", self.project.slug, slugify(label))
if m.group(3):
title = m.group(3).strip()[1:]
else:
title = label
a = etree.Element("a")
a.text = title
a.set("href", url)
a.set("title", title)
a.set("class", "reference wiki")
return a
开发者ID:cubettech,项目名称:taiga-back,代码行数:15,代码来源:wikilinks.py
示例5: location
def location(self, obj):
return resolve(obj["url_key"])
开发者ID:andrewchenshx,项目名称:taiga-back,代码行数:2,代码来源:generics.py
示例6: location
def location(self, obj):
return resolve("user", obj.username)
开发者ID:spetpet,项目名称:taiga-back,代码行数:2,代码来源:users.py
示例7: location
def location(self, obj):
return resolve("kanban", obj.slug)
开发者ID:spetpet,项目名称:taiga-back,代码行数:2,代码来源:projects.py
示例8: location
def location(self, obj):
return resolve("taskboard", obj.project.slug, obj.slug)
开发者ID:spetpet,项目名称:taiga-back,代码行数:2,代码来源:milestones.py
示例9: location
def location(self, obj):
return resolve("userstory", obj.project.slug, obj.ref)
开发者ID:cubettech,项目名称:taiga-back,代码行数:2,代码来源:userstories.py
示例10: emit_live_notification_for_model
def emit_live_notification_for_model(obj, user, history, *, type:str="change", channel:str="events",
sessionid:str="not-existing"):
"""
Sends a model live notification to users.
"""
if obj._importing:
return None
content_type = get_typename_for_model_instance(obj)
if content_type == "userstories.userstory":
if history.type == HistoryType.create:
title = _("User story created")
url = resolve("userstory", obj.project.slug, obj.ref)
elif history.type == HistoryType.change:
title = _("User story changed")
url = resolve("userstory", obj.project.slug, obj.ref)
else:
title = _("User story deleted")
url = None
body = _("US #{} - {}").format(obj.ref, obj.subject)
elif content_type == "tasks.task":
if history.type == HistoryType.create:
title = _("Task created")
url = resolve("task", obj.project.slug, obj.ref)
elif history.type == HistoryType.change:
title = _("Task changed")
url = resolve("task", obj.project.slug, obj.ref)
else:
title = _("Task deleted")
url = None
body = _("Task #{} - {}").format(obj.ref, obj.subject)
elif content_type == "issues.issue":
if history.type == HistoryType.create:
title = _("Issue created")
url = resolve("issue", obj.project.slug, obj.ref)
elif history.type == HistoryType.change:
title = _("Issue changed")
url = resolve("issue", obj.project.slug, obj.ref)
else:
title = _("Issue deleted")
url = None
body = _("Issue: #{} - {}").format(obj.ref, obj.subject)
elif content_type == "wiki.wiki_page":
if history.type == HistoryType.create:
title = _("Wiki Page created")
url = resolve("wiki", obj.project.slug, obj.slug)
elif history.type == HistoryType.change:
title = _("Wiki Page changed")
url = resolve("wiki", obj.project.slug, obj.slug)
else:
title = _("Wiki Page deleted")
url = None
body = _("Wiki Page: {}").format(obj.slug)
elif content_type == "milestones.milestone":
if history.type == HistoryType.create:
title = _("Sprint created")
url = resolve("taskboard", obj.project.slug, obj.slug)
elif history.type == HistoryType.change:
title = _("Sprint changed")
url = resolve("taskboard", obj.project.slug, obj.slug)
else:
title = _("Sprint deleted")
url = None
body = _("Sprint: {}").format(obj.name)
else:
return None
return emit_event(
{
"title": title,
"body": "Project: {}\n{}".format(obj.project.name, body),
"url": url,
"timeout": 10000,
"id": history.id
},
"live_notifications.{}".format(user.id),
sessionid=sessionid
)
开发者ID:taigaio,项目名称:taiga-back,代码行数:79,代码来源:events.py
注:本文中的taiga.front.templatetags.functions.resolve函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论