同步数据处理

pull/109/head
Mr Chen 6 years ago
parent f9d679c8d4
commit 7e7843ff3a
  1. 1
      plugins/csvn/index.html
  2. 59
      plugins/csvn/index.py
  3. 19
      plugins/csvn/js/csvn.js

@ -8,6 +8,7 @@
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('csvn');">服务</p>
<p onclick="pluginInitD('csvn');">自启动</p>
<p onclick="csvnEdit();">手动编辑</p>
<p onclick="csvnUserList(1);">用户管理</p>
<p onclick="csvnProjectList(1);">项目管理</p>
<p onclick="csvnReadme();">使用说明</p>

@ -150,6 +150,14 @@ def initdUinstall():
return 'ok'
def csvnEdit():
data = {}
data['svn_access_file'] = getServerDir() + '/data/conf/svn_access_file'
data['commit_tpl'] = getPluginDir() + '/hook/commit.tpl'
data['post_commit_tpl'] = getPluginDir() + '/hook/post-commit.tpl'
return public.getJson(data)
def userAdd():
args = getArgs()
if not 'username' in args:
@ -512,6 +520,45 @@ def projectAclSet():
return 'ok'
def getCsvnUser():
user = 'admin_sync'
acl = getAllAclList()
if '' in acl:
tmp = acl['']
is_has = False
for data in tmp:
if data['user'] == user:
is_has = True
if not is_has:
tmp.append({'user': user, 'acl': 'r'})
acl[''] = tmp
makeAclFile(acl)
return user
def getCsvnPwd(user):
if app_debug:
return user + '123'
pwd_file = 'data/csvn_sync.pl'
if os.path.exists(pwd_file):
return public.readFile(pwd_file).strip()
import time
cur_time = time.time()
rand_pwd = public.md5(str(cur_time))
pwd = user + rand_pwd[:5]
htpasswd = getServerDir() + "/bin/htpasswd"
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + user + ' ' + pwd
data = public.execShell(cmd)
public.writeFile(pwd_file, pwd)
return pwd
def projectScriptLoad():
args = getArgs()
@ -533,8 +580,8 @@ def projectScriptLoad():
ct_content = public.readFile(commit_tpl)
ct_content = ct_content.replace('{$PROJECT_DIR}', public.getRootDir())
ct_content = ct_content.replace('{$PORT}', getHttpPort())
ct_content = ct_content.replace('{$CSVN_USER}', 'admin')
ct_content = ct_content.replace('{$CSVN_PWD}', 'admin123Q')
ct_content = ct_content.replace('{$CSVN_USER}', getCsvnUser())
ct_content = ct_content.replace('{$CSVN_PWD}', getCsvnPwd(getCsvnUser()))
public.writeFile(commit_file, ct_content)
public.execShell('chmod 777 ' + commit_file)
@ -611,12 +658,8 @@ if __name__ == "__main__":
print initdInstall()
elif func == 'initd_uninstall':
print initdUinstall()
elif func == 'run_info':
print runInfo()
elif func == 'conf':
print getConf()
elif func == 'save_conf':
print saveConf()
elif func == 'csvn_edit':
print csvnEdit()
elif func == 'user_list':
print userList()
elif func == 'user_add':

@ -15,6 +15,25 @@ function csvnPost(method,args,callback){
},'json');
}
function csvnEdit(){
csvnPost('csvn_edit',{} , function(data){
console.log(data);
var rdata = $.parseJSON(data.data);
var edit = '<p class="status">通用的手动编辑:</p>';
edit +='<div class="sfm-opt">\
<button class="btn btn-default btn-sm" onclick="onlineEditFile(0,\''+rdata['svn_access_file']+'\');">权限编辑</button>\
<button class="btn btn-default btn-sm" onclick="onlineEditFile(0,\''+rdata['post_commit_tpl']+'\');">post_commit_tpl</button>\
<button class="btn btn-default btn-sm" onclick="onlineEditFile(0,\''+rdata['commit_tpl']+'\');">commit_tpl</button>\
</div>';
$(".soft-man-con").html(edit);
});
}
function csvnUserFind(){
var search = $('#csvn_find_user').val();
if (search==''){

Loading…
Cancel
Save