本文整理汇总了Python中taiga.base.utils.urls.get_absolute_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_absolute_url函数的具体用法?Python get_absolute_url怎么用?Python get_absolute_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_absolute_url函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_big_photo_url
def get_big_photo_url(photo):
"""Get a big photo absolute url and the photo automatically cropped."""
try:
url = get_thumbnailer(photo)[settings.THN_AVATAR_BIG].url
return get_absolute_url(url)
except InvalidImageFormatError as e:
return None
示例2: get_photo_url
def get_photo_url(photo):
"""Get a photo absolute url and the photo automatically cropped."""
try:
url = get_thumbnailer(photo)['avatar'].url
return get_absolute_url(url)
except InvalidImageFormatError as e:
return None
示例3: _get_attachment_thumbnailer_url
def _get_attachment_thumbnailer_url(attachment, thumbnailer_size):
try:
thumb_url = get_thumbnailer(attachment.attached_file)[thumbnailer_size].url
thumb_url = get_absolute_url(thumb_url)
except InvalidImageFormatError:
thumb_url = None
return thumb_url
示例4: get_thumbnail_url
def get_thumbnail_url(file_obj, thumbnailer_size):
try:
path_url = get_thumbnailer(file_obj)[thumbnailer_size].url
thumb_url = get_absolute_url(path_url)
except InvalidImageFormatError:
thumb_url = None
return thumb_url
示例5: get_thumbnail_url
def get_thumbnail_url(file_obj, thumbnailer_size):
thumbnail = get_thumbnail(file_obj, thumbnailer_size)
if not thumbnail:
return None
path_url = thumbnail.url
thumb_url = get_absolute_url(path_url)
return thumb_url
示例6: get_or_generate_config
def get_or_generate_config(project):
config = project.modules_config.config
if config and "github" in config:
g_config = project.modules_config.config["github"]
else:
g_config = {"secret": uuid.uuid4().hex}
url = reverse("github-hook-list")
url = get_absolute_url(url)
url = "%s?project=%s" % (url, project.id)
g_config["webhooks_url"] = url
return g_config
示例7: get_or_generate_config
def get_or_generate_config(project):
config = project.modules_config.config
if config and "bitbucket" in config:
g_config = project.modules_config.config["bitbucket"]
else:
g_config = {"secret": uuid.uuid4().hex, "valid_origin_ips": settings.BITBUCKET_VALID_ORIGIN_IPS}
url = reverse("bitbucket-hook-list")
url = get_absolute_url(url)
url = "%s?project=%s&key=%s" % (url, project.id, g_config["secret"])
g_config["webhooks_url"] = url
return g_config
示例8: get_or_generate_config
def get_or_generate_config(project):
config = project.modules_config.config
if config and "gitlab" in config:
g_config = project.modules_config.config["gitlab"]
else:
g_config = {
"secret": uuid.uuid4().hex,
"valid_origin_ips": settings.GITLAB_VALID_ORIGIN_IPS,
}
url = reverse("gitlab-hook-list")
url = get_absolute_url(url)
url = "{}?project={}&key={}".format(url, project.id, g_config["secret"])
g_config["webhooks_url"] = url
return g_config
示例9: extract_attachments
def extract_attachments(obj) -> list:
for attach in obj.attachments.all():
try:
thumb_url = get_thumbnailer(attach.attached_file)['timeline-image'].url
thumb_url = get_absolute_url(thumb_url)
except InvalidImageFormatError as e:
thumb_url = None
yield {"id": attach.id,
"filename": os.path.basename(attach.attached_file.name),
"url": attach.attached_file.url,
"thumb_url": thumb_url,
"is_deprecated": attach.is_deprecated,
"description": attach.description,
"order": attach.order}
示例10: get_thumbnail_url
def get_thumbnail_url(file_obj, thumbnailer_size):
# Ugly hack to temporary ignore tiff files
relative_name = file_obj
if isinstance(file_obj, FieldFile):
relative_name = file_obj.name
source_extension = os.path.splitext(relative_name)[1][1:]
if source_extension == "tiff":
return None
try:
path_url = get_thumbnailer(file_obj)[thumbnailer_size].url
thumb_url = get_absolute_url(path_url)
except InvalidImageFormatError:
thumb_url = None
return thumb_url
示例11: get_gravatar_url
def get_gravatar_url(email: str, **options) -> str:
"""Get the gravatar url associated to an email.
:param options: Additional options to gravatar.
- `default` defines what image url to show if no gravatar exists
- `size` defines the size of the avatar.
By default the `settings.GRAVATAR_DEFAULT_OPTIONS` are used.
:return: Gravatar url.
"""
defaults = settings.GRAVATAR_DEFAULT_OPTIONS.copy()
default = defaults.get("default", None)
if default:
defaults["default"] = get_absolute_url(default)
defaults.update(options)
email_hash = hashlib.md5(email.lower().encode()).hexdigest()
url = GRAVATAR_BASE_URL.format(email_hash, urlencode(defaults))
return url
示例12: test_get_absolute_url
def test_get_absolute_url():
site = sites.get_current()
assert get_absolute_url("http://domain/path") == "http://domain/path"
assert get_absolute_url("/path") == build_url("/path", domain=site.domain, scheme=site.scheme)
示例13: get_photo_url
def get_photo_url(photo):
"""Get a photo absolute url and the photo automatically cropped."""
url = get_thumbnailer(photo)['avatar'].url
return get_absolute_url(url)