本文整理汇总了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)
示例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
示例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")
示例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
示例5: location
def location(self, obj):
return resolve(obj["url_key"])
示例6: location
def location(self, obj):
return resolve("user", obj.username)
示例7: location
def location(self, obj):
return resolve("kanban", obj.slug)
示例8: location
def location(self, obj):
return resolve("taskboard", obj.project.slug, obj.slug)
示例9: location
def location(self, obj):
return resolve("userstory", obj.project.slug, obj.ref)
示例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
)