当前位置: 首页>>代码示例>>Python>>正文


Python services.get_photo_or_gravatar_url函数代码示例

本文整理汇总了Python中taiga.users.services.get_photo_or_gravatar_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_photo_or_gravatar_url函数的具体用法?Python get_photo_or_gravatar_url怎么用?Python get_photo_or_gravatar_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_photo_or_gravatar_url函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_slackhook

def create_slackhook(url, channel, obj):
    obj_type = _get_type(obj)

    template = loader.get_template('taiga_contrib_slack/create.jinja')
    context = Context({"obj": obj, "obj_type": obj_type})
    description = getattr(obj, 'description', '-')

    data = {
        "text": template.render(context),
        "attachments": [{
            "color": "good",
            "fields": [{
                "title": "Creator",
                "value": obj.owner.get_full_name(),
                "short": True,
            }]
        }]
    }
    if description:
        data["attachments"][0]["fields"].append({
            "title": "Description",
            "value": description,
            "short": False,
        })

    if channel:
        data["channel"] = channel

    data["username"] = "{} ({})".format(getattr(settings, "SLACKHOOKS_USERNAME", "Taiga"), obj.owner.get_full_name())
    data["icon_url"] = get_photo_or_gravatar_url(obj.owner)
    if not data["icon_url"].startswith("http"):
        data["icon_url"] = "https:{}".format(data["icon_url"])
    _send_request(url, data)
开发者ID:vuchau,项目名称:taiga-contrib-slack,代码行数:33,代码来源:tasks.py

示例2: delete_slackhook

def delete_slackhook(url, channel, notify_config, obj, change):
    obj_type = _get_type(obj)

    if not _check_notify_permission(notify_config, obj_type, 'delete'):
        return

    template = loader.get_template('taiga_contrib_slack/delete.jinja')
    context = Context({"obj": obj, "obj_type": obj_type})
    description = getattr(obj, 'description', '-')

    data = {
        "text": template.render(context),
        "attachments": [{
            "color": "danger",
            "fields": [{
                "title": "Description",
                "value": description,
                "short": False,
            }]
        }]
    }

    if channel:
        data["channel"] = channel

    data["username"] = "{} ({})".format(getattr(settings, "SLACKHOOKS_USERNAME", "Taiga"), change.user['name'])
    try:
        user = User.objects.get(pk=change.user['pk'])
        data["icon_url"] = get_photo_or_gravatar_url(user)
        if not data["icon_url"].startswith("http"):
            data["icon_url"] = "https:{}".format(data["icon_url"])
    except User.DoesNotExist:
        data["icon_url"] = getattr(settings, "SLACKHOOKS_ICON", "https://tree.taiga.io/images/favicon.png")
    _send_request(url, data)
开发者ID:deviotours,项目名称:taiga-contrib-slack,代码行数:34,代码来源:tasks.py

示例3: extract_user_info

def extract_user_info(instance):
    return {
        "id": instance.pk,
        "name": instance.get_full_name(),
        "photo": get_photo_or_gravatar_url(instance),
        "big_photo": get_big_photo_or_gravatar_url(instance),
        "username": instance.username,
    }
开发者ID:benzaku,项目名称:taiga-back,代码行数:8,代码来源:service.py

示例4: change_slackhook

def change_slackhook(url, channel, notify_config, obj, change):
    obj_type = _get_type(obj)

    if not _check_notify_permission(notify_config, obj_type, 'change'):
        return

    template_change = loader.get_template('taiga_contrib_slack/change.jinja')
    comment = re.sub(LINK_RE, _link_transform, change.comment)
    context = Context({"obj": obj, "obj_type": obj_type, "change": change, "comment": comment})

    change_text = template_change.render(context)
    data = {"text": change_text.strip()}
    data['attachments'] = []

    if channel:
        data["channel"] = channel

    # Get markdown fields
    if change.diff:
        template_field = loader.get_template('taiga_contrib_slack/field-diff.jinja')
        included_fields = ["description", "content", "blocked_note"]

        for field_name, values in change.diff.items():
            if field_name in included_fields:
                attachment = _markdown_field_to_attachment(template_field, field_name, values)

                data['attachments'].append(attachment)

    # Get rest of fields
    if change.values_diff:
        template_field = loader.get_template('taiga_contrib_slack/field-diff.jinja')
        excluded_fields = ["description_diff", "description_html", "content_diff",
                           "content_html", "blocked_note_diff", "blocked_note_html",
                           "backlog_order", "kanban_order", "taskboard_order", "us_order",
                           "finish_date", "is_closed"]

        for field_name, values in change.values_diff.items():
            if field_name in excluded_fields:
                continue

            attachment = _field_to_attachment(template_field, field_name, values)

            if attachment:
                data['attachments'].append(attachment)

    data["username"] = "{} ({})".format(getattr(settings, "SLACKHOOKS_USERNAME", "Taiga"), change.user['name'])
    try:
        user = User.objects.get(pk=change.user['pk'])
        data["icon_url"] = get_photo_or_gravatar_url(user)
        if not data["icon_url"].startswith("http"):
            data["icon_url"] = "https:{}".format(data["icon_url"])
    except User.DoesNotExist:
        data["icon_url"] = getattr(settings, "SLACKHOOKS_ICON", "https://tree.taiga.io/images/favicon.png")
    _send_request(url, data)
