• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python service.mdrender函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: userstory_freezer

def userstory_freezer(us) -> dict:
    rp_cls = apps.get_model("userstories", "RolePoints")
    rpqsd = rp_cls.objects.filter(user_story=us)

    points = {}
    for rp in rpqsd:
        points[str(rp.role_id)] = rp.points_id

    snapshot = {
        "ref": us.ref,
        "owner": us.owner_id,
        "status": us.status_id,
        "is_closed": us.is_closed,
        "finish_date": str(us.finish_date),
        "backlog_order": us.backlog_order,
        "sprint_order": us.sprint_order,
        "kanban_order": us.kanban_order,
        "subject": us.subject,
        "description": us.description,
        "description_html": mdrender(us.project, us.description),
        "assigned_to": us.assigned_to_id,
        "milestone": us.milestone_id,
        "client_requirement": us.client_requirement,
        "team_requirement": us.team_requirement,
        "attachments": extract_attachments(us),
        "tags": us.tags,
        "points": points,
        "from_issue": us.generated_from_issue_id,
        "is_blocked": us.is_blocked,
        "blocked_note": us.blocked_note,
        "blocked_note_html": mdrender(us.project, us.blocked_note),
        "custom_attributes": extract_user_story_custom_attributes(us),
    }

    return snapshot
开发者ID:jinanwang,项目名称:taiga-back,代码行数:35,代码来源:freeze_impl.py


示例2: _import_action

    def _import_action(self, us, action, statuses, options):
        key = make_key_from_model_object(us)
        typename = get_typename_for_model_class(UserStory)
        action_data = self._transform_action_data(us, action, statuses, options)
        if action_data is None:
            return

        change_old = action_data['change_old']
        change_new = action_data['change_new']
        hist_type = action_data['hist_type']
        comment = action_data['comment']
        user = action_data['user']

        diff = make_diff_from_dicts(change_old, change_new)
        fdiff = FrozenDiff(key, diff, {})

        entry = HistoryEntry.objects.create(
            user=user,
            project_id=us.project.id,
            key=key,
            type=hist_type,
            snapshot=None,
            diff=fdiff.diff,
            values=make_diff_values(typename, fdiff),
            comment=comment,
            comment_html=mdrender(us.project, comment),
            is_hidden=False,
            is_snapshot=False,
        )
        HistoryEntry.objects.filter(id=entry.id).update(created_at=action['date'])
        return HistoryEntry.objects.get(id=entry.id)
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:31,代码来源:importer.py


示例3: userstory_freezer

def userstory_freezer(us) -> dict:
    rp_cls = get_model("userstories", "RolePoints")
    rpqsd = rp_cls.objects.filter(user_story=us)

    points = {}
    for rp in rpqsd:
        points[str(rp.role_id)] = rp.points_id

    snapshot = {
        "ref": us.ref,
        "owner": us.owner_id,
        "status": us.status_id,
        "is_closed": us.is_closed,
        "finish_date": us.finish_date,
        "order": us.order,
        "subject": us.subject,
        "description": us.description,
        "description_html": mdrender(us.project, us.description),
        "assigned_to": us.assigned_to_id,
        "milestone": us.milestone_id,
        "client_requirement": us.client_requirement,
        "team_requirement": us.team_requirement,
        "watchers": [x.id for x in us.watchers.all()],
        "attachments": extract_attachments(us),
        "tags": us.tags,
        "points": points,
        "from_issue": us.generated_from_issue_id,
    }

    return snapshot
开发者ID:yamila-moreno,项目名称:taiga-back,代码行数:30,代码来源:freeze_impl.py


示例4: edit_comment

    def edit_comment(self, request, pk):
        obj = self.get_object()
        history_entry_id = request.QUERY_PARAMS.get('id', None)
        history_entry = services.get_history_queryset_by_model_instance(obj).filter(id=history_entry_id).first()
        obj = services.get_instance_from_key(history_entry.key)
        comment = request.DATA.get("comment", None)

        self.check_permissions(request, 'edit_comment', history_entry)

        if history_entry is None:
            return response.NotFound()

        if comment is None:
            return response.BadRequest({"error": _("comment is required")})

        if history_entry.delete_comment_date or history_entry.delete_comment_user:
            return response.BadRequest({"error": _("deleted comments can't be edited")})

        # comment_versions can be None if there are no historic versions of the comment
        comment_versions = history_entry.comment_versions or []
        comment_versions.append({
            "date": history_entry.created_at,
            "comment": history_entry.comment,
            "comment_html": history_entry.comment_html,
            "user": {
                "id": request.user.pk,
            }
        })

        history_entry.edit_comment_date = timezone.now()
        history_entry.comment = comment
        history_entry.comment_html = mdrender(obj.project, comment)
        history_entry.comment_versions = comment_versions
        history_entry.save()
        return response.Ok()
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:35,代码来源:api.py


