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


Python CodeDoubanProject.get_by_name方法代码示例

本文整理汇总了Python中vilya.models.project.CodeDoubanProject.get_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python CodeDoubanProject.get_by_name方法的具体用法?Python CodeDoubanProject.get_by_name怎么用?Python CodeDoubanProject.get_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vilya.models.project.CodeDoubanProject的用法示例。


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

示例1: create

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
    def create(self, request):
        user = request.user
        if not user:
            raise AccessError
        from_proj = request.get_form_var('from_proj')
        from_ref = request.get_form_var('from_ref')
        to_ref = request.get_form_var('to_ref')
        to_proj = request.get_form_var('to_proj')
        title = request.get_form_var('title', '').decode('utf-8')
        comment = request.get_form_var('body', '').decode('utf-8')
        if not all([from_ref, from_proj, to_ref, to_proj]):
            raise TraversalError
        from_proj = CodeDoubanProject.get_by_name(from_proj)
        to_proj = CodeDoubanProject.get_by_name(to_proj)
        if from_proj != to_proj:
            if not from_proj.has_push_perm(user.name):
                raise AccessError(
                    "Need push permission to create PR on another project")

        pullreq = PullRequest.open(from_proj, from_ref, to_proj, to_ref)
        ticket = Ticket(None, None, to_proj.id, title, comment,
                        user.username, None, None)
        pullreq = add_pull(ticket, pullreq, user)
        ticket = pullreq.ticket
        return request.redirect(str('/%s/pull/%s/' % (to_proj.name,
                                                      ticket.ticket_id)))
开发者ID:000fan000,项目名称:code,代码行数:28,代码来源:pull.py

示例2: test_get_forked_from_should_return_origin_project

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
 def test_get_forked_from_should_return_origin_project(self):
     prj = CodeDoubanProject.get_by_name('orig')
     prj.delete()
     prj = CodeDoubanProject.get_by_name('fork')
     prj.delete()
     orig = CodeDoubanProject.add('orig', owner_id="test1")
     fork = orig.fork('fork', 'user2')
     source = fork.get_forked_from()
     eq_(source, orig)
开发者ID:000fan000,项目名称:code,代码行数:11,代码来源:test_fork_project.py

示例3: test_transfer_project

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
 def test_transfer_project(self):
     pname1 = 'project6'
     pname2 = 'project7'
     proj_owner = 'admin_user'
     to_user = 'testuser1'
     p = CodeDoubanProject.add(pname1, owner_id=proj_owner,
                               summary="test", product="fire")
     _ = CodeDoubanProject.add(pname2, owner_id=proj_owner,
                               summary="test", product="fire")
     p.transfer_to(to_user)
     p1 = CodeDoubanProject.get_by_name(pname1)
     assert p1.owner_id == to_user
     p2 = CodeDoubanProject.get_by_name(pname2)
     assert p2.owner_id == proj_owner
开发者ID:000fan000,项目名称:code,代码行数:16,代码来源:test_project.py

示例4: test_project_meta_dict

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
 def test_project_meta_dict(self):
     project_name = "project3"
     owner_id = "testuser"
     summary = "a summary"
     product = "fire"
     project = CodeDoubanProject.add(
         project_name, owner_id, summary, product)
     # hookfile_path = "%s/hooks/post-receive" % project.git_real_path
     project = CodeDoubanProject.get_by_name(project_name)
     data = {
         'url': "%s/%s" % (DOMAIN, project_name),
         'name': project_name,
         'description': summary,
         'product': product,
         'committers_count': 0,
         'forked_count': 0,
         'open_issues_count': 0,
         'open_tickets_count': 0,
         'watched_count': 0,
         'owner': {
             'name': owner_id,
             'avatar': gravatar_url(owner_id + '@douban.com'),
         },
     }
     commits = project.git.get_revisions("HEAD~1", "HEAD")
     if commits:
         data['last_commit'] = commits[0]
     ok_(project.get_info() == data)
     project.delete()
开发者ID:000fan000,项目名称:code,代码行数:31,代码来源:test_project.py

示例5: count

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
    def count(self, request):
        request.response.set_content_type('application/json; charset=utf8')
        q = request.get_form_var('q', '')
        project = CodeDoubanProject.get_by_name(self.project) \
            if self.project else None
        state = request.get_form_var('state', '')
        language = request.get_form_var('language', '')
        doctype = request.get_form_var('doctype', '')
        counts = {}

        for kind, cls in KIND_CLASS_MAP.iteritems():
            kwargs = dict(phrase=q, from_=0, size=0)
            if project and kind in (K_DOC, K_CODE, K_PULL, K_ISSUE):
                kwargs.update(project_id=project.id)
            if language and kind == K_CODE:
                kwargs.update(language=language)
            if state and kind in (K_PULL, K_ISSUE):
                kwargs.update(state=state)
            if doctype and kind == K_DOC:
                kwargs.update(doctype=doctype)
            result = cls.search_a_phrase(**kwargs)
            counts[kind] = SearchEngine.get_count(result)

        tdt = {
            'q': q,
            'repos': counts[K_REPO],
            'codes': counts[K_CODE],
            'users': counts[K_USER],
            'docs': counts[K_DOC],
            'pulls': counts[K_PULL],
            'issues': counts[K_ISSUE],
        }
        return json.dumps(tdt)
开发者ID:000fan000,项目名称:code,代码行数:35,代码来源:search_beta.py

示例6: _q_index

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
 def _q_index(self, request):
     group = self.group
     project = request.get_form_var('project')
     p = CodeDoubanProject.get_by_name(project) if project else None
     if project and p:
         group.add_project(project_id=p.id)
     return request.redirect(group.url)
开发者ID:000fan000,项目名称:code,代码行数:9,代码来源:team.py

