本文整理汇总了Python中taiga.mdrender.service.mdrender函数的典型用法代码示例。如果您正苦于以下问题:Python mdrender函数的具体用法?Python mdrender怎么用?Python mdrender使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mdrender函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)
示例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
示例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()
示例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()
示例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)
示例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
示例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
示例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
示例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
示例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
示例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})
示例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
示例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
示例15: get_blocked_note_html
def get_blocked_note_html(self, obj):
return mdrender(obj.project, obj.blocked_note)