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


Python Project.description方法代码示例

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


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

示例1: add_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import description [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)
开发者ID:dcbishop,项目名称:rust-ci,代码行数:47,代码来源:views.py

示例2: register

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import description [as 别名]
def register(request):
    if request.method == 'POST':
        a = request.POST.get('action')
        if a == 'register':
            register_f = RegisterForm(request.POST)
            login_f = LoginForm()
            if register_f.is_valid():
                try:
                    User.objects.create_user(
                        register_f.cleaned_data['username'],
                        register_f.cleaned_data['email'],
                        register_f.cleaned_data['password'])
                except IntegrityError, e:
                    if 'username' in str(e):
                        register_f.add_error('username',
                                             'Username is taken')
                    elif 'email' in str(e):
                        register_f.add_error('email',
                                             'Email is already registered')
                    else:
                        raise e
                else:
                    user = authenticate(
                        username=register_f.cleaned_data['username'],
                        password=register_f.cleaned_data['password'])
                    login(request, user)
                    Timezone.objects.create(user=user)
                    project = Project()
                    project.user = user
                    project.name = 'default project'
                    project.description = 'default project description'
                    project.color = Project.DEFAULT_COLOR
                    project.save()
                    return redirect('dashboard')
        elif a == 'login':
            register_f = RegisterForm()
            login_f = LoginForm(request.POST)
            if login_f.is_valid():
                user = authenticate(
                    username=login_f.cleaned_data['username'],
                    password=login_f.cleaned_data['password'])
                if user is None:
                    login_f.add_error('username',
                                      'Wrong credentials')
                else:
                    login(request, user)
                    return redirect('dashboard')
        else:
            register_f = RegisterForm()
            login_f = LoginForm()
开发者ID:DataScientists,项目名称:GOHDS,代码行数:52,代码来源:views.py


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