示例5: _process_edited

 def _process_edited(self, item, comment, comment_github_url):
     histories = HistoryEntry.objects.filter(key="issues.issue:" + str(item.id), comment__contains=comment_github_url)
     
     for history in list(histories):
         history.comment = comment
         history.comment_html = mdrender(item.project, comment)
         history.save()
开发者ID:alvarollmenezes,项目名称:taiga-back,代码行数:7,代码来源:event_hooks.py


示例6: take_snapshot

def take_snapshot(obj:object, *, comment:str="", user=None, delete:bool=False):
    """
    Given any model instance with registred content type,
    create new history entry of "change" type.

    This raises exception in case of object wasn't
    previously freezed.
    """

    key = make_key_from_model_object(obj)
    typename = get_typename_for_model_class(obj.__class__)

    new_fobj = freeze_model_instance(obj)
    old_fobj, need_real_snapshot = get_last_snapshot_for_key(key)

    entry_model = apps.get_model("history", "HistoryEntry")
    user_id = None if user is None else user.id
    user_name = "" if user is None else user.get_full_name()

    # Determine history type
    if delete:
        entry_type = HistoryType.delete
    elif new_fobj and not old_fobj:
        entry_type = HistoryType.create
    elif new_fobj and old_fobj:
        entry_type = HistoryType.change
    else:
        raise RuntimeError("Unexpected condition")

    fdiff = make_diff(old_fobj, new_fobj)

    # If diff and comment are empty, do
    # not create empty history entry
    if (not fdiff.diff and not comment
        and old_fobj is not None
        and entry_type != HistoryType.delete):

        return None

    fvals = make_diff_values(typename, fdiff)

    if len(comment) > 0:
        is_hidden = False
    else:
        is_hidden = is_hidden_snapshot(fdiff)

    kwargs = {
        "user": {"pk": user_id, "name": user_name},
        "key": key,
        "type": entry_type,
        "snapshot": fdiff.snapshot if need_real_snapshot else None,
        "diff": fdiff.diff,
        "values": fvals,
        "comment": comment,
        "comment_html": mdrender(obj.project, comment),
        "is_hidden": is_hidden,
        "is_snapshot": need_real_snapshot,
    }

    return entry_model.objects.create(**kwargs)
开发者ID:AVert,项目名称:taiga-back,代码行数:60,代码来源:services.py


示例7: userstory_freezer

def userstory_freezer(us) -> dict:
    rp_cls = apps.get_model("userstories", "RolePoints")
    rpqsd = rp_cls.objects.filter(user_story=us)

    points = {}
    for rp in rpqsd:
        points[str(rp.role_id)] = rp.points_id

    assigned_users = [u.id for u in us.assigned_users.all()]
    # Due to multiple assignment migration, for new snapshots we add to
    # assigned users a list with the 'assigned to' value
    if us.assigned_to_id and not assigned_users:
        assigned_users = [us.assigned_to_id]

    snapshot = {
        "ref": us.ref,
        "owner": us.owner_id,
        "status": us.status.id if us.status else None,
        "is_closed": us.is_closed,
        "finish_date": str(us.finish_date),
        "backlog_order": us.backlog_order,
        "sprint_order": us.sprint_order,
        "kanban_order": us.kanban_order,
        "subject": us.subject,
        "description": us.description,
        "description_html": mdrender(us.project, us.description),
        "assigned_to": us.assigned_to_id,
        "assigned_users": assigned_users,
        "milestone": us.milestone_id,
        "client_requirement": us.client_requirement,
        "team_requirement": us.team_requirement,
        "attachments": extract_attachments(us),
        "tags": us.tags,
        "points": points,
        "from_issue": us.generated_from_issue_id,
        "from_task": us.generated_from_task_id,
        "is_blocked": us.is_blocked,
        "blocked_note": us.blocked_note,
        "blocked_note_html": mdrender(us.project, us.blocked_note),
        "custom_attributes": extract_user_story_custom_attributes(us),
        "tribe_gig": us.tribe_gig,
        "due_date": str(us.due_date) if us.due_date else None
    }

    return snapshot
开发者ID:taigaio,项目名称:taiga-back,代码行数:45,代码来源:freeze_impl.py


