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


Python ticket.Ticket类代码示例

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


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

示例1: search

 def search(self, request):
     key_word = request.get_form_var('q')
     if not key_word:
         return self._index(request)
     status = request.get_form_var('status')
     user = request.user
     page = request.get_form_var('page', 1)
     project = self.project
     tickets = []
     ticket_len = Ticket.get_count_by_proj_id(project.id)
     search_result = PullRequestSearch.search_a_phrase(
         key_word, project.id, size=ticket_len)
     if search_result and not search_result.get('error'):
         ticket_ids = [id for id, in SearchEngine.decode(
             search_result, ['ticket_id'])]
         tickets = Ticket.gets_by_projectid_and_ticketnumbers(
             project.id, ticket_ids)
         if status == "closed":
             tickets = [t for t in tickets if t.closed]
         else:
             tickets = [t for t in tickets if not t.closed]
     ticket_total_len = len(tickets)
     limit = TICKETS_COUNT_PER_PAGE
     start = TICKETS_COUNT_PER_PAGE * (int(page) - 1)
     tickets = tickets[start:start + limit]
     n_pages = (ticket_total_len - 1) / TICKETS_COUNT_PER_PAGE + 1
     if status == "closed":
         is_closed_tab = True
     else:
         is_closed_tab = False
     open_tab_link = self.open_tab_link
     close_tab_link = self.close_tab_link
     return st('/pull/pulls.html', **locals())
开发者ID:000fan000,项目名称:code,代码行数:33,代码来源:pull.py

示例2: test_ticket_gets_by_proj_and_author

 def test_ticket_gets_by_proj_and_author(self):
     title = 'test title'
     desc = 'test desc'
     author = 'testuser'
     Ticket.add(self.proj1.id, title, desc, author)
     assert Ticket.gets_by_proj_and_author(self.proj1.id, author)
     assert not Ticket.gets_by_proj_and_author(
         self.proj1.id, author='anonuser')
开发者ID:leeccong,项目名称:code,代码行数:8,代码来源:test_ticket.py

示例3: get_tickets

 def get_tickets(self, project, page, closed=False):
     tickets = Ticket.gets_by_proj(
         project.id, closed=closed, limit=TICKETS_COUNT_PER_PAGE,
         start=TICKETS_COUNT_PER_PAGE * (int(page) - 1))
     if closed:
         tickets = sorted(tickets, key=lambda x: x.closed, reverse=True)
     ticket_total_len = Ticket.get_count_by_proj(project.id, closed=closed)
     return tickets, ticket_total_len
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:pull.py

示例4: _q_index

 def _q_index(self, request):
     user = request.user
     team = self.team
     page = request.get_form_var('page', 1)
     tickets = Ticket.gets_by_team_id(
         team.id, limit=TICKETS_COUNT_PER_PAGE,
         start=TICKETS_COUNT_PER_PAGE * (int(page) - 1)) or []
     ticket_total_len = Ticket.get_count_by_team_id(team.id) or 0
     is_closed_tab = False
     n_pages = (ticket_total_len - 1) / TICKETS_COUNT_PER_PAGE + 1
     return st('/teams/team_pulls.html', **locals())
开发者ID:000fan000,项目名称:code,代码行数:11,代码来源:pull.py

示例5: contribution_detail

 def contribution_detail(self, request):
     req_date = request.get_form_var("date")
     if req_date:
         try:
             req_date = dateutil.parser.parse(req_date).astimezone(dateutil.tz.tzoffset("EST", 8 * 3600))
         except ValueError as e:
             return ""
         contributions = UserContributions.get_by_date(self.name, req_date)
         owned = contributions.get("owned_tickets")
         commented = contributions.get("commented_tickets")
         owned_tickets = filter(None, [Ticket.get(id_) for id_ in owned])
         commented_tickets = filter(None, [Ticket.get(comment[0]) for comment in commented])
         return st("people_contribution_detail.html", **locals())
     return ""
开发者ID:leeccong,项目名称:code,代码行数:14,代码来源:people.py