开发者ID:deviotours,项目名称:taiga-contrib-slack,代码行数:54,代码来源:tasks.py

示例5: get_user

    def get_user(self, entry):
        user = {"pk": None, "username": None, "name": None, "photo": None, "is_active": False}
        user.update(entry.user)

        user["photo"] = get_photo_or_gravatar_url(entry.owner)
        user["is_active"] = entry.owner.is_active

        if entry.owner.is_active or entry.owner.is_system:
            user["name"] = entry.owner.get_full_name()
            user["username"] = entry.owner.username

        return user
开发者ID:al42and,项目名称:taiga-back,代码行数:12,代码来源:serializers.py

示例6: test_slackhook

def test_slackhook(url, channel):
    data = {
        "text": "Test slack message",
    }

    if channel:
        data["channel"] = channel

    data["username"] = getattr(settings, "SLACKHOOKS_USERNAME", "Taiga")
    try:
        user = User.objects.get(pk=change.user['pk'])
        data["icon_url"] = get_photo_or_gravatar_url(user)
    except User.DoesNotExist:
        data["icon_url"] = getattr(settings, "SLACKHOOKS_ICON", "https://tree.taiga.io/images/favicon.png")
    _send_request(url, data)
开发者ID:vuchau,项目名称:taiga-contrib-slack,代码行数:15,代码来源:tasks.py

示例7: create_slackhook

def create_slackhook(url, channel, notify_config, obj):
    obj_type = _get_type(obj)

    if not _check_notify_permission(notify_config, obj_type, 'create'):
        return

    template = loader.get_template('taiga_contrib_slack/create.jinja')
    context = Context({"obj": obj, "obj_type": obj_type})
    data = {
        "text": template.render(context.flatten()),
        "attachments": [{
            "color": "good",
            "fields": [{
                "title": "Creator",
                "value": obj.owner.get_full_name(),
                "short": True,
            }]
        }]
    }

    if obj_type == "wikipage":
        # For wikipages
        content = getattr(obj, 'content', '-')
        if content:
            data["attachments"][0]["fields"].append({
                "title": "Content",
                "value": content,
                "short": False,
            })
    else:
        # For stories, tasks and issues
        description = getattr(obj, 'description', '-')
        if description:
            data["attachments"][0]["fields"].append({
                "title": "Description",
                "value": description,
                "short": False,
            })

    if channel:
        data["channel"] = channel

    data["username"] = "{} ({})".format(getattr(settings, "SLACKHOOKS_USERNAME", "Taiga"), obj.owner.get_full_name())
    data["icon_url"] = get_photo_or_gravatar_url(obj.owner)
    if not data["icon_url"].startswith("http"):
        data["icon_url"] = "https:{}".format(data["icon_url"])
    _send_request(url, data)
开发者ID:ansarbek,项目名称:taiga-contrib-slack,代码行数:47,代码来源:tasks.py

示例8: to_native

    def to_native(self, obj):
        #Updates the data user info saved if the user exists
        User = apps.get_model("users", "User")
        userData = obj.get("user", None)
        if userData:
            try:
                user = User.objects.get(id=userData["id"])
                obj["user"] = {
                    "id": user.pk,
                    "name": user.get_full_name(),
                    "photo": get_photo_or_gravatar_url(user),
                    "big_photo": get_big_photo_or_gravatar_url(user),
                    "username": user.username,
                }
            except User.DoesNotExist:
                pass

        return obj
开发者ID:SashaBorandi,项目名称:taiga-back,代码行数:18,代码来源:serializers.py

示例9: get_data

    def get_data(self, obj):
        #Updates the data user info saved if the user exists
        if hasattr(obj, "_prefetched_user"):
            user = obj._prefetched_user
        else:
            User = apps.get_model("users", "User")
            userData = obj.data.get("user", None)
            try:
                user = User.objects.get(id=userData["id"])
            except User.DoesNotExist:
                user = None

        if user is not None:
            obj.data["user"] = {
                "id": user.pk,
                "name": user.get_full_name(),
                "photo": get_photo_or_gravatar_url(user),
                "big_photo": get_big_photo_or_gravatar_url(user),
                "username": user.username,
                "is_profile_visible": user.is_active and not user.is_system,
                "date_joined": user.date_joined
            }

        return obj.data
开发者ID:spetpet,项目名称:taiga-back,代码行数:24,代码来源:serializers.py

示例10: get_photo

 def get_photo(self, membership):
     return get_photo_or_gravatar_url(membership.user)
开发者ID:SKOx0,项目名称:taiga-back,代码行数:2,代码来源:serializers.py

示例11: get_photo

 def get_photo(self, obj):
     return get_photo_or_gravatar_url(obj)
开发者ID:74Labs,项目名称:taiga-back,代码行数:2,代码来源:serializers.py


注:本文中的taiga.users.services.get_photo_or_gravatar_url函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。