本文整理汇总了Python中vilya.models.project_issue.ProjectIssue.get方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectIssue.get方法的具体用法?Python ProjectIssue.get怎么用?Python ProjectIssue.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vilya.models.project_issue.ProjectIssue
的用法示例。
在下文中一共展示了ProjectIssue.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_issue_comment_by_uid
# 需要导入模块: from vilya.models.project_issue import ProjectIssue [as 别名]
# 或者: from vilya.models.project_issue.ProjectIssue import get [as 别名]
def _get_issue_comment_by_uid(uid):
issue = {}
# uid: issue-type-id-number
if uid and uid.startswith('issue-'):
fields = uid.split('-')
if len(fields) != 6:
return issue
_, _, type, id, number, comment_number = fields
if type == 'project':
_issue = ProjectIssue.get(id, number=number)
_issue = Issue.get_cached_issue(_issue.issue_id)
_target = _get_project_by_name(_issue.target.name)
elif type == 'team':
_issue = TeamIssue.get(id, number=number)
_issue = Issue.get_cached_issue(_issue.issue_id)
_target = _get_team_by_uid(_issue.target.uid)
else:
return issue
_author = _get_user_by_name(_issue.creator_id)
_closer = _get_user_by_name(_issue.closer_id) if _issue.closer_id else {}
issue = dict(
id=_issue.issue_id,
name=_issue.title,
author=_author,
closer=_closer,
)
issue[_issue.target_type] = _target
return issue
示例2: _q_lookup
# 需要导入模块: from vilya.models.project_issue import ProjectIssue [as 别名]
# 或者: from vilya.models.project_issue.ProjectIssue import get [as 别名]
def _q_lookup(self, request, issue_number):
repo = self.repo
issue = ProjectIssue.get(project_id=repo.id,
number=issue_number)
if not issue:
raise api_errors.NotFoundError('project issue')
return IssueUI(request, repo, issue)
示例3: __init__
# 需要导入模块: from vilya.models.project_issue import ProjectIssue [as 别名]
# 或者: from vilya.models.project_issue.ProjectIssue import get [as 别名]
def __init__(self, proj_name, issue_number):
self.target = CodeDoubanProject.get_by_name(proj_name)
self.issue_number = issue_number
project_issue = ProjectIssue.get(self.target.id,
number=self.issue_number)
self.issue_id = project_issue.issue_id
self.issue = Issue.get_cached_issue(self.issue_id)
self.issue_template = 'issue/issue.html'
示例4: test_get_issue
# 需要导入模块: from vilya.models.project_issue import ProjectIssue [as 别名]
# 或者: from vilya.models.project_issue.ProjectIssue import get [as 别名]
def test_get_issue(self):
p = ProjectIssue.add('test', 'test description', 'test', project=1)
r = ProjectIssue.get(p.project_id, issue_id=p.issue_id)
assert isinstance(r, ProjectIssue)
assert r.project_id == 1
r = ProjectIssue.get(p.project_id, number=p.number)
assert isinstance(r, ProjectIssue)
assert r.project_id == 1
r = Issue.get_cached_issue(p.issue_id)
assert isinstance(r, ProjectIssue)
assert r.title == 'test'
assert r.description == 'test description'
assert r.project_id == 1
p2 = ProjectIssue.add(
'test2', 'test2 description', 'test', project=1,
assignee='assignee')
p3 = ProjectIssue.add(
'test3', 'test3 description', 'test', project=1,
assignee='assignee')
p4 = ProjectIssue.add(
'test4', 'test4 description', 'test', project=1, assignee='test')
p5 = ProjectIssue.add(
'test5', 'test5 description', 'test1', project=2, assignee='test')
rs = ProjectIssue._gets_by_project_id(1)
assert len(rs) == 4
rs = ProjectIssue._get_issues_by_project_id(1)
assert all([isinstance(i, ProjectIssue) for i in rs])
assert len(rs) == 4
rs = ProjectIssue.gets_by_assignee_id(1, 'assignee')
assert all([isinstance(i, ProjectIssue) for i in rs])
assert len(rs) == 2
rs = ProjectIssue.gets_by_creator_id(1, 'test')
assert all([isinstance(i, ProjectIssue) for i in rs])
assert len(rs) == 4
for p in [p, p2, p3, p4, p5]:
p.delete()
示例5: _get_issue_by_project_and_number
# 需要导入模块: from vilya.models.project_issue import ProjectIssue [as 别名]
# 或者: from vilya.models.project_issue.ProjectIssue import get [as 别名]
def _get_issue_by_project_and_number(id, number):
issue = {}
project_issue = ProjectIssue.get(id, number=number)
_issue = Issue.get_cached_issue(project_issue.issue_id)
_author = _get_user_by_name(_issue.creator_id)
_closer = _get_user_by_name(_issue.closer_id) if _issue.closer_id else {}
issue = dict(
id=_issue.issue_id,
name=_issue.title,
author=_author,
closer=_closer,
)
return issue
示例6: test_n_issue
# 需要导入模块: from vilya.models.project_issue import ProjectIssue [as 别名]
# 或者: from vilya.models.project_issue.ProjectIssue import get [as 别名]
def test_n_issue(self):
p1 = ProjectIssue.add(
'test1', 'test1 description', 'test', project=1,
assignee='assignee')
p1.close('test')
p2 = ProjectIssue.add(
'test2', 'test2 description', 'test', project=1,
assignee='assignee')
p2.close('test')
p3 = ProjectIssue.add(
'test3', 'test3 description', 'test', project=1,
assignee='assignee')
p4 = ProjectIssue.add(
'test4', 'test4 description', 'test', project=1,
assignee='test')
p5 = ProjectIssue.add(
'test5', 'test5 description', 'test1', project=2,
assignee='test')
count = ProjectIssue.get_count_by_project_id(1)
assert count == 4
count = ProjectIssue.get_count_by_project_id(1, 'open')
assert count == 2
count = ProjectIssue.get_count_by_project_id(1, 'closed')
assert count == 2
count = ProjectIssue.get_count_by_assignee_id(1, 'assignee')
assert count == 3
count = ProjectIssue.get_count_by_assignee_id(1, 'assignee', 'open')
assert count == 1
count = ProjectIssue.get_count_by_assignee_id(1, 'assignee', 'closed')
assert count == 2
count = ProjectIssue.get_count_by_creator_id(1, 'test')
assert count == 4
count = ProjectIssue.get_count_by_creator_id(1, 'test', 'open')
assert count == 2
count = ProjectIssue.get_count_by_creator_id(1, 'test', 'closed')
assert count == 2
r = ProjectIssue.get(p1.project_id, p1.issue_id)
assert isinstance(r, ProjectIssue)
assert r.n_closed_issues == 2
assert r.n_open_issues == 2
for p in [p1, p2, p3, p4, p5]:
p.delete()
示例7: patch
# 需要导入模块: from vilya.models.project_issue import ProjectIssue [as 别名]
# 或者: from vilya.models.project_issue.ProjectIssue import get [as 别名]
def patch(self, request):
issue = Issue.get_cached_issue(self.project_issue.issue_id)
if self.user.username != issue.creator_id:
raise api_errors.NotTheAuthorError('project issue', 'edit')
data = request.data
state = data.get("state")
if state in ("open", "closed") and state != issue.state:
if state == "open":
issue.open(self.user.username)
else:
issue.close(self.user.username)
title = data.get("title")
title = title if title else issue.title
description = data.get("description")
description = description if description else issue.description
issue.update(title, description)
new_issue = ProjectIssue.get(project_id=self.project.id,
number=self.issue_number)
return new_issue.as_dict()