示例6: test_ticket_close

    def test_ticket_close(self):
        # close ticket
        title = 'test title'
        desc = 'test desc'
        author = 'testuser'

        p2_t1 = Ticket.add(self.proj2.id, title, desc, author)
        pullreq2 = PullRequest.open(
            self.proj2_fork, 'master', self.proj2, 'master')
        pullreq2 = pullreq2.insert(p2_t1.ticket_number)

        assert p2_t1.closed is None
        p2_t1.close('testuser')
        assert Ticket.get(p2_t1.id).closed is not None
开发者ID:leeccong,项目名称:code,代码行数:14,代码来源:test_ticket.py

示例7: main

def main():
    rs = store.execute("select id "
                       "from codedouban_ticket")
    for r in rs:
        id, = r
        ticket = Ticket.get(id)
        # update merge
        pullreq = PullRequest.get_by_ticket(ticket)
        author = pullreq.merge_by or pullreq.to_proj.owner_id
        time = pullreq.merge_time
        ticket_id = ticket.id
        id = 0
        if not get_node(author, TICKET_NODE_TYPE_MERGE, id, ticket_id, time) and time:
            print id, author, time, ticket_id
            store.execute("insert into ticket_nodes "
                          "(author, type, type_id, ticket_id, created_at) "
                          "value (%s, %s, %s, %s, %s)",
                          (author, TICKET_NODE_TYPE_MERGE, id, ticket_id, time))
            store.commit()
        # update close
        author = ticket.close_by or ticket.author
        time = ticket.closed
        ticket_id = ticket.id
        id = 0
        if not get_node(author, TICKET_NODE_TYPE_CLOSE, id, ticket_id, time) and time:
            print id, author, time, ticket_id
            store.execute("insert into ticket_nodes "
                          "(author, type, type_id, ticket_id, created_at) "
                          "value (%s, %s, %s, %s, %s)",
                          (author, TICKET_NODE_TYPE_CLOSE, id, ticket_id, time))
            store.commit()
    print "update %s close & merge pulls" % len(rs)
开发者ID:000fan000,项目名称:code,代码行数:32,代码来源:update_ticket.py

示例8: get

    def get(self, request):
        _date_from = None
        _date_to = None
        state = request.get_form_var('state', '')
        author = request.get_form_var('author', '')
        date_from = request.get_form_var('from', '')
        date_to = request.get_form_var('to', '')
        if not state or state == "open":
            closed = False
        else:
            closed = True
        if date_from:
            _date_from = date_from
        if date_to:
            _date_to = date_to

        tickets = Ticket.gets(project_id=self.repo.id,
                              author=author,
                              date_from=_date_from,
                              date_to=_date_to,
                              closed=closed)
        pulls = []
        for t in tickets:
            pull = PullRequest.get_by_proj_and_ticket(self.repo.id,
                                                      t.ticket_number)
            pulls.append(pull.as_dict())
        return pulls
开发者ID:000fan000,项目名称:code,代码行数:27,代码来源:pulls.py

示例9: test_ticket_update_desc

    def test_ticket_update_desc(self):
        title = 'test title'
        desc = 'test desc'
        author = 'testuser'

        p1_t2 = Ticket.add(self.proj1.id, title, desc, author)
        pullreq = PullRequest.open(
            self.proj1_fork, 'master', self.proj1, 'master')
        pullreq = pullreq.insert(p1_t2.ticket_number)

        new_title = 'this is new title'
        new_desc = 'this is new desc!'
        p1_t2.update(new_title, new_desc)
        p1_t2 = Ticket.get(p1_t2.id)
        assert p1_t2.title == new_title
        assert p1_t2.description == new_desc
开发者ID:leeccong,项目名称:code,代码行数:16,代码来源:test_ticket.py

示例10: _q_index

