예제 #1
0
def newProjectAjax(request):
	try:
		#get information from the Ajax post data
		r_projectType = request.POST.get('projectType')
		r_projectName= request.POST.get('projectName')
		r_projectDescription = request.POST.get('projectDescription')
		user = request.user
		newProject = Project(project_name=r_projectName, project_type=r_projectType, description=r_projectDescription)
		newProject.save()
		member = Member(project= newProject, user = user, mem_type = "Owner")
		member.save()
		root = Directory(parent = None, name = "Root", project_id = newProject, level = '0')
		root.save()
		newfile = File(parent = root, data= "", project_id = newProject.project_id, file_name = "readme", file_type = "txt")
		newfile.save()
		return JsonResponse({'response':'success', 'projectid': newProject.project_id})
	except:
		pass
	#if here then somthing went wrong	
	return JsonResponse({'response':'fail'})
예제 #2
0
def ajax_addNewTeamMember(request):
	is_username = False
	is_email = False
	try:
		#get information from the Ajax post data
		r_input_user = request.POST.get('input_user')
		r_input_permission = request.POST.get('input_permission')
		r_usertitle = request.POST.get('input_usertitle')
		r_project_id = request.POST.get('projectid')

		project = get_object_or_404(Project,project_id = r_project_id)

		try:
			user_username = User.objects.get(username = r_input_user)
			is_username = True
		except:
			pass
		try:
			user_email = User.objects.get(email = r_input_user)
			is_email = True
		except:
			pass

		if is_email:
			newMember = Member(project = project, user = user_email, mem_type = r_input_permission)
			newMember.save()
			notifyUser(newMember.user, newMember, project.project_name)
			return JsonResponse({'response':'success','username' : newMember.user.username,'usertype' : newMember.mem_type})
		elif is_username:
			newMember = Member(project = project, user = user_username, mem_type = r_input_permission)
			newMember.save()
			notifyUser(newMember.user, newMember, project.project_name)
			return JsonResponse({'response':'success','username' : newMember.user.username,'usertype' : newMember.mem_type})
	except:
		pass
	#if here then somthing went wrong	
	return JsonResponse({'response':'fail'})