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


Python ProjectForm.is_valid方法代码示例

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


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

示例1: create_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
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,代码行数:37,代码来源:views.py

示例2: create

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
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,代码行数:34,代码来源:views.py

示例3: edit_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
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,代码行数:27,代码来源:views.py

示例4: create_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
def create_project(request, rfpId):
    context = RequestContext(request)
    user = request.user
    progress_status = 30
    rfp = RfpCampaign.objects.get(pk=rfpId)
    print("RFP is: ")
    print(rfp)
    questions = rfp.get_project_questions()

    if request.method == "POST":
        print(request.POST)
        project = ProjectForm(request.POST, request.FILES, questions=questions)

        if project.is_valid():
            project = Project(**project.cleaned_data)
            project.rfp = rfp
            project.user = user
            project.save()

            if "Next" in request.POST:
                return HttpResponseRedirect(reverse("create_project_budget", args=[project.pk]))
            else:
                return HttpResponseRedirect(reverse("create_project_previous", args=[project.pk]))

    else:
        project = ProjectForm(questions=questions)

    return render_to_response(
        "rfp/create_project.html",
        {"form": project, "user": user, "progress_status": progress_status, "rfp": rfp},
        context,
    )
开发者ID:unistra,项目名称:rfpportal-frcsxb,代码行数:34,代码来源:views.py

示例5: project_detail_view

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
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,代码行数:28,代码来源:views.py

示例6: project_add_typed

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
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,代码行数:30,代码来源:views.py

示例7: edit_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
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,代码行数:34,代码来源:views.py

示例8: project_edit

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
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,代码行数:27,代码来源:views.py

示例9: new_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
def new_project(request):
    if request.method == 'POST':
        form = ProjectForm(request.POST)
        name = str(request.POST['title'])
        #list=(str(project_api.get_projects_for_user(request.user.id))).replace("<Project: ","").replace(', ','').replace('[','').replace("]",'').split('>')
        #list = project_api.get_projects_for_user(request.user.id).values_list('title',flat=True)
        #print list

        #if name in list:
        if project_api.duplicate_project(request.user,request.POST):
            form.if_dup(1)
        if form.is_valid() :
            project_api.create_project(request.user, request.POST)
            project = form.save(commit=False)
            # return redirect('/req/projects')
            # return empty string and do the redirect stuff in front-end
            return HttpResponse('')

    else:
        form = ProjectForm()

    context = {'projects': project_api.get_projects_for_user(request.user.id),
               'canOwnProject': request.user.has_perm(PERMISSION_OWN_PROJECT),
               'title': 'New Project',
               'form': form, 'action': '/req/newproject', 'button_desc': 'Create Project'}
    return render(request, 'ProjectSummary.html', context)
开发者ID:ceyeclone,项目名称:team_alpha_project,代码行数:28,代码来源:projects.py

示例10: new_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
def new_project(request):
    if request.method == 'POST':
        form = ProjectForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/projects/')
    else:
        form = ProjectForm()
    return render_to_response('new_project.html',{'form': form})
开发者ID:Lopic,项目名称:urtest,代码行数:11,代码来源:views.py

示例11: pep_view

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
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,代码行数:11,代码来源:views.py

示例12: create_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
def create_project(request, template="create_project.html"):
    user = get_object_or_404(User, pk=request.user.pk)
    form = ProjectForm(request.POST or None, initial={"user": user})
    if request.method == "POST" and form.is_valid():
        new_project = form.save()
        print new_project
        return redirect("enterprise.projects")
    context = {"form": form, "title": _("Create Project"), "enterprise": request.session["company"]}
    return render(request, template, context)
开发者ID:kingofhawks,项目名称:greenbuilding,代码行数:11,代码来源:views.py

示例13: add

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
def add(request):
    if request.method == "POST":
        form = ProjectForm(data=request.POST)
        if form.is_valid():
            form.save()
            return redirect("core:home")
    else:
        form = ProjectForm()
    return render_to_response("add.html", {"form": form}, context_instance=RequestContext(request))
开发者ID:benoitbar,项目名称:projectcounter,代码行数:11,代码来源:views.py

示例14: add_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
def add_project(request):
	if request.method == 'GET':
		form = ProjectForm()
	elif request.method == 'POST':
		form = ProjectForm(request.POST)
		if form.is_valid():
			form.save()
	return render_to_response ('devcup/add_project.html', {
		'form': form,
	}, context_instance = RequestContext(request))
开发者ID:rap12,项目名称:wdwebapp,代码行数:12,代码来源:views.py

示例15: create_project

# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import is_valid [as 别名]
def create_project(request):
    """ Create a new Project.

    """
    form = ProjectForm(request.POST or None)
    if form.is_valid():
        new_project = form.save()
        return redirect(details_project, project_id=new_project.key)
    return render_to_response('form.html',
                              {'form': form},
                              context_instance=RequestContext(request))
开发者ID:jpihl,项目名称:plotato,代码行数:13,代码来源:views.py


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