示例8: wikipage_freezer

def wikipage_freezer(wiki) -> dict:
    snapshot = {
        "slug": wiki.slug,
        "owner": wiki.owner_id,
        "content": wiki.content,
        "content_html": mdrender(wiki.project, wiki.content),
        "attachments": extract_attachments(wiki),
    }

    return snapshot
开发者ID:andrewchenshx,项目名称:taiga-back,代码行数:10,代码来源:freeze_impl.py


示例9: issue_freezer

def issue_freezer(issue) -> dict:
    snapshot = {
        "ref": issue.ref,
        "owner": issue.owner_id,
        "status": issue.status_id,
        "priority": issue.priority_id,
        "severity": issue.severity_id,
        "type": issue.type_id,
        "milestone": issue.milestone_id,
        "subject": issue.subject,
        "description": issue.description,
        "description_html": mdrender(issue.project, issue.description),
        "assigned_to": issue.assigned_to_id,
        "attachments": extract_attachments(issue),
        "tags": issue.tags,
        "is_blocked": issue.is_blocked,
        "blocked_note": issue.blocked_note,
        "blocked_note_html": mdrender(issue.project, issue.blocked_note),
        "custom_attributes": extract_issue_custom_attributes(issue),
    }

    return snapshot
开发者ID:andrewchenshx,项目名称:taiga-back,代码行数:22,代码来源:freeze_impl.py


示例10: epic_freezer

def epic_freezer(epic) -> dict:
    snapshot = {
        "ref": epic.ref,
        "color": epic.color,
        "owner": epic.owner_id,
        "status": epic.status.id if epic.status else None,
        "epics_order": epic.epics_order,
        "subject": epic.subject,
        "description": epic.description,
        "description_html": mdrender(epic.project, epic.description),
        "assigned_to": epic.assigned_to_id,
        "client_requirement": epic.client_requirement,
        "team_requirement": epic.team_requirement,
        "attachments": extract_attachments(epic),
        "tags": epic.tags,
        "is_blocked": epic.is_blocked,
        "blocked_note": epic.blocked_note,
        "blocked_note_html": mdrender(epic.project, epic.blocked_note),
        "custom_attributes": extract_epic_custom_attributes(epic)
    }

    return snapshot
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:22,代码来源:freeze_impl.py


示例11: task_freezer

def task_freezer(task) -> dict:
    snapshot = {
        "ref": task.ref,
        "owner": task.owner_id,
        "status": task.status_id,
        "milestone": task.milestone_id,
        "subject": task.subject,
        "description": task.description,
        "description_html": mdrender(task.project, task.description),
        "assigned_to": task.assigned_to_id,
        "attachments": extract_attachments(task),
        "taskboard_order": task.taskboard_order,
        "us_order": task.us_order,
        "tags": task.tags,
        "user_story": task.user_story_id,
        "is_iocaine": task.is_iocaine,
        "is_blocked": task.is_blocked,
        "blocked_note": task.blocked_note,
        "blocked_note_html": mdrender(task.project, task.blocked_note),
        "custom_attributes": extract_task_custom_attributes(task),
    }

    return snapshot
开发者ID:andrewchenshx,项目名称:taiga-back,代码行数:23,代码来源:freeze_impl.py


示例12: render

    def render(self, request, **kwargs):
        content = request.DATA.get("content", None)
        project_id = request.DATA.get("project_id", None)

        if not content:
            raise exc.WrongArguments({"content": _("'content' parameter is mandatory")})

        if not project_id:
            raise exc.WrongArguments({"project_id": _("'project_id' parameter is mandatory")})

        project = get_object_or_404(Project, pk=project_id)

        self.check_permissions(request, "render", project)

        data = mdrender(project, content)
        return response.Ok({"data": data})
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:16,代码来源:api.py


示例13: task_freezer

def task_freezer(task) -> dict:
    snapshot = {
        "ref": task.ref,
        "owner": task.owner_id,
        "status": task.status_id,
        "milestone": task.milestone_id,
        "subject": task.subject,
        "description": task.description,
        "description_html": mdrender(task.project, task.description),
        "assigned_to": task.assigned_to_id,
        "watchers": [x.pk for x in task.watchers.all()],
        "attachments": extract_attachments(task),
        "tags": task.tags,
        "user_story": task.user_story_id,
        "is_iocaine": task.is_iocaine,
    }

    return snapshot
开发者ID:yamila-moreno,项目名称:taiga-back,代码行数:18,代码来源:freeze_impl.py


示例14: issue_freezer

