def addProject(request): if request.session.has_key('logged_in'): if request.method == 'POST': form = ProjectForm(request.POST, request.FILES) if form.is_valid(): cd = form.cleaned_data p = Project(name=cd['name'], url=cd["url"], brief=cd['brief'], cleverbits=cd['cleverbits'], desktop_screenshot=cd['desktop_screenshot'], mobile_screenshot=cd['mobile_screenshot'], description=cd['description']) p.save() success = True return render(request, 'new_project.html', {'success': success}) else: form = ProjectForm() return render(request, 'new_project.html', {'form': form}) else: return render(request, 'login.html', { 'user_login': '******', 'destination': 'addProject' })
def project_view(request, project_id): """ - return project corresponding to project_id - handle project modification form submition - raise 404 if project is not found or project doesn't belong to the current user """ if request.user.is_superuser: project = get_object_or_404(Project, pk=project_id) else: project = get_object_or_404(Project, owner=request.user, pk=project_id) if request.method == "POST": form = ProjectForm(request.POST, instance=project) if form.is_valid(): form.save() else: form = ProjectForm(instance=project) context = { 'project': project, 'new_application_form': NewApplicationForm({'project_id': project.id}, prefix='new_application'), 'project_form': form } return render_response(request, 'project/project_view.html', context)
def manage_project(request): if request.method == "GET": form = ProjectForm() return render( request, "resume_view/update.html", { "form": form, "pics": None, "tech": None, "idslash": "", "btntext": "Save" }) # no fall through if request.method == "POST": form = ProjectForm(request.POST) if form.is_valid(): proj = copy_project_details(form, Project()) proj.save() return HttpResponseRedirect("/resume/project/{0}/".format(proj.id)) else: return render( request, "resume_view/update.html", { "form": form, "pics": None, "tech": None, "idslash": "", "btntext": "Save" })
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)
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)
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)
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)
def new_project(request): if request.method == 'POST': pform = ProjectForm(request.POST, instance=Project()) if pform.is_valid(): pform.save() return HttpResponseRedirect(reverse('manage_project')) else: pform = ProjectForm(instance=Project()) context = {'project_form': pform} context.update(csrf(request)) return render_to_response('viewer/project/new_project.html', context, context_instance=RequestContext(request))
def add_project(request): if request.method == "POST": form = ProjectForm(request.POST, user=request.user) if form.is_valid(): form.save(request) messages.success(request, 'Project created successfully.') return HttpResponseRedirect(reverse('my_projects')) else: form = ProjectForm() return render_to_response('authenticated/project/add_project.html', locals(), context_instance=RequestContext(request))
def server_type_edit(request, uuid): """修改项目""" Server_Type = Project.objects.all() business_name = Project.objects.get(uuid=uuid) uf = ProjectForm(instance=business_name) if request.method == 'POST': uf = ProjectForm(request.POST, instance=business_name) if uf.is_valid(): myform = uf.save() return render_to_response('assets/server_type_edit_ok.html', locals(), context_instance=RequestContext(request)) return render(request, 'assets/server_type_edit.html', locals())
def project(request): user = request.user bio = Bio.objects.get(user=user) if request.method == 'POST': form = ProjectForm(request.POST) if form.is_valid(): project = form.save(commit=False) project.bio = bio project.save() return redirect('skills') else: HttpResponse('please fill the form') else: form = ProjectForm() return render(request, 'skills/projects.html', {'form': form})
def edit_project(request, id): project = get_object_or_404(Project, id=id) #TODO: check if user is owner if request.method == "POST": form = ProjectForm(request.POST, instance=project, user=request.user) if form.is_valid(): form.save(request) messages.success(request, 'Project edited successfully.') return HttpResponseRedirect( reverse('project_detail', kwargs={'id': id})) else: form = ProjectForm(instance=project) return render_to_response('authenticated/project/edit_project.html', locals(), context_instance=RequestContext(request))
def selectproject(): arc = gis.GIS(username=session.get('arcuser'), password=session.get('arcsenha')) mytoken = session.get('mytoken') listaprojetos = session.get('listaprojetos') form = ProjectForm() form.selecionaprojeto.choices = listaprojetos if form.validate_on_submit(): items = arc.content.search( query="NOT title: %stakeholder% AND NOT title: %fieldworker% AND " + "owner:" + arc.users.me.username + " AND Survey", item_type="Feature Layer", max_items=500) session['projectname'] = str(form.selecionaprojeto.data) flash( f'Projeto ' + session.get('projectname') + ' selecionado com sucesso!', 'success') return redirect(url_for('selectcategory', mytoken=session['mytoken'])) else: flash( 'Projeto não pode ser selecionado. Verifique se há registros na camada.', 'danger') return render_template('selectprojecto.html', title='SelectProject', mytoken=mytoken, form=form)
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)
def create_project_summary(request,projectId): context = RequestContext(request) user = request.user project = Project.objects.get(pk = projectId) project_data = ProjectForm(data=model_to_dict(project),questions = project.rfp.get_project_questions()) user_is_owner(user,project) budget_line_list = BudgetLine.objects.filter(project = project) hr_budget_line_list = BudgetLine.objects.filter(project = project,category = 'HR') oc_budget_line_list = BudgetLine.objects.filter(project = project,category = 'OC') eq_budget_line_list = BudgetLine.objects.filter(project = project,category = 'EQ') prop_rev_list = ProposedReviewer.objects.filter(project = project).exclude(type='USER_EXCLUDED').exclude(type='ADMIN_PROPOSED').exclude(type = 'BOARD_SUGGESTED') excluded_rev_list = ProposedReviewer.objects.filter(project = project, type='USER_EXCLUDED') total_budgeted = budget_line_sum(budget_line_list) if request.method == 'POST': project.status='submitted' project.save() project.send_project_confirmation_email() context_dict = {'project':project,'project_data' : project_data,'budget_line_list': budget_line_list, 'total' : total_budgeted,'hr_budget_lines_list' : hr_budget_line_list, 'oc_budget_lines_list' : oc_budget_line_list, 'eq_budget_lines_list' : eq_budget_line_list,'prop_rev_list' : prop_rev_list,'excluded_rev_list' : excluded_rev_list} return render_to_response('rfp/create_project_summary.html',context_dict,context)
def edit_project(project_id): """ Route to edit a project in the database and redirect to index page """ projects = mongo.db.Projects the_project = mongo.db.Projects.find_one({'_id': ObjectId(project_id)}) form = ProjectForm() form.project_name.data = the_project['project_name'] form.short_text.data = the_project['short_text'] form.long_text.data = the_project['long_text'] form.image1.data = the_project['image0'] form.image2.data = the_project['image1'] form.image3.data = the_project['image2'] form.image4.data = the_project['image3'] form.website_link.data = the_project['website_link'] form.git_link.data = the_project["git_link"] if request.method == 'POST' and form.validate_on_submit(): projects.update({'_id': ObjectId(project_id)}, { 'project_name': request.form.get('project_name'), 'short_text': request.form.get('short_text'), 'long_text': request.form.get('long_text'), 'image0': request.form.get('image1'), 'image1': request.form.get('image2'), 'image2': request.form.get('image3'), 'image3': request.form.get('image4'), 'website_link': request.form.get('website_link'), 'git_link': request.form.get('git_link') }) return redirect(url_for('index')) return render_template('pages/edit/project.html', project=the_project, form=form)
def project_add(request): temp_name = "appconf/appconf-header.html" if request.method == 'POST': form = ProjectForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('project_list')) else: form = ProjectForm() results = { 'form': form, 'request': request, 'temp_name': temp_name, } return render(request, 'appconf/project_base.html', results)
def edit_project(id): """ Edit a project """ check_admin() add_project = False project = Project.query.get_or_404(id) form = ProjectForm(obj=project) if form.validate_on_submit(): project.name = form.name.data project.description = form.description.data db.session.commit() flash('You have successfully edited the project.') # redirect to the projects page return redirect(url_for('admin.list_projects')) form.description.data = project.description form.name.data = project.name return render_template('admin/projects/project.html', action="Edit", add_project=add_project, form=form, project=project, title="Edit Project")
def home(): project_form = ProjectForm() auth_form = AuthenticationForm() return render_template("home.html", project_form=project_form, auth_form=auth_form, session=session)
def edit_project(title): import __init__, models, forms from __init__ import db from models import Project from forms import ProjectForm project = Project.query.filter_by(title=title).first() if not project: abort(404) project_form = ProjectForm(obj=project) if request.method == "POST": if project_form.validate(): project_form.populate_obj(project) db.session.commit() flash("Edit was successful.") return redirect(url_for("main._portfolio")) else: flash("Project editing failed.") return render_template("edit_form.html", form=project_form, title="Edit Projects", right=random.choice(rights), is_web=True)
def create_project(): form = ProjectForm() if request.method == 'POST' and form.validate_on_submit(): name = form.name.data list_of_names = [ project.project_name for project in Project.query.filter_by( company_id=current_user.company_id).all() ] if name not in list_of_names: description = form.description.data project = Project() project.project_name = name project.description = description project.company_id = current_user.company_id db.session.add(project) db.session.commit() return render_template( 'error.html', message='Okay! Lets make some documentation!') else: return render_template( 'error.html', message='Project with current name exist in your company.') return render_template('project.html', user=current_user.user_username, form=form)
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)
def update_project(request, pid): try: proj = Project.objects.get(pk=int(pid)) except: return HttpResponseRedirect("/resume/project/") if request.method == 'GET': form = populate_default_form(proj) pics = Pics.objects.filter(project=proj.id) tech = Tech.objects.filter(project=proj.id) return render( request, "resume_view/update.html", { "form": form, "pics": pics, "tech": tech, "idslash": "{0}/".format(pid), "btntext": "Update" }) elif request.method == 'POST': form = ProjectForm(request.POST) if form.is_valid(): proj = copy_project_details(form, proj) proj.save() return HttpResponseRedirect("/resume/project/{0}/".format(proj.id)) pics = Pics.objects.filter(project=proj.id) tech = Tech.objects.filter(project=proj.id) return render( request, "resume_view/update.html", { "form": form, "pics": pics, "tech": tech, "idslash": "{0}/".format(pid), "btntext": "Update" })
def edit_project(request, project_id): if request.method == 'POST': p = Project.objects.get(pk=project_id) updated_form = ProjectForm(request.POST, instance=p) if updated_form.is_valid(): updated_form.save() return HttpResponseRedirect(reverse('manage_project')) else: proj_obj = Project.objects.get(pk=project_id) pform = ProjectForm(instance=proj_obj) context = {'project_form': pform, 'name': proj_obj.name, 'pk': proj_obj.pk} context.update(csrf(request)) return render_to_response('viewer/project/edit_project.html', context, context_instance=RequestContext(request))
def delete_project(request, projectID): project = project_api.get_project(projectID) if project is None: # return redirect('/req/projects') # return empty string and do the redirect stuff in front-end return HttpResponse('') if request.method == 'POST': project_api.delete_project(project) # return redirect('/req/projects') # return empty string and do the redirect stuff in front-end return HttpResponse('') else: form = ProjectForm(instance=project) context = { 'projects': project_api.get_projects_for_user(request.user.id), 'canOwnProject': request.user.has_perm(PERMISSION_OWN_PROJECT), 'title': 'Delete Project', 'confirm_message': 'This is an unrevert procedure ! You will lose all information about this project !', 'form': form, 'action': '/req/deleteproject/' + projectID, 'button_desc': 'Delete Project' } return render(request, 'ProjectSummary.html', context)
def add_project(request): # REMEMBER TO HANDLE UNAUTHENTICATED USERS if request.method == 'POST': projectForm = ProjectForm(request.POST) if projectForm.is_valid() and request.user.is_authenticated(): project = projectForm.save(commit = False) project.creator = request.user project.soundCloud = getIFrameSrc(projectForm.cleaned_data['soundCloud']) project.is_active = True project.save() projectForm.save_m2m() return HttpResponseRedirect('profile/' + request.user.username) else: return render(request, 'addProject.html', {'projectForm': projectForm}) else: projectForm = ProjectForm() return render(request, 'addProject.html', {'projectForm': projectForm})
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
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)
def edit_project(request, project_id): """ Edit Project. """ project = get_object_or_404(Project, pk=project_id) if request.method == "POST": form = ProjectForm(request.POST, instance=project) else: form = ProjectForm(instance=project) if form.is_valid(): # All validation rules pass form.save() messages.add_message(request, messages.INFO, 'The project has been successfully modified.') return redirect(details_project, project_id=project.key) return render_to_response('form.html', {'form': form}, context_instance=RequestContext(request))
def server_type_add(request): """添加项目""" if request.method == 'POST': # 验证post方法 init = request.GET.get("init", False) uf = ProjectForm(request.POST) if uf.is_valid(): project_name = uf.cleaned_data['service_name'] if Project.objects.filter(service_name=project_name): emg = u'添加失败, 此项目 %s 已存在!' % project_name return my_render('assets/server_type_add.html', locals(), request) uf.save() if not init: return HttpResponseRedirect("/assets/server/type/list/") else: uf = ProjectForm() return render(request, 'assets/server_type_add.html', locals())