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


Python forms.ProjectForm类代码示例

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


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

示例1: edit_project

def edit_project(request, project_id=None):
    # http://wiki.ddenis.com/index.php?title=Django,_add_and_edit_object_together_in_the_same_form

    if project_id:
        print "exists"
        project = get_object_or_404(Project, pk=project_id)
        if request.user not in project.users.all():
            return HttpResponseForbidden()
    else:
        print "doesn't exist"
        project = Project()

    if request.method == "POST":

        form = ProjectForm(request.POST, instance=project)

        if form.is_valid():

            form.save()

            return HttpResponseRedirect(project.get_absolute_url())

    else:

        form = ProjectForm(instance=project)

    if project_id:
        template_name = "edit_project.html"
    else:
        template_name = "new_project.html"

    return render(request, template_name, {"form": form, "project": project})
开发者ID:joinEF,项目名称:people,代码行数:32,代码来源:views.py

示例2: form

def form():
	form = ProjectForm()
	email = session['email']
	project_id = project_nums()
	user = User.query.filter_by(email=email).first()
	user_id = user.uid
	firstname, lastname = user.firstname, user.lastname
	
	if request.method == "POST":
		if form.validate() == False:
			return render_template('form.html', form=form, firstname=firstname, lastname=lastname)
		else:
			name = form.groupname.data
			goal = form.goal.data
			accomplish = form.accomplish.data
			friends = form.friends.data
			new_user_project = Projects(project_id, name, user_id, goal, accomplish)
			if friends:
				friends = friends.split(" ")
				for i in friends:
					friend = None
					if "@" in i:
						friend = User.query.filter_by(email=i[1:-2]).first()
						friend_id = friend.uid
					if friend:
						new_friend_project = Projects(project_id, name, friend_id, '', '')
						db.session.add(new_friend_project)
						db.session.commit()
			db.session.add(new_user_project)
			db.session.commit()

			return redirect(url_for('home', firstname = firstname, lastname = lastname))


	return render_template("form.html", form=form, firstname=firstname, lastname= lastname)
开发者ID:hershalb,项目名称:Information,代码行数:35,代码来源:routes.py

示例3: create

def create(request):
    if request.method == 'POST':

        form = ProjectForm(request.POST)

        if form.is_valid():

            title = form.cleaned_data['title']
            inv_type = form.cleaned_data['investigation_type']
            desc = form.cleaned_data['description']

            body = {
                "name":"idsvc.project",
                "value": {
                    "title":title,
                    "investigation_type":inv_type,
                    "description":desc,
                }
            }
            a = _client(request)
            try:
                response = a.meta.addMetadata(body=body)
            except Exception as e:
                logger.debug('no sir: %s' % e)

            return HttpResponseRedirect('/projects/')
    # else:
    context = {
        'form': ProjectForm()
    }

    return render(request, 'ids_projects/create.html', context)
开发者ID:mingchen7,项目名称:Identifier-Services-Portal,代码行数:32,代码来源:views.py

示例4: project_edit

def project_edit(request, pid, template_name='project_new.html'):
    """
    Edit an existing project
    """
    namedup = None
    project = get_object_or_404(request.user.project_set, id=pid)
    if request.method == "POST":
        form = ProjectForm(request.POST, instance=project)
        if form.is_valid():
            try:
                form.save()
                url = reverse('bbotweb_project_show', kwargs={'pid':project.id})
                return HttpResponseRedirect(url)
            except IntegrityError:
                msg = _("You already have a %s with the same name (%s).")
                messages.error(request, msg % (_("project"), project.name)); 
                namedup = True
    else:
        form = ProjectForm(instance=project)
    
    return render_to_response(template_name, {
        'form' : form,
        'project' : project,
        'namedup' : namedup,
    }, context_instance=RequestContext(request))
开发者ID:shawnchin,项目名称:bbotui,代码行数:25,代码来源:views.py

示例5: setting_project

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,代码行数:25,代码来源:views.py

示例6: edit_project

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,代码行数:30,代码来源:views.py

示例7: create_project

def create_project(request):
    user = request.user
    if request.POST:
        form = ProjectForm(request.POST, request.FILES)
        if form.is_valid():
            c = form.save(commit=False)
            c.author = user
            c.save()
            #            import pdb; pdb.set_trace()
            project = Project.objects.get(id=c.id)
            ## permissions
            if not project.public:
                group = '{}_pr_workers'.format(c.id)
                group = Group.objects.create(name=group)
                group.save()
            else:
                group = Group.objects.get(name='workers')
#            import pdb; pdb.set_trace()
            for i in worker_perms['project']:
                assign_perm(i, group, project)
            for i in prcreator_perms:
                assign_perm(i, user, project)
            user.groups.add(group)
            loger(auth.get_user(request), 'created project',c.name, project=project)
            return HttpResponseRedirect('/projector/all')
    else:
        form = ProjectForm()
     #   import pdb; pdb.set_trace()
        #form['deadline'] = '111'

    args = {}
    args['username'] = auth.get_user(request).username
    args.update(csrf(request))
    args['form'] = form
    return render_to_response('create_project.html',args)
开发者ID:i-k-i,项目名称:tolk,代码行数:35,代码来源:views.py

示例8: create_project