示例7: get_by_proj_name_and_number

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [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

示例8: delete_project

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
def delete_project(names):
    if isinstance(names, basestring):
        names = [names]
    for n in names:
        prj = CodeDoubanProject.get_by_name(n)
        if prj:
            prj.delete()
开发者ID:000fan000,项目名称:code,代码行数:9,代码来源:utils.py

示例9: _get_tmpl_raw

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
def _get_tmpl_raw(tmpl_target, rev, path, project_name, request):
    project = CodeDoubanProject.get_by_name(project_name)
    if rev is None:
        rev = project.default_branch
    try:
        blob = project.repo.get_file(rev, path.decode("utf-8"))
    except IOError:
        raise TraversalError()
    if not blob:
        raise TraversalError("No content found")
    resp = request.response
    if is_image(path):
        if path.endswith("svg"):
            resp.set_header("Content-Type", "image/svg+xml")
        else:
            resp.set_header("Content-Type", "image/jpeg")
        resp.set_header("Expires", "Sun, 1 Jan 2006 01:00:00 GMT")
        resp.set_header("Pragma", "no-cache")
        resp.set_header("Cache-Control", "must-revalidate, no-cache, private")
        return blob.data
    if path.endswith(".pdf"):
        resp.set_header("Content-Type", "application/pdf")
        return blob.data
    if is_binary(path):
        resp.set_header("Content-Type", "application/octet-stream")
        resp.set_header("Content-Disposition", "attachment;filename=%s" % path.split("/")[-1])
        resp.set_header("Content-Transfer-Encoding", "binary")
        return blob.data
    resp.set_header("Content-Type", "text/plain;charset=utf-8")
    return blob.data.encode("utf8")
开发者ID:leeccong,项目名称:code,代码行数:32,代码来源:source.py

示例10: push_data_receiver

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
def push_data_receiver(sender, **kw):
    EMPTY_COMMIT_HASH = "0" * 40
    date = datetime.now()
    repo_name = kw.get('repo_name')
    before = kw.get('before')
    after = kw.get('after')
    username = kw.get('username')
    data = {
        'repo_name': repo_name,
        'repo_url': kw.get('repo_url'),
        'ref': kw.get('ref'),
        'branch': kw.get('branch'),
        'date': date,
        'before': before,
        'after': after,
        'is_new_branch': before == EMPTY_COMMIT_HASH,
        'is_delete_branch': after == EMPTY_COMMIT_HASH,
        'commits': kw.get('commits'),
        'type': 'push',
        'username': username,
    }
    feeds = get_related_feeds(
        '', project=CodeDoubanProject.get_by_name(repo_name))
    for feed in feeds:
        feed.add_action(data)
开发者ID:leeccong,项目名称:code,代码行数:27,代码来源:feed.py

示例11: destroy

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
 def destroy(self, request):
     group = self.group
     project = request.get_form_var("project")
     p = CodeDoubanProject.get_by_name(project) if project else None
     if project and p:
         group.remove_project(project_id=p.id)
     return request.redirect(group.url)
开发者ID:leeccong,项目名称:code,代码行数:9,代码来源:team.py

示例12: has_permission_handler

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
def has_permission_handler(username, path, perm):
    if not username or not path:
        return False

    if path.endswith(".git"):
        path = path[:-4]

    # gist
    if path.startswith("gist/"):
        gist_id = path.rpartition("/")[-1]
        if username == Gist.get(gist_id).owner_id:
            return True
        return False

    # project
    project = Project.get_by_name(path)
    if not project:
        return False
    if perm == "read":
        return True
    if not project.can_push:
        return False
    if project.has_push_perm(username):
        return True
    return False
开发者ID:leeccong,项目名称:code,代码行数:27,代码来源:ssh_app.py

示例13: create

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
    def create(self, request):
        if request.method == 'POST':
            user = request.user
            if not user:
                raise AccessError
            project = request.get_form_var('project')
            title = request.get_form_var('title', '').decode('utf-8')
            description = request.get_form_var('body', '').decode('utf-8')
            tags = request.get_form_var('issue_tags', [])
            if isinstance(tags, list):
                tags = [tag.decode('utf-8') for tag in tags if tag]
            elif isinstance(tags, basestring):
                tags = [tags.decode('utf-8')]

            if not project:
                raise TraversalError
            if not title.strip():
                return request.redirect('/%s/issues/new?error=empty' % project)
            project = CodeDoubanProject.get_by_name(project)
            pissue = ProjectIssue.add(title, description, user.name,
                                      project=project.id)
            pissue.add_tags(tags, pissue.project_id)
            # TODO: 重构feed后取消信号发送
            issue_signal.send(author=user.name, content=description,
                              issue_id=pissue.issue_id)
            dispatch('issue', data={
                     'sender': user.name,
                     'content': description,
                     'issue': pissue
                     })
            return request.redirect(pissue.url)
        project_name = self.proj_name
        return request.redirect('/%s/issues' % project_name)
开发者ID:000fan000,项目名称:code,代码行数:35,代码来源:issue.py

示例14: _tmpl_common_data

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
def _tmpl_common_data(rev, path, project_name, request):
    project = CodeDoubanProject.get_by_name(project_name)
    user = request.user
    ref = rev
    if ref is None:
        ref = project.default_branch
    branches = project.repo.branches
    tags = project.repo.tags
    ref_type = 'branch' if ref in branches else 'tag' \
               if ref in tags else 'tree'
    blob_path = path.decode('utf-8')
    tdt = {
        'errors': '',
        'branches': branches,
        'rev': rev,
        'tags': tags,
        'blob_path': blob_path,
        'file_name': blob_path.rpartition('/')[-1],
        'request': request,
        'project': project,
        'project_name': project_name,
        'path': path,
        'ref_type': ref_type,
        'blob_ref': ref,
        'ref': ref,
        'user': user,
    }
    return tdt
开发者ID:000fan000,项目名称:code,代码行数:30,代码来源:sphinx_docs.py

示例15: _q_index

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_by_name [as 别名]
 def _q_index(self, request):
     project_name = self.proj_name
     project = CodeDoubanProject.get_by_name(project_name)
     if not project:
         raise TraversalError()
     tickets = CodeDoubanTicketBoard(
         self.proj_name).tickets_group_by_status()
     return st('ticket_board.html', **locals())
开发者ID:000fan000,项目名称:code,代码行数:10,代码来源:board.py


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