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


Python ProjectForm.validate_on_submit方法代码示例

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


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

示例1: create_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def create_project():
    config.reload()
    form = ProjectForm()
    ds_forms = dict([
        (cls.populates, cls()) for cls in DataSourceForm.__subclasses__()])

    form.datasource_type.choices = [
        (cls.populates, cls.name) for cls in DataSourceForm.__subclasses__()]
    form.datasource_type.choices.insert(0, (None, "-- Select Data Source --"))
    new_project = Project()

    if form.validate_on_submit():
        form.populate_obj(new_project)
        ds_form = ds_forms[form.datasource_type.data]

        if ds_form.validate():
            new_project.datasource = \
                getattr(models, form.datasource_type.data)()
            ds_form.populate_obj(new_project.datasource)

            db.session.add(new_project)
            db.session.commit()
            flash("New project successfully created.")
            return redirect(url_for('view_project', id=new_project.id))

    return render_template("project/create.html",
                           form=form, ds_forms=ds_forms, project=new_project)
开发者ID:VaclavDedik,项目名称:triager,代码行数:29,代码来源:views.py

示例2: edit_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def edit_project(id):
    project = Project.query.get_or_404(id)

    ds_forms = dict([
        (cls.populates, cls()) for cls in DataSourceForm.__subclasses__()])
    for populates, ds_form in ds_forms.items():
        if populates == project.datasource.__class__.__name__:
            ds_forms[populates] = ds_form.__class__(obj=project.datasource)
            current_ds_type = populates

    form = ProjectForm(obj=project, datasource_type=current_ds_type)
    form.datasource_type.choices = [
        (cls.populates, cls.name) for cls in DataSourceForm.__subclasses__()]
    form.datasource_type.choices.insert(0, (None, "-- Select Data Source --"))

    if form.validate_on_submit():
        form.populate_obj(project)
        ds_form = ds_forms[form.datasource_type.data]

        if ds_form.validate():
            project.datasource = getattr(models, form.datasource_type.data)()
            ds_form.populate_obj(project.datasource)

            db.session.add(project)
            db.session.commit()
            flash("Project %s successfully updated." % project.name)
            return redirect(url_for('view_project', id=project.id))

    return render_template("project/edit.html",
                           form=form, ds_forms=ds_forms, project=project)
开发者ID:VaclavDedik,项目名称:triager,代码行数:32,代码来源:views.py

示例3: setting_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def setting_project():
    # 表格信息区
    projects = db.engine.execute(SQL['PROJECT_INFO'])
    project_choices = [(p.id, p.project_name) for p in Project.query.order_by('id')]
    user_choices = [(p.id, p.user_name) for p in User.query.filter(User.enable == 1).order_by('id')]
    # 增加项目区
    add_form = ProjectForm()
    add_form.project_manager.choices = user_choices
    if add_form.validate_on_submit():
        if g.user.role == 0:
            try:
                new_project = Project(add_form.project_name.data, add_form.project_manager.data,
                                      add_form.build_year.data, add_form.status.data)
                db.session.add(new_project)
                db.session.commit()
                log('project', '增加项目', new_project.id, new_project.project_name, '成功')
                flash("项目添加成功!")
            except Exception, e:
                flash("无法添加项目!")
                print Exception, e
                return render_template('setting-project.html', data=projects, user_choices=user_choices,
                                       status_choices=PROJECT_STATUS, add_form=add_form,
                                       project_choices=project_choices, atr='show')
        else:
            flash("无权限操作!")
开发者ID:frontc,项目名称:Effect_PM,代码行数:27,代码来源:views.py

示例4: add_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def add_project():
    form = ProjectForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            new_project = Projects(form.name.data, form.category.data, form.info.data, form.slug.data,
                                   form.status.data, github=form.github.data, url=form.url.data)
            db.session.add(new_project)
            db.session.commit()
            flash('New project added')
        else:
            flash('Validation failed')

    return render_template('new.html', form=form)
开发者ID:iScrE4m,项目名称:DJetelina,代码行数:15,代码来源:views.py

示例5: edit

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def edit(name):
    form = ProjectForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            selected_project = Projects.query.filter(Projects.slug == name).first()
            selected_project.update(form)
            db.session.commit()
            flash('Project edited')
        else:
            flash('Validation error')
    return render_template('edit.html',
                           project=Projects.query.filter(Projects.slug == name).first(),
                           form=form)
开发者ID:iScrE4m,项目名称:DJetelina,代码行数:15,代码来源:views.py

示例6: project_new

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def project_new():
    project = Project()
    form = ProjectForm(request.form, project)
    if form.validate_on_submit():
        counter = Counter.objects(id_for="project")[0]
        counter.set_next_id()
        counter.save()
        form.populate_obj(project)
        project.number = counter.number
        project.save()
        return redirect('/projects/')
    return render_template('projects_create.html',
                           project=project,
                           form=form)
开发者ID:ljb-2000,项目名称:neobug,代码行数:16,代码来源:views.py

示例7: project_setting

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def project_setting(project_id):
    project = Project.query.get(project_id)
    if current_user.id != project.creator_id:
        abort(404)
    form = ProjectForm(user=current_user, team=project.team, project=project, team_id=project.team.id,
                       name=project.name, subject=project.subject)
    form.team_id.choices = [(g.id, g.name) for g in current_user.teams]
    if form.validate_on_submit():
        if request.form.get('delete'):
            project.status = 1
            db.session.add(project)
            db.session.commit()
            return redirect(url_for('run'))
        return redirect(url_for('project_index', project_id=form.project.id))
    return render_template('project/form.html', form=form)
开发者ID:Red54,项目名称:Sophia,代码行数:17,代码来源:app.py

示例8: project_create

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def project_create():
    form = ProjectForm()
    if form.validate_on_submit():
        new_project = Project(
            title=form.title.data,
            branch=form.branch.data,
            user_id=current_user.get_id(),
            repo_url=form.repo_url.data
        )
        db.session.add(new_project)
        db.session.commit()

        flash('Project has been created successfully.', 'success')
        return redirect(url_for('project', project_id=new_project.id))

    return render_template('project/form.html', form=form, action_url=url_for('project_create'))
开发者ID:anton-kasperovich,项目名称:deployCD,代码行数:18,代码来源:views.py

示例9: index

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def index():
    form = ProjectForm()
    if form.validate_on_submit():
        project_name = request.form['name']
        api_type = request.form['api_type']

        project = Project(
                          name=project_name,
                          api_type=api_type,
                          created_by=current_user.id
                        )
        db.session.add(project)
        db.session.commit()
        flash('Project Created')
        return redirect(url_for('main_site_index.index'))

    return render_template('main/api_auth.html', form=form)
开发者ID:erictempleton1,项目名称:aggtron,代码行数:19,代码来源:create_project.py

示例10: project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def project(id_project=None):
    from forms import ProjectForm
    if id_project != None:
        project = Project.query.get(id_project)
        action = "Save"
    else:
        project = Project()
        action = "Create"
        
    form = ProjectForm(obj=project)
    if form.validate_on_submit():
        form.populate_obj(project)
        project.users.append(current_user)
        db.session.add(project)
        db.session.commit()
        return redirect('/projects')
    
    return render_template('project/form.html', form=form, action=action)
开发者ID:torav,项目名称:poxDNA,代码行数:20,代码来源:views.py

示例11: newproject

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def newproject():
    error = None
    form = ProjectForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            print 'validated'
            new_project = Project(
                form.subject.data,
                form.discription.data,
                form.duedate.data,
                form.finished.data,
                form.download_file.data,
            )
            db.session.add(new_project)
            db.session.commit()
            flash(u'پروژه ثبت شد ممد!')
        else:
            print 'not!'
    return render_template('newproject.html', form=form, error=error)
开发者ID:mohammadgoli,项目名称:newblog,代码行数:21,代码来源:views.py

示例12: create_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def create_project(record_id=False):
    form = ProjectForm()
    if form.validate_on_submit():
        values = {
            'name': form.name.data,
            'description': form.description.data,
            'color': form.color.data,
            'date': form.date.data,
        }
        if current_user.data.get('id') and not record_id:
            values['user_id'] = current_user.data.get('id')
        if record_id:
            table_registry.projects.write([record_id], values)
        else:
            table_registry.projects.create(values)
        return json.dumps({'redirect': url_for('home')})
    elif record_id:
        project_data = table_registry.projects.search_read([['id', '=', record_id]])[0]
        form.name.data = project_data['name']
        form.description.data = project_data['description']
        form.color.data = project_data['color']
        form.date.data = project_data['date'].strftime('%m/%d/%Y %I:%M %p')
    return render_template('backend/project_model.html', form=form, record_id=record_id and str(record_id))
开发者ID:snowbros,项目名称:pyweb,代码行数:25,代码来源:controller.py

示例13: project_create

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import validate_on_submit [as 别名]
def project_create():
    form = ProjectForm(user=current_user, team_id=request.args.get('team_id'))
    form.team_id.choices = [(g.id, g.name) for g in current_user.teams]
    if form.validate_on_submit():
        return redirect(url_for('project_index', project_id=form.project.id))
    return render_template('project/form.html', form=form)
开发者ID:Red54,项目名称:Sophia,代码行数:8,代码来源:app.py


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