本文整理汇总了Python中vilya.models.project.CodeDoubanProject.gets_by_owner_id方法的典型用法代码示例。如果您正苦于以下问题:Python CodeDoubanProject.gets_by_owner_id方法的具体用法?Python CodeDoubanProject.gets_by_owner_id怎么用?Python CodeDoubanProject.gets_by_owner_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vilya.models.project.CodeDoubanProject
的用法示例。
在下文中一共展示了CodeDoubanProject.gets_by_owner_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: projects
# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import gets_by_owner_id [as 别名]
def projects(self, request):
projects = CodeDoubanProject.gets_by_owner_id(self.user.username)
data = []
without_commits = request.get_form_var('without_commits')
for project in projects:
data.append(project.get_info(without_commits))
return data
示例2: create
# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import gets_by_owner_id [as 别名]
#.........这里部分代码省略.........
mirror = None
def add_people_project(project):
name = "%s/%s" % (project.owner_id, project.name)
_project = CodeDoubanProject.add(
name=name, owner_id=project.owner_id,
summary=project.summary, product=project.product,
intern_banned=project.intern_banned)
return _project
def add_org_project(project):
_project = CodeDoubanProject.add(
name=name, owner_id=project.owner_id,
summary=project.summary, product=project.product,
intern_banned=project.intern_banned)
return _project
def add_mirror_project(project):
name = "mirror/%s" % (project.name)
_project = CodeDoubanProject.add(
name=name, owner_id='mirror', summary=project.summary,
product=project.product, intern_banned=project.intern_banned,
mirror=project.mirror_url)
if _project:
CodeDoubanMirror.add(url=project.mirror_url,
state=MIRROR_STATE_CLONING,
project_id=_project.id,
with_proxy=project.mirror_proxy)
return _project
def add_fork_project(project):
name = "%s/%s" % (project.owner_id, project.name)
_project = CodeDoubanProject.add(
name=name, owner_id=project.owner_id, summary=project.summary,
product=project.product, fork_from=project.fork_from,
intern_banned=project.intern_banned)
if _project:
fork_from_project = CodeDoubanProject.get(project.fork_from)
_project.update(project.summary,
project.product,
name,
fork_from_project.intern_banned)
return _project
def validate_project(project_type, project):
error = ''
if project_type in (PEOPLE_PROJECT, ORGANIZATION_PROJECT):
error = project.validate()
elif project_type == MIRROR_PROJECT:
error = project.validate()
if not error:
error = CodeDoubanMirror.validate(project.mirror_url)
else:
error = project.validate()
return error
def add_project(project):
_project = None
if project_type == PEOPLE_PROJECT:
_project = add_people_project(project)
elif project_type == ORGANIZATION_PROJECT:
_project = add_org_project(project)
elif project_type == MIRROR_PROJECT:
_project = add_mirror_project(project)
else:
_project = add_fork_project(project)
return _project
project = CodeDoubanProject(None, name, user.username, summary,
datetime.now(), product, None, None,
fork_from=fork_from,
intern_banned=intern_banned,
mirror_url=repo_url,
mirror_proxy=with_proxy)
# FIXME: rename org_proj of html
project_type = org_proj
errors = validate_project(project_type, project)
if errors:
return st(template_filename, **locals())
project = add_project(project)
if not project:
fork_from = ''
errors = 'project exists'
return st(template_filename, **locals())
CodeDoubanProject.add_watch(project.id, user.name)
return request.redirect('/%s/' % project.name)
fork_from = ''
if request.get_form_var('fork_from'):
fork_from = CodeDoubanProject.get(request.get_form_var('fork_from'))
name = "%s/%s" % (user.name, fork_from.realname)
if CodeDoubanProject.exists(name):
return request.redirect('/%s/' % name)
projects = CodeDoubanProject.gets_by_owner_id(user.name)
for p in projects:
if p.origin_project_id == fork_from.id and '/' in p.name:
return request.redirect('/%s/' % p.name)
return st(template_filename, **locals())