本文整理匯總了Python中models.Project.categories方法的典型用法代碼示例。如果您正苦於以下問題:Python Project.categories方法的具體用法?Python Project.categories怎麽用?Python Project.categories使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Project
的用法示例。
在下文中一共展示了Project.categories方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_project
# 需要導入模塊: from models import Project [as 別名]
# 或者: from models.Project import categories [as 別名]
def add_project(request):
if request.method == 'POST':
form = ProjectForm(request.POST)
if form.is_valid():
package = form.cleaned_data['package']
username = form.cleaned_data['username']
repository = form.cleaned_data['repository']
branch = form.cleaned_data['branch']
cargo_support = form.cleaned_data['cargo_support']
categories = form.cleaned_data['categories']
repo = travisclient.get_repo(username, repository)
if not repo:
error_message = 'Unable to get Travis CI repo: {}/{}'.\
format(username, repository)
return index(request, error_message)
project = Project(package = package, username = username,
repository = repository, branch = branch,
cargo_support = cargo_support)
if('description' in repo and repo['description']):
project.description = repo['description']
else:
project.description = ''
project.save()
# Set categories
project.categories = categories
project.save()
return authenticate_with_github(request, project.id,
'add_project')
else:
form = ProjectForm(initial={'branch': 'master'})
context = {
'title': private_settings.APP_TITLE,
'form': form,
'categories': ProjectCategory.objects.all()
}
return render(request, 'ppatrigger/project_form.html', context)