Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop

This commit is contained in:
miss 2017-08-17 17:34:29 +08:00
commit d4e888b980
2 changed files with 40 additions and 12 deletions

View File

@ -163,8 +163,13 @@ class ShixunsController < ApplicationController
def collaborators_delete
user_id = params[:c_id]
gid = User.find(user_id).try(:gid)
shixun_member = ShixunMember.where(:user_id => user_id, :shixun_id => @shixun.id, :role => 2).first
shixun_member.delete
g = Gitlab.client
unless gid.nil?
g.remove_team_member(@shixun.gpid, gid)
end
@collaborators = @shixun.collaborators
respond_to do |format|
format.js
@ -177,24 +182,45 @@ class ShixunsController < ApplicationController
# members = searchTeacherAndAssistant @course
member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")"
condition = "%#{params[:search].strip}%".gsub(" ","")
@users = User.where("id not in #{member_ids} and status = 1 and LOWER(concat(lastname, firstname)) LIKE '#{condition}'").includes(:user_extensions)
@users = User.where("id not in #{member_ids} and status = 1 and LOWER(concat(lastname, firstname, login, mail)) LIKE '#{condition}'").includes(:user_extensions)
end
respond_to do |format|
format.js
end
end
# 事务处理保证Trustie与Gitlab数据同步
def shixun_members_added
unless params[:membership][:user_ids].blank?
memberships = params[:membership][:user_ids]
memberships.each do |member|
ShixunMember.create(:user_id => member, :shixun_id => @shixun.id, :role => 2)
ActiveRecord::Base.transaction do
begin
user = User.find(member)
s = Trustie::Gitlab::Sync.new
if user.gid.present?
gid = user.gid
else
guser = s.sync_user(user)
gid = guser.id
end
ShixunMember.create(:user_id => member, :shixun_id => @shixun.id, :role => 2)
u = s.g.add_team_member(@shixun.gpid, gid, 40) # 3代表角色master
if u.blank?
raise("同步Gitlab数据错误")
end
@collaborators = @shixun.collaborators
respond_to do |format|
format.js
end
rescue Exception => e
logger.error(e)
raise ActiveRecord::Rollback
end
end
end
@collaborators = @shixun.collaborators
end
respond_to do |format|
format.js
end
end
def search
@ -619,7 +645,7 @@ class ShixunsController < ApplicationController
# REDO: 新增类型copy的时候
# 复制项目
# gshixun --> gitlab project
CODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
# CODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
def copy_myshixun shixun, gshixun
myshixun = Myshixun.new
# myshixun.attributes = shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier","propaedeutics")

View File

@ -89,13 +89,15 @@
if(data.error){
return;
}else{
// 测试版
var html = "<iframe src='<%= Redmine::Configuration['webssh'] %>/?Host=" + data.host + "&Port=" + data.port + "&Username=" + data.username + "&Password=" + data.password + "&Gameid=" + data.game_id + "'" + " style='width:100%;border:0;' scrolling='no' id='game_webssh'></iframe><div class='-brother undis'></div>";
// 本地版
var html_local ="<iframe src='http://127.0.0.1:9527?Host=106.75.96.108&Port=40054&Username=root&Password=123123&Gameid=" +data.game_id + "'" + " style='width:100%;border:0;' scrolling='no' id='game_webssh'></iframe><div class='-brother undis'></div>";
$("#codetab_con_2").html(html);
var h = $("#games_repository_contents").height() - $("#top_repository").height() - 10;
var h = $("#games_repository_contents").height() - $("#top_repository").height() - 10;
var rows = parseInt(h / 18);
$("#game_webssh").css("min-height", h);
// 测试版
var html = "<iframe src='<%= Redmine::Configuration['webssh'] %>/?Host=" + data.host + "&Port=" + data.port + "&Username=" + data.username + "&Password=" + data.password + "&Gameid=" + data.game_id + "&rows=" + rows + "'" + " style='width:100%;border:0;' scrolling='no' id='game_webssh'></iframe><div class='-brother undis'></div>";
// 本地版
var html_local ="<iframe src='http://127.0.0.1:9527?Host=106.75.96.108&Port=40054&Username=root&Password=123123&Gameid=" +data.game_id + "&rows=" + rows + "'" + " style='width:100%;border:0;' scrolling='no' id='game_webssh'></iframe><div class='-brother undis'></div>";
$("#codetab_con_2").html(html);
HoverLi_new(2);
// console.log( $("#game_webssh").contentDocument.body.height());