def issue_freezer(issue) -> dict:
    snapshot = {
        "ref": issue.ref,
        "owner": issue.owner_id,
        "status": issue.status_id,
        "priority": issue.priority_id,
        "severity": issue.severity_id,
        "type": issue.type_id,
        "milestone": issue.milestone_id,
        "subject": issue.subject,
        "description": issue.description,
        "description_html": mdrender(issue.project, issue.description),
        "assigned_to": issue.assigned_to_id,
        "watchers": [x.pk for x in issue.watchers.all()],
        "attachments": extract_attachments(issue),
        "tags": issue.tags,
    }

    return snapshot
开发者ID:yamila-moreno,项目名称:taiga-back,代码行数:19,代码来源:freeze_impl.py


示例15: get_blocked_note_html

 def get_blocked_note_html(self, obj):
     return mdrender(obj.project, obj.blocked_note)
开发者ID:david-strejc,项目名称:taiga-back,代码行数:2,代码来源:serializers.py


示例16: _transform_activity_data

    def _transform_activity_data(self, obj, activity, options):
        users_bindings = options.get('users_bindings', {})
        due_date_field = obj.project.userstorycustomattributes.get(name="Due date")
        story_type_field = obj.project.userstorycustomattributes.get(name="Type")

        user = {"pk": None, "name": activity.get('performed_by', {}).get('name', None)}
        taiga_user = users_bindings.get(activity.get('performed_by', {}).get('id', None), None)
        if taiga_user:
            user = {"pk": taiga_user.id, "name": taiga_user.get_full_name()}

        result = {
            "change_old": {},
            "change_new": {},
            "hist_type": HistoryType.change,
            "comment": "",
            "user": user,
            "obj": obj
        }

        if activity['kind'] == "story_create_activity":
            UserStory.objects.filter(id=obj.id, created_date__gt=activity['occurred_at']).update(
                created_date=activity['occurred_at'],
                owner=users_bindings.get(activity["performed_by"]["id"], self._user)
            )
            return None
        elif activity['kind'] == "epic_create_activity":
            Epic.objects.filter(id=obj.id, created_date__gt=activity['occurred_at']).update(
                created_date=activity['occurred_at'],
                owner=users_bindings.get(activity["performed_by"]["id"], self._user)
            )
            return None
        elif activity['kind'] in ["story_update_activity", "epic_update_activity"]:
            for change in activity['changes']:
                if change['change_type'] != "update" or change['kind'] not in ["story", "epic"]:
                    continue

                if 'description' in change['new_values']:
                    result['change_old']["description"] = str(change['original_values']['description'])
                    result['change_new']["description"] = str(change['new_values']['description'])
                    result['change_old']["description_html"] = mdrender(obj.project, str(change['original_values']['description']))
                    result['change_new']["description_html"] = mdrender(obj.project, str(change['new_values']['description']))

                if 'estimate' in change['new_values']:
                    old_points = None
                    if change['original_values']['estimate']:
                        estimation = change['original_values']['estimate']
                        (old_points, _) = Points.objects.get_or_create(
                            project=obj.project,
                            value=estimation,
                            defaults={
                                "name": str(estimation),
                                "order": estimation,
                            }
                        )
                        old_points = old_points.id
                    new_points = None
                    if change['new_values']['estimate']:
                        estimation = change['new_values']['estimate']
                        (new_points, _) = Points.objects.get_or_create(
                            project=obj.project,
                            value=estimation,
                            defaults={
                                "name": str(estimation),
                                "order": estimation,
                            }
                        )
                        new_points = new_points.id
                    result['change_old']["points"] = {obj.project.roles.get(slug="main").id: old_points}
                    result['change_new']["points"] = {obj.project.roles.get(slug="main").id: new_points}

                if 'name' in change['new_values']:
                    result['change_old']["subject"] = change['original_values']['name']
                    result['change_new']["subject"] = change['new_values']['name']

                if 'labels' in change['new_values']:
                    result['change_old']["tags"] = [l.lower() for l in change['original_values']['labels']]
                    result['change_new']["tags"] = [l.lower() for l in change['new_values']['labels']]

                if 'current_state' in change['new_values']:
                    result['change_old']["status"] = obj.project.us_statuses.get(slug=change['original_values']['current_state']).id
                    result['change_new']["status"] = obj.project.us_statuses.get(slug=change['new_values']['current_state']).id

                if 'story_type' in change['new_values']:
                    if "custom_attributes" not in result['change_old']:
                        result['change_old']["custom_attributes"] = []
                    if "custom_attributes" not in result['change_new']:
                        result['change_new']["custom_attributes"] = []

                    result['change_old']["custom_attributes"].append({
                        "name": "Type",
                        "value": change['original_values']['story_type'],
                        "id": story_type_field.id
                    })
                    result['change_new']["custom_attributes"].append({
                        "name": "Type",
                        "value": change['new_values']['story_type'],
                        "id": story_type_field.id
                    })

                if 'deadline' in change['new_values']:
#.........这里部分代码省略.........
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:101,代码来源:importer.py


示例17: get_description_html

 def get_description_html(self, obj):
     return mdrender(obj.project, obj.description)
开发者ID:david-strejc,项目名称:taiga-back,代码行数:2,代码来源:serializers.py


示例18: _transform_action_data

    def _transform_action_data(self, us, action, statuses, options):
        users_bindings = options.get('users_bindings', {})
        due_date_field = us.project.userstorycustomattributes.first()

        ignored_actions = ["addAttachmentToCard", "addMemberToCard",
                           "deleteAttachmentFromCard", "deleteCard",
                           "removeMemberFromCard"]

        if action['type'] in ignored_actions:
            return None

        user = {"pk": None, "name": action.get('memberCreator', {}).get('fullName', None)}
        taiga_user = users_bindings.get(action.get('memberCreator', {}).get('id', None), None)
        if taiga_user:
            user = {"pk": taiga_user.id, "name": taiga_user.get_full_name()}

        result = {
            "change_old": {},
            "change_new": {},
            "hist_type": HistoryType.change,
            "comment": "",
            "user": user
        }

        if action['type'] == "commentCard":
            result['comment'] = str(action['data']['text'])
        elif action['type'] == "convertToCardFromCheckItem":
            UserStory.objects.filter(id=us.id, created_date__gt=action['date']).update(
                created_date=action['date'],
                owner=users_bindings.get(action["idMemberCreator"], self._user)
            )
            result['hist_type'] = HistoryType.create
        elif action['type'] == "copyCommentCard":
            UserStory.objects.filter(id=us.id, created_date__gt=action['date']).update(
                created_date=action['date'],
                owner=users_bindings.get(action["idMemberCreator"], self._user)
            )
            result['hist_type'] = HistoryType.create
        elif action['type'] == "createCard":
            UserStory.objects.filter(id=us.id, created_date__gt=action['date']).update(
                created_date=action['date'],
                owner=users_bindings.get(action["idMemberCreator"], self._user)
            )
            result['hist_type'] = HistoryType.create
        elif action['type'] == "updateCard":
            if 'desc' in action['data']['old']:
                result['change_old']["description"] = str(action['data']['old'].get('desc', ''))
                result['change_new']["description"] = str(action['data']['card'].get('desc', ''))
                result['change_old']["description_html"] = mdrender(us.project, str(action['data']['old'].get('desc', '')))
                result['change_new']["description_html"] = mdrender(us.project, str(action['data']['card'].get('desc', '')))
            if 'idList' in action['data']['old']:
                old_status_name = statuses[action['data']['old']['idList']]['name']
                result['change_old']["status"] = us.project.us_statuses.get(name=old_status_name).id
                new_status_name = statuses[action['data']['card']['idList']]['name']
                result['change_new']["status"] = us.project.us_statuses.get(name=new_status_name).id
            if 'name' in action['data']['old']:
                result['change_old']["subject"] = action['data']['old']['name']
                result['change_new']["subject"] = action['data']['card']['name']
            if 'due' in action['data']['old']:
                result['change_old']["custom_attributes"] = [{
                    "name": "Due",
                    "value": action['data']['old']['due'],
                    "id": due_date_field.id
                }]
                result['change_new']["custom_attributes"] = [{
                    "name": "Due",
                    "value": action['data']['card']['due'],
                    "id": due_date_field.id
                }]

            if result['change_old'] == {}:
                return None
        return result
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:73,代码来源:importer.py


示例19: get_html

 def get_html(self, obj):
     return mdrender(obj.project, obj.content)
开发者ID:marctc,项目名称:taiga-back,代码行数:2,代码来源:serializers.py


示例20: field_from_native

 def field_from_native(self, data, files, field_name, into):
     super().field_from_native(data, files, field_name, into)
     into["comment_html"] = mdrender(self.context['project'], data.get("comment", ""))
开发者ID:SKOx0,项目名称:taiga-back,代码行数:3,代码来源:serializers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python service.render函数代码示例发布时间:2022-05-27
下一篇:
Python functions.resolve函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap