當前位置: 首頁>>代碼示例>>Python>>正文


Python Issue.get_cached_issue方法代碼示例

本文整理匯總了Python中vilya.models.issue.Issue.get_cached_issue方法的典型用法代碼示例。如果您正苦於以下問題:Python Issue.get_cached_issue方法的具體用法?Python Issue.get_cached_issue怎麽用?Python Issue.get_cached_issue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vilya.models.issue.Issue的用法示例。


在下文中一共展示了Issue.get_cached_issue方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_issue_comment_by_uid

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [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
開發者ID:000fan000,項目名稱:code,代碼行數:30,代碼來源:timeline.py

示例2: test_closed_issue_should_not_vote

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [as 別名]
    def test_closed_issue_should_not_vote(self):
        self.test_team_issue.close(self.testuser1)
        self.test_team_issue = Issue.get_cached_issue(
            self.test_team_issue.issue_id)
        count = self.test_team_issue.upvote_by_user(self.testuser2)
        assert count == 0

        self.test_project_issue.close(self.testuser1)
        self.test_project_issue = Issue.get_cached_issue(
            self.test_project_issue.issue_id)
        count = self.test_project_issue.upvote_by_user(self.testuser2)
        assert count == 0
開發者ID:000fan000,項目名稱:code,代碼行數:14,代碼來源:test_issue_upvote.py

示例3: __init__

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [as 別名]
    def __init__(self, issue_id):
        self.target = get_fair()
        self.issue_number = issue_id  # fair issue 直接拿 issue_id 當 number

        self.issue_id = issue_id
        self.issue = Issue.get_cached_issue(issue_id)
        self.issue_template = 'issue/team_issue.html'
開發者ID:leeccong,項目名稱:code,代碼行數:9,代碼來源:fair.py

示例4: get_by_proj_name_and_number

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [as 別名]
    def get_by_proj_name_and_number(cls, proj_name, number):
        from vilya.models.project import CodeDoubanProject

        project = CodeDoubanProject.get_by_name(proj_name)
        project_issue = cls.get(project.id, number=number)
        issue_id = project_issue.issue_id
        return Issue.get_cached_issue(issue_id)
開發者ID:mozillazg,項目名稱:code,代碼行數:9,代碼來源:project_issue.py

示例5: add

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [as 別名]
 def add(
     cls,
     title,
     description,
     creator,
     number=None,
     team=None,
     project=None,
     assignee=None,
     closer=None,
     created_at=None,
     updated_at=None,
     closed_at=None,
 ):
     issue = Issue.add(
         title, description, creator, assignee=assignee, closer=closer, type=cls.target_type, target_id=project
     )
     if issue and project:
         number = PICounter.incr(project, number)
         store.execute(
             "insert into project_issues (project_id, issue_id, number) " "values (%s, %s, %s) ",
             (project, issue.id, number),
         )
         store.commit()
         mc.delete(MC_KEY_PROJECT_ISSUE_CREATOR_N % (project, creator, "open"))
         mc.delete(MC_KEY_PROJECT_ISSUE_CREATOR_N % (project, creator, "closed"))
         cls._clean_cache(project)
         return Issue.get_cached_issue(issue.id)
開發者ID:mozillazg,項目名稱:code,代碼行數:30,代碼來源:project_issue.py

示例6: __init__

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [as 別名]
    def __init__(self, team_uid, issue_number):
        self.target = Team.get_by_uid(team_uid)
        self.issue_number = issue_number

        team_issue = TeamIssue.get(self.target.id, number=self.issue_number)
        self.issue_id = team_issue.issue_id
        self.issue = Issue.get_cached_issue(self.issue_id)
        self.issue_template = "issue/team_issue.html"
開發者ID:leeccong,項目名稱:code,代碼行數:10,代碼來源:team.py

示例7: __init__

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [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'
開發者ID:000fan000,項目名稱:code,代碼行數:11,代碼來源:issue.py

示例8: delete

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [as 別名]
 def delete(self, request):
     user = request.user
     if self.comment.author_id != user.username:
         raise AccessError
     issue_id = self.comment.issue_id
     ok = self.comment.delete()
     if not ok:
         return {'r': 0}
     pissue = Issue.get_cached_issue(issue_id)
     pissue.update_rank_score()
     return {'r': 1}
開發者ID:000fan000,項目名稱:code,代碼行數:13,代碼來源:issue.py

示例9: _get_issue_by_project_and_number

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [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
開發者ID:000fan000,項目名稱:code,代碼行數:15,代碼來源:timeline.py

示例10: test_get_issue

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [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()
開發者ID:000fan000,項目名稱:code,代碼行數:46,代碼來源:test_project_issue.py

示例11: patch

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [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()
開發者ID:000fan000,項目名稱:code,代碼行數:22,代碼來源:issue.py

示例12: get

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [as 別名]
 def get(cls, team_id, issue_id=None, number=None):
     # FIXME: dirty hack. 需要統一子類和基類的get方法
     if number:
         issue_id = number
     return Issue.get_cached_issue(issue_id)
開發者ID:000fan000,項目名稱:code,代碼行數:7,代碼來源:fair_issue.py

示例13: issue

# 需要導入模塊: from vilya.models.issue import Issue [as 別名]
# 或者: from vilya.models.issue.Issue import get_cached_issue [as 別名]
 def issue(self):
     from vilya.models.issue import Issue
     return Issue.get_cached_issue(self.issue_id)
開發者ID:000fan000,項目名稱:code,代碼行數:5,代碼來源:issue_comment.py


注:本文中的vilya.models.issue.Issue.get_cached_issue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。