def upload_document( request, *args, **kwargs ):
	if not PermissionHandler.edit_project( request.user, project = kwargs['project'] ):
		return PermissionDenied('You are not allowed to upload to this project!')

	d = Document( doc = request.FILES['doc'], user = request.user, desc = request.POST['desc'] )
	d.save()
	project = get_object_or_404( Project, pk = kwargs['project'] )
	project.documents.add(d)
	project.save()
	return redirect( reverse('project:project_detail', args=[kwargs['project']] ) )
def project_detail_view( request, *args, **kwargs ):
	# putting together the required context.
	if request.method == 'GET':
	# very basic implementation.
		ctx = { }
		ctx['project'] = get_object_or_404( Project, pk = kwargs['project'] )
		ctx['task_list'] = Task.objects.filter( parent = ctx['project'] )
		ctx['update_list'] = Update.objects.filter( parent = ctx['project'] )
		ctx['documents'] = Document.objects.filter( project = ctx['project'] )
		if Update.objects.filter( parent = ctx['project'] ).count():
			ctx['no_updates'] = 0
		else:
			ctx['no_updates'] = 1

		if Task.objects.filter( parent = ctx['project'] ).count():
			ctx['no_tasks'] = 0
		else:
			ctx['no_tasks'] = 1

		if not PermissionHandler.edit_project( request.user, project = kwargs['project'] ):
			ctx['allow_project_edit'] = 0
		else:
			ctx['allow_project_edit'] = 1

		if not PermissionHandler.create_update( request.user, project = kwargs['project'] ):
			ctx['allow_update'] = 0
		else:
			ctx['allow_update'] = 1

		if not PermissionHandler.create_task( request.user, project = kwargs['project'] ):
			ctx['allow_task'] = 0
		else:
			ctx['allow_task'] = 1

		if not PermissionHandler.add_user_to_project( request.user, project = kwargs['project'] ):
			ctx['allow_add_user'] = 0
		else:
			ctx['allow_add_user'] = 1

		if not PermissionHandler.add_mentor_to_project( request.user, project = kwargs['project'] ):
			ctx['allow_add_mentor'] = 0
		else:
			ctx['allow_add_mentor'] = 1


		return render_to_response( 'project/project_details.html', ctx, context_instance = RequestContext(request) )

	elif request.method == 'POST':
		return HttpResponse('Method inapplicable')
def project_update( request, *args, **kwargs ):

	if not PermissionHandler.edit_project( request.user, project = kwargs['project'] ):
		return PermissionDenied('You are not allowed to edit!')

	project = get_object_or_404( Project, pk = kwargs['project'] )

	try:
		project.desc = request.POST['detailed_writeup']
		project.brief = request.POST['brief_writeup']
		project.status = request.POST['status']
		project.name = request.POST['title']
		if('bgImg' in request.FILES):
			project.image = request.FILES['bgImg']
		project.save()
	except ValueError as e:	# implement a form clean mechanism here.
		raise PermissionDenied('Error')

	return redirect( reverse('project:project_detail', args=[kwargs['project']]) )