Exemplo n.º 1
0
def project_create(request):
	#template_project = Project()

	#form = ProjectForm(request.POST or template_project)
	form = ProjectForm(request.POST or None, initial={})
	if form.is_valid():
		
		new_project = Project(title=form.cleaned_data['title'], description=form.cleaned_data['description'], url=form.cleaned_data['url'], open=form.cleaned_data['open'])
		new_project.save()
		
		#new_project = form.save()
		
		new_position = admin_position_default
		
		new_position.project = new_project
		
		new_position.save()
		
		relation = ProjectRelation(admin=True, user=request.user.userdata, project=new_project)
		relation.save()
		
		new_position.project_relation = relation
		new_position.save()
		
		
		admin_position_default.id=None
		
		for interest in form.cleaned_data['interests']:
			pi = ProjectInterest(project=new_project, interest=interest)
			pi.save()
		
		return redirect(project_detail, new_project.id)
	
	return render_to_response('project/create.html', {'form': form}, context_instance=RequestContext(request))
Exemplo n.º 2
0
def project_acceptposition(request, project_id, position_id):
	p = get_object_or_404(Project, pk=project_id)
	pos = get_object_or_404(Position, pk=position_id)
	
	# for now, users will just add themselves
	#require_project_admin(request, p)
	
	require_project_position_match(p, pos)
	
	require_project_nonmember(request, p)
	
	rel = ProjectRelation(
		user = request.user.userdata,
		project = p,
		admin = False,
	)
	
	rel.save()
	
	pos.project_relation = rel
	
	pos.save()
	
	return redirect(project_detail, p.id)