def _q_index(request):
    user = request.user
    if user:
        list_type = request.get_form_var("list_type", "invited")

        n_invited = user.n_open_invited
        n_participated = user.n_open_participated
        n_yours = user.n_user_open_submit_pull_requests
        counts = [n_invited, n_participated, n_yours, None]
        tab_info = []
        for tab, count in zip(MY_PULL_REQUESTS_TAB_INFO, counts):
            tab.update(count=count)
            tab_info.append(tab)

        if list_type == "participated":
            tickets = user.get_participated_pull_requests()
        elif list_type == "yours":
            tickets = user.get_user_submit_pull_requests()
        elif list_type == "explore":
            from vilya.models.ticket import Ticket
            tickets = Ticket.gets_all_opened()
            ticket_total_len = len(tickets)
            shuffle(tickets)
        else:
            tickets = user.get_invited_pull_requests()
        is_closed_tab = False
        ticket_total_len = len(tickets)
        return st('my_pull_requests.html', **locals())
开发者ID:000fan000,项目名称:code,代码行数:28,代码来源:my_pull_requests.py

示例11: async_comment_to_pr

def async_comment_to_pr(data):
    ''' commit comment rewrite to pr '''
    type_ = data.get('type')
    if type_ not in ('commit_comment', 'commit_linecomment'):
        return

    comment = data.get('comment')
    ref = comment.get('ref')
    author = comment.get('author')
    content = comment.get('content')
    proj_id = comment.get('project_id')
    comment_uid = comment.get('comment_uid')
    proj = CodeDoubanProject.get(proj_id)
    prs = proj.open_family_pulls
    anchor = comment_uid

    for pr in prs:
        if ref in pr.get_commits_shas():
            content = COMMENT_TEMPLATE.format(content=content,
                                              domain=DOMAIN,
                                              proj=proj.name,
                                              sha=ref,
                                              anchor=anchor)
            ticket = Ticket.get_by_projectid_and_ticketnumber(
                pr.to_proj.id, pr.ticket_id)
            ticket.add_comment(content, author)
开发者ID:000fan000,项目名称:code,代码行数:26,代码来源:comment_actions.py

示例12: contribution_detail

 def contribution_detail(self, request):
     req_date = request.get_form_var('date')
     if not req_date:
         return {"error": "No datetime"}
     try:
         req_date = dateutil.parser.parse(req_date).astimezone(
             dateutil.tz.tzoffset('EST', 8 * 3600))
     except ValueError:
         return {"error": "Invalid date"}
     contributions = UserContributions.get_by_date(self.user.name, req_date)
     owned = contributions.get('owned_tickets')
     commented = contributions.get('commented_tickets')
     pullreqs = [Ticket.get(id_).as_dict() for id_ in owned]
     participated = [Ticket.get(comment[0]).as_dict()
                     for comment in commented]
     return {"pull requests": pullreqs,
             "participated": participated}
开发者ID:000fan000,项目名称:code,代码行数:17,代码来源:users.py

示例13: test_ticket_count

    def test_ticket_count(self):
        title = 'test title'
        desc = 'test desc'
        author = 'testuser'

        p1_t1 = Ticket.add(self.proj1.id, title, desc, author)
        pullreq1 = PullRequest.open(
            self.proj1_fork, 'master', self.proj1, 'master')
        pullreq1 = pullreq1.insert(p1_t1.ticket_number)

        p1_t2 = Ticket.add(self.proj1.id, title, desc, author)
        pullreq = PullRequest.open(
            self.proj1_fork, 'master', self.proj1, 'master')
        pullreq = pullreq.insert(p1_t2.ticket_number)

        # test ticket count
        assert int(Ticket.get_count_by_proj(self.proj1.id)) == 2
开发者ID:leeccong,项目名称:code,代码行数:17,代码来源:test_ticket.py

示例14: open_pulls

 def open_pulls(self):
     from vilya.models.ticket import Ticket
     from vilya.models.pull import PullRequest
     pulls = [PullRequest.get_by_proj_and_ticket(self.id,
                                                 t.ticket_id)
              for t in Ticket.gets_by_proj(self.id,
                                           limit=9999)]
     return pulls
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:project.py

示例15: __init__

 def __init__(self, project_id, ticket_number, hl_description):
     self.ticket = Ticket.get_by_projectid_and_ticketnumber(
         project_id, ticket_number)
     self.ticket_project = CodeDoubanProject.get(self.ticket.project_id)
     self.author = User(self.ticket.author)
     self.ticket_url = self.ticket.url
     self.hl_description = hl_description if hl_description \
         else self.ticket.description
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:issue_pr_search.py


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