def create_project():

  if 'email' not in session:
    return redirect(url_for('home'))

  show_project = ProjectForm()
  show_project.set_supervisor_choices()

  if request.method == 'POST':
    if show_project.validate() == False:
      flash('All fields are required.')
      return render_template('create_project.html', show_project=show_project)
    else:
      new_project = project(show_project, session['email'])
      db.session.add(new_project)
      db.session.commit()
      if show_project.file.data.filename:
        os.makedirs("Project/files/" + str(newuser.id))
        filename = secure_filename(show_project.file.data.filename)
        show_project.file.data.save('Project/files/' + str(newuser.id) + "/" + filename)
      flash('Project has been created')
      return redirect(url_for('create_project'))
 
  elif request.method == 'GET':
    return render_template('create_project.html', show_project=show_project) 
开发者ID:martinsoender,项目名称:PIS,代码行数:25,代码来源:routes.py

示例9: project_detail_view

def project_detail_view(request,id):
    context = {'current':'projects'}
    user = request.user
    project = Project.objects.get_for_user(user=request.user, id=int(id))

    if request.POST:
        form = ProjectForm(instance=project, data=request.POST)
        if form.is_valid():
            form.save()
            context['project_saved'] = True
        context['form'] = form
    else:
        context['form'] = ProjectForm(instance=project)

    context['project'] = project
    context['spectators'] = project.spectators.all().select_related()
    context['owners'] = project.owners.all().select_related()
    context['collaborators'] = project.collaborators.all().select_related()
    context['new_spectators'] = User.objects.filter(profile__contacts__user=request.user).exclude(projects_as_spectator = project).select_related()
    context['new_collaborators'] = User.objects.filter(profile__contacts__user=request.user).exclude(projects_as_collaborator = project).select_related()
    context['is_creator'] = project.is_creator(request.user)
    context['is_admin'] = project.is_admin(request.user)
    context['new_owners'] = User.objects.filter(profile__contacts__user=request.user).exclude(owned_projects = project).select_related()
    context['new_task_form'] = NewTaskForm()
    context['goal_form'] = GoalForm()
    return render_response(request, 'project/project_detail_view.html', context)
开发者ID:debrice,项目名称:kaaloo,代码行数:26,代码来源:views.py

示例10: project_add_typed

def project_add_typed(request, project_id, response_format='html'):
    """Project add to preselected parent project"""

    parent_project = None
    if project_id:
        parent_project = get_object_or_404(Project, pk=project_id)
        if not request.user.profile.has_permission(parent_project, mode='x'):
            parent_project = None

    if request.POST:
        if 'cancel' not in request.POST:
            project = Project()
            form = ProjectForm(
                request.user.profile, project_id, request.POST, instance=project)
            if form.is_valid():
                project = form.save()
                project.set_user_from_request(request)
                return HttpResponseRedirect(reverse('projects_project_view', args=[project.id]))
        else:
            return HttpResponseRedirect(reverse('projects'))
    else:
        form = ProjectForm(request.user.profile, project_id)

    context = _get_default_context(request)
    context.update({'form': form, 'project': parent_project})

    return render_to_response('projects/project_add_typed', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:28,代码来源:views.py

示例11: edit_project

def edit_project(request, projectId):
    context = RequestContext(request)
    user = request.user
    project = Project.objects.get(pk=projectId)
    project_dict = model_to_dict(project)
    user_is_owner(user, project)
    redirect = get_redirect_url(request)

    if request.method == "POST":
        p = ProjectForm(request.POST, request.FILES, questions=project.rfp.get_project_questions())

        if p.is_valid():
            p_data = p.cleaned_data
            p_update = Project.objects.update_or_create(user=user, id=project.id, defaults=p_data)
            proj = p_update[0]
            proj_save = proj.save()

            return HttpResponseRedirect(redirect)

    else:
        p = ProjectForm(initial=project_dict, questions=project.rfp.get_project_questions())

    context_dict = {"project": project, "user": user, "form": p}

    return render_to_response("rfp/edit_project.html", context_dict, context)
开发者ID:unistra,项目名称:rfpportal-frcsxb,代码行数:25,代码来源:views.py

示例12: create_project

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,代码行数:27,代码来源:views.py

示例13: add

 def add(self):
     form = ProjectForm(csrf_enabled=False)
     if form.validate():
         project = form.save()
         db.session.add(project)
         db.session.commit()
         return 201, project.id
     return 400, form.errors
开发者ID:almet,项目名称:ihatemoney,代码行数:8,代码来源:api.py

示例14: add_project

def add_project():
    form = ProjectForm(request.form)
    if not form.validate():
        return str(form.errors)
    project = Project(form.name.data)
    db.session.add(project)
    db.session.commit()
    return redirect(url_for('index'))
开发者ID:moba,项目名称:summy,代码行数:8,代码来源:views.py

示例15: pep_view

def pep_view(request, **view_args):
    if request.method == 'GET':
        form = ProjectForm(request.GET)

        if form.is_valid():
            run_pep8(form.cleaned_data['url'], form.path, form.name, form.rev)
            return HttpResponseRedirect('/%s/%s' % (form.name, form.rev))

    return __show_home(form)
开发者ID:Bryukh,项目名称:spygit,代码行数:9,代码来源:views.py


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