def deluser(request, projectid, userid): project = Project.objects.get(id = projectid) user = User.objects.get(id = userid) if user not in project.members.all(): template = loader.get_template('error.html') context = Context( {'error': user.username + u'은 이미 프로젝트 멤버가 아닙니다. 이상하네요. 이 에러는 발생할 수 없는 에러입니다.' ,} ) return HttpResponse(template.render(context)) else: project.members.remove(user) project.save() # 저장소에서 push 권한 빼기 conf = Gitolite(settings.GITOLITE_ADMIN) conf.lock() conf.rmUser(project.unix_name, [user.username,]) if conf.publish() == False: template = loader.get_template('error.html') context = Context( {'error': user.username + u'을 프로젝트 저장소에 추가할 수 없습니다.' ,} ) conf.unlock() return HttpResponse(template.render(context)) conf.unlock() return HttpResponseRedirect('/project/'+projectid+'/')
def addsshkey(request): if request.method == 'POST': form = AddKeyForm(request.POST) if form.is_valid(): conf = Gitolite(settings.GITOLITE_ADMIN) conf.lock() key_value = form.cleaned_data['key'] key_name = form.cleaned_data['name'].encode('utf-8') if validate_sshkey(key_value) == True: fingerprint = sshKeyFingerprint(key_value) if is_duplicate(request.user.username, fingerprint) == True: form.errors['key'] = u'중복된 SSH Key 값입니다.' template = loader.get_template('account/addsshkey.html') context = Context( {'form': form, } ) return HttpResponse(template.render(context)) conf.addSSHKey(request.user.username, key_name, key_value) if conf.publish() == False: template = loader.get_template('error.html') context = Context( {'error': u'Cannot Publish your SSH key', } ) conf.unlock() return HttpResponse(template.render(context)) conf.unlock() return HttpResponseRedirect('/account/setting/sshkey/') else: form.errors['key'] = u'잘못된 SSH Key 값입니다.' else: form = AddKeyForm() template = loader.get_template('account/addsshkey.html') context = Context( {'form': form, } ) return HttpResponse(template.render(context))
def deluser(request, projectid, userid): project = Project.objects.get(id=projectid) user = User.objects.get(id=userid) if user not in project.members.all(): template = loader.get_template('error.html') context = Context({ 'error': user.username + u'은 이미 프로젝트 멤버가 아닙니다. 이상하네요. 이 에러는 발생할 수 없는 에러입니다.', }) return HttpResponse(template.render(context)) else: project.members.remove(user) project.save() # 저장소에서 push 권한 빼기 conf = Gitolite(settings.GITOLITE_ADMIN) conf.lock() conf.rmUser(project.unix_name, [ user.username, ]) if conf.publish() == False: template = loader.get_template('error.html') context = Context({ 'error': user.username + u'을 프로젝트 저장소에 추가할 수 없습니다.', }) conf.unlock() return HttpResponse(template.render(context)) conf.unlock() return HttpResponseRedirect('/project/' + projectid + '/')
def delsshkey(request, name): conf = Gitolite(settings.GITOLITE_ADMIN) conf.lock() if conf.rmSSHKey(request.user.username, name) == False: template = loader.get_template('error.html') context = Context( {'error': u'SSH Key file 을 지우는데 실패 했습니다.', } ) return HttpResponse(template.render(context)) conf.publish() conf.unlock() return HttpResponseRedirect('/account/setting/sshkey/')
def delsshkey(request, name): conf = Gitolite(settings.GITOLITE_ADMIN) conf.lock() if conf.rmSSHKey(request.user.username, name) == False: template = loader.get_template('error.html') context = Context({ 'error': u'SSH Key file 을 지우는데 실패 했습니다.', }) return HttpResponse(template.render(context)) conf.publish() conf.unlock() return HttpResponseRedirect('/account/setting/sshkey/')
def deluser2repo(request, projectid, userid): project = Project.objects.get(id = projectid) user = User.objects.get(id = userid) conf = Gitolite(settings.GITOLITE_ADMIN) conf.lock() conf.rmUser(project.unix_name, [user.username,]) if conf.publish() == False: template = loader.get_template('error.html') context = Context( {'error': user.username + u'을 프로젝트 저장소에 추가할 수 없습니다.' ,} ) conf.unlock() return HttpResponse(template.render(context)) conf.unlock() return HttpResponseRedirect('/project/'+projectid+'/')
def deluser2repo(request, projectid, userid): project = Project.objects.get(id=projectid) user = User.objects.get(id=userid) conf = Gitolite(settings.GITOLITE_ADMIN) conf.lock() conf.rmUser(project.unix_name, [ user.username, ]) if conf.publish() == False: template = loader.get_template('error.html') context = Context({ 'error': user.username + u'을 프로젝트 저장소에 추가할 수 없습니다.', }) conf.unlock() return HttpResponse(template.render(context)) conf.unlock() return HttpResponseRedirect('/project/' + projectid + '/')
def addsshkey(request): if request.method == 'POST': form = AddKeyForm(request.POST) if form.is_valid(): conf = Gitolite(settings.GITOLITE_ADMIN) conf.lock() key_value = form.cleaned_data['key'] key_name = form.cleaned_data['name'].encode('utf-8') if validate_sshkey(key_value) == True: fingerprint = sshKeyFingerprint(key_value) if is_duplicate(request.user.username, fingerprint) == True: form.errors['key'] = u'중복된 SSH Key 값입니다.' template = loader.get_template('account/addsshkey.html') context = Context({ 'form': form, }) return HttpResponse(template.render(context)) conf.addSSHKey(request.user.username, key_name, key_value) if conf.publish() == False: template = loader.get_template('error.html') context = Context({ 'error': u'Cannot Publish your SSH key', }) conf.unlock() return HttpResponse(template.render(context)) conf.unlock() return HttpResponseRedirect('/account/setting/sshkey/') else: form.errors['key'] = u'잘못된 SSH Key 값입니다.' else: form = AddKeyForm() template = loader.get_template('account/addsshkey.html') context = Context({ 'form': form, }) return HttpResponse(template.render(context))