Example #1
0
def project_new(request):
	if request.method == 'POST':
		form = ProjectForm(request.POST)
		if form.is_valid():
			name = form.cleaned_data['name']
			gitpath = settings.FORJME_GIT_ROOT + name + '.git'
			if not os.path.exists(gitpath):
				description = form.cleaned_data['description']
				project = Project.objects.create(name=name, description=description, is_archived = False, creation_date=datetime.now(), creator=request.user)
				project.save()
				#create a git project
				client = GitClient()
				client.create_repository(gitpath, True)
				tmpl = loader.get_template('dashboard/project/project.html')
				ctx = Context({ 'project': project })
				rendered = tmpl.render(ctx)
				return HttpResponse(content=json.dumps({'success' : 'success', 'element': rendered}), mimetype='application/json')
			else:
				return HttpResponse(json.dumps({"name": ["nom de projet non disponible"]}), mimetype='application/json')
		else:
			errors = json.dumps(form.errors)
			logger.debug(errors)
			return HttpResponse(errors, mimetype='application/json')
	else:
		form = ProjectForm(request)
	#variables = RequestContext(request, {'form':form})
	return render_to_response('dashboard/project/newproject.html', {'form':form}, context_instance=RequestContext(request))
Example #2
0
def sources_commit(request, project_id = None, commit = None):
	project = Project.objects.get(pk=project_id)
	client = GitClient()
	gitpath = settings.FORJME_GIT_ROOT + project.name + '.git'
	repository = client.get_repository(gitpath)
	repo = project.name + '.git'
	thecommit = repository.get_commit(commit)
	breadcrumbs = [{'dir': 'Commit #' + thecommit.hash, 'path':''}]
	return render_to_response('dashboard/sources/commit.html',{'page':'commits', 'repo':repo, 'commit':thecommit, 'project':project, 'breadcrumbs': breadcrumbs},context_instance=RequestContext(request))
Example #3
0
def sources_commits(request, project_id = None, branch = None):
	project = Project.objects.get(pk=project_id)
	client = GitClient()
	gitpath = settings.FORJME_GIT_ROOT + project.name + '.git'
	repository = client.get_repository(gitpath)
	repo = project.name + '.git'
	branches = repository.get_branches()
	tags = repository.get_tags()
	commits = repository.get_commits(branch)
	breadcrumbs = [{'dir': 'Commit history', 'path':''}]
	return render_to_response('dashboard/sources/commits.html',{'page':'commits', 'repo': repo, 'branch': branch, 'branches': branches, 'tags': tags, 'commits': commits, 'project': project, 'breadcrumbs': breadcrumbs}, context_instance=RequestContext(request))	
Example #4
0
def sources_archive(request, project_id = None, branch = None, format = 'zip'):
	project = Project.objects.get(pk=project_id)
	client = GitClient()
	gitpath = settings.FORJME_GIT_ROOT + project.name + '.git'
	repository = client.get_repository(gitpath)
	tree = repository.get_branch_tree(branch)
	archive_dir = settings.FORJME_ARCHIVE_DIR
	file_ouput = repository.create_archive(archive_dir, tree,format)
	response = HttpResponse(FileWrapper(file(file_ouput)), content_type='application/zip')
	response['Content-Length'] = os.path.getsize(file_ouput)
	response['Content-Disposition'] = 'attachment; filename=' + project.name + format
	return response
Example #5
0
def sources_branch(request, project_id = None, branch = None):
	project = Project.objects.get(pk=project_id)
	client = GitClient()
	gitpath = settings.FORJME_GIT_ROOT + project.name + '.git'
	repository = client.get_repository(gitpath)
	repo = project.name + '.git'
	#branch = repository.get_current_branch()
	#repo = 'test.git'
	path = ''
	parent = ''
	branches = repository.get_branches()
	tags = repository.get_tags()
	files = repository.get_tree(branch)
	return render_to_response('dashboard/sources/index.html',{'page':'files', 'files': files.output(), 'repo':repo, 'path': path, 'parent': parent, 'branch': branch, 'branches': branches, 'tags': tags,'project':project}, context_instance=RequestContext(request))	
Example #6
0
def sources_file(request, project_id = None, branch = None, file = None):
	project = Project.objects.get(pk=project_id)
	client = GitClient()
	gitpath = settings.FORJME_GIT_ROOT + project.name + '.git'
	repository = client.get_repository(gitpath)
	repo = project.name + '.git'
	fileType = repository.get_file_type(file)
	blob = repository.get_blob(branch+':"'+file+'"')
	#logger.debug('blob content : %s' % blob.output())
	#repo = 'test.git'
	branches = repository.get_branches()
	tags = repository.get_tags()
	output = blob.output()
	breadcrumbs = repository.get_breadcrumbs(file)
	return render_to_response('dashboard/sources/file.html',{'file':file, 'fileType':fileType, 'blob': output, 'repo': repo, 'breadcrumbs':breadcrumbs, 'branch':branch, 'branches':branches,'tags': tags, 'project': project}, context_instance=RequestContext(request))
Example #7
0
def sources_tree(request, project_id = None, branch = None, dir = None):
	#logger.debug('directory : %s' % dir)
	project = Project.objects.get(pk=project_id)
	client = GitClient()
	gitpath = settings.FORJME_GIT_ROOT + project.name + '.git'
	repository = client.get_repository(gitpath)
	repo = project.name + '.git'
	branches = repository.get_branches()
	tags = repository.get_tags()
	commits = repository.get_commits(branch)
	path = dir
	if dir.rfind('/') != -1:
		pos = dir.rfind('/')
		parent = dir[0:pos]
	else:
		parent= ''
	files = repository.get_tree(branch+':"'+dir+'"')
	breadcrumbs = repository.get_breadcrumbs(dir)
	return render_to_response('dashboard/sources/index.html',{'page':'files', 'files': files.output(), 'repo':repo, 'path': path, 'parent': parent, 'branch': branch, 'branches': branches, 'tags': tags, 'breadcrumbs': breadcrumbs, 'project':project}, context_instance=RequestContext(request))