From: taejun Date: Wed, 24 Apr 2013 06:49:14 +0000 (+0900) Subject: [DIBS web] modify for sbi command using email and password X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c4d6e53c2735248ede6210095f0ff5d9bb99121;p=sdk%2Ftools%2Fsdk-build.git [DIBS web] modify for sbi command using email and password --- diff --git a/dibs-web/Gemfile b/dibs-web/Gemfile index cfe9b05..47512b4 100644 --- a/dibs-web/Gemfile +++ b/dibs-web/Gemfile @@ -5,8 +5,6 @@ gem 'rails', '3.2.8' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' -gem 'sqlite3' - gem 'json' gem 'execjs' diff --git a/dibs-web/Gemfile.lock b/dibs-web/Gemfile.lock index d4f7f1a..2f3f71c 100644 --- a/dibs-web/Gemfile.lock +++ b/dibs-web/Gemfile.lock @@ -90,7 +90,6 @@ GEM hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.6) thor (0.16.0) tilt (1.3.3) treetop (1.4.10) @@ -114,5 +113,4 @@ DEPENDENCIES mysql2 (> 0.3) rails (= 3.2.8) sass-rails (~> 3.2.3) - sqlite3 uglifier (>= 1.0.3) diff --git a/dibs-web/app/controllers/admin_project_controller.rb b/dibs-web/app/controllers/admin_project_controller.rb index 04baa94..2a23fef 100644 --- a/dibs-web/app/controllers/admin_project_controller.rb +++ b/dibs-web/app/controllers/admin_project_controller.rb @@ -75,7 +75,6 @@ class AdminProjectController < ApplicationController , projects.name , projects.ptype , projects.status - , projects.password FROM projects , distributions WHERE distributions.id = \"#{dist_id}\" @@ -88,7 +87,6 @@ class AdminProjectController < ApplicationController doc.Name(project.name) doc.Type(project.ptype) doc.ProjectStatus(project.status) - doc.ProjectPassword(project.password) os_list = ProjectOs.find_by_sql("SELECT supported_os.name AS name FROM project_os @@ -132,7 +130,6 @@ class AdminProjectController < ApplicationController dist_id = change_item[:DistId] project_name = change_item[:Name] project_type = change_item[:ProjectType].upcase - project_password = change_item[:ProjectPass] project_status = change_item[:ProjectStatus].upcase if dist_id.nil? or dist_id.empty? or @@ -174,7 +171,6 @@ class AdminProjectController < ApplicationController project.name = project_name project.ptype = project_type project.status = project_status - project.password = project_password project.distribution_id = dist_id #TODO: set project user is admin. admin user id is '1' project.user_id = 1 @@ -266,7 +262,6 @@ class AdminProjectController < ApplicationController project_id = change_item[:Id] project_name = change_item[:Name] project_status = change_item[:ProjectStatus].upcase - project_password = change_item[:ProjectPass] if project_id.nil? or project_id.empty? or project_name.nil? or project_name.empty? or @@ -301,7 +296,6 @@ class AdminProjectController < ApplicationController project.name = project_name end - project.password = project_password project.status = project_status # remove project os and reset project os diff --git a/dibs-web/app/controllers/application_controller.rb b/dibs-web/app/controllers/application_controller.rb index 1ad4921..6027ab4 100644 --- a/dibs-web/app/controllers/application_controller.rb +++ b/dibs-web/app/controllers/application_controller.rb @@ -57,6 +57,18 @@ class ApplicationController < ActionController::Base end end + def get_user_password + if @current_user.nil? + current_user + end + + if not @current_user.nil? + return @current_user.password_hash + else + return nil + end + end + def get_group_list(email) if not email.nil? group_list = Group.find_by_sql("SELECT groups.id diff --git a/dibs-web/app/controllers/jobs_controller.rb b/dibs-web/app/controllers/jobs_controller.rb index 03dfdad..01ec9f3 100644 --- a/dibs-web/app/controllers/jobs_controller.rb +++ b/dibs-web/app/controllers/jobs_controller.rb @@ -413,7 +413,6 @@ class JobsController < ApplicationController ELSE \"SINGLE\" END \"job_attribute\" , projects.name AS project_name , projects.ptype AS project_type - , projects.password AS project_password , users.name AS user_name , users.email AS user_email , supported_os.name AS supported_os_name @@ -559,7 +558,7 @@ class JobsController < ApplicationController #check svr dir if not File.exist?(svr_dir) then - render :text => e.message, :status => 406 + render :text => "[#{svr_dir}] does not exist. please mail to server administrator", :status => 406 return end @@ -639,24 +638,15 @@ class JobsController < ApplicationController # Check job builder if get_user_email != job.user_email if not is_admin(get_user_email) - render :text => "You don't have authority to calcel.", :status => 406 + render :text => "You don't have authority to cancel.", :status => 406 return end end - # get password when Multi build - if job.job_type.eql? "MULTIBUILD" - sub_job = Job.find(:first, :conditions => ["parent_job_id=?", id]) - sub_job_project_info = Project.find(sub_job.project_id) - job_password = sub_job_project_info.password - else - job_password = job.project_password - end - # Excute command message = "" begin - result, message = Utils.sbi_cancel_command(id, job_password) + result, message = Utils.sbi_cancel_command(id, get_user_email, get_user_password) rescue => e render :text => e.message, :status => 406 end diff --git a/dibs-web/app/controllers/projects_controller.rb b/dibs-web/app/controllers/projects_controller.rb index a4460b2..dc8d863 100644 --- a/dibs-web/app/controllers/projects_controller.rb +++ b/dibs-web/app/controllers/projects_controller.rb @@ -46,7 +46,6 @@ class ProjectsController < ApplicationController distribution_list = [] project_list = [] os_list = [] - password_list = [] dist_name = nil @@ -75,14 +74,12 @@ class ProjectsController < ApplicationController distribution_list.push project.distribution_id project_list.push project.name - password_list.push project.password os_list.push os.name end distribution_list.uniq! project_list.uniq! os_list.uniq! - password_list.uniq! if(distribution_list.length > 1) errmsg = "Can't build multiple distribution" @@ -93,7 +90,7 @@ class ProjectsController < ApplicationController # execute build command begin - result, job_id, msg = Utils.sbi_build_command(distribution.name, project_list, os_list, password_list, get_user_email) + result, job_id, msg = Utils.sbi_build_command(distribution.name, project_list, os_list, get_user_email, get_user_password) if result then render :json => { :result => "SUCCESS", :job_id => job_id } else @@ -415,7 +412,7 @@ class ProjectsController < ApplicationController end begin - Utils.sbi_register_command(distribution.name, file_path, project.password, get_user_email) + Utils.sbi_register_command(distribution.name, file_path, get_user_email, get_user_password) rescue => e render :text => e.message, :status => 406 return diff --git a/dibs-web/app/controllers/utils.rb b/dibs-web/app/controllers/utils.rb index 0b96790..ee8aad3 100644 --- a/dibs-web/app/controllers/utils.rb +++ b/dibs-web/app/controllers/utils.rb @@ -31,7 +31,7 @@ BUILD_SERVER_ADDRESS = "127.0.0.1" DIBS_PATH = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) class Utils < ApplicationController - def Utils.sbi_build_command(distribution, project_list, os_list, password_list, email) + def Utils.sbi_build_command(distribution, project_list, os_list, email, password) job_id = nil dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""]) if dibs_config.nil? @@ -40,17 +40,11 @@ class Utils < ApplicationController dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value end - options = "-d #{dibs_address} --async " + options = "-d #{dibs_address} --async -U #{email} -w \'#{password}\'" options = options + " -N #{project_list.join(",")} -D #{distribution} " if (os_list.length > 1) or (not os_list[0].nil?) options = options + " -o #{os_list.join(",")} " end - if (password_list.length > 1) or (not (password_list[0].nil? or password_list[0].empty?)) - options = options + " -w #{password_list.join(",")} " - end - if not email.nil? - options = options + " -U #{email} " - end cmd = "#{DIBS_PATH}/build-cli build #{options}" puts "Build command" @@ -65,7 +59,7 @@ puts "[[[#{cmd}]]]" return result, job_id, msg end - def Utils.sbi_register_command(distribution, file_path, password, email) + def Utils.sbi_register_command(distribution, file_path, email, password) dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""]) if dibs_config.nil? raise RuntimeError, "Can't find server port information" @@ -73,13 +67,7 @@ puts "[[[#{cmd}]]]" dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value end - options = "-P #{file_path} -d #{dibs_address} -D #{distribution} --async " - if (not password.nil?) - options = options + " -w #{password}" - end - if not email.nil? - options = options + " -U #{email} " - end + options = "-P #{file_path} -d #{dibs_address} -D #{distribution} --async -U #{email} -w \'#{password}\' " cmd = "#{DIBS_PATH}/build-cli register #{options}" puts "Register command" @@ -87,7 +75,7 @@ puts "[[[#{cmd}]]]" return execute_shell_return(cmd) end - def Utils.sbi_cancel_command(job_id, password) + def Utils.sbi_cancel_command(job_id, email, password) dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""]) if dibs_config.nil? raise RuntimeError, "Can't find server port information" @@ -99,11 +87,7 @@ puts "[[[#{cmd}]]]" raise RuntimeError, "Invalid job id : #{job_id}" end - options = "-d #{dibs_address} " - options = options + " -j #{job_id}" - if (not password.nil?) - options = options + " -w #{password}" - end + options = "-d #{dibs_address} -j #{job_id} -U #{email} -w \'#{password}\' " cmd = "#{DIBS_PATH}/build-cli cancel #{options}" puts "Cancel command" diff --git a/dibs-web/app/models/project.rb b/dibs-web/app/models/project.rb index c393ab3..1c66c6a 100644 --- a/dibs-web/app/models/project.rb +++ b/dibs-web/app/models/project.rb @@ -1,3 +1,3 @@ class Project < ActiveRecord::Base - attr_accessible :id, :distribution_id, :name, :ptype, :password, :status + attr_accessible :id, :distribution_id, :name, :ptype, :status end diff --git a/dibs-web/app/models/user.rb b/dibs-web/app/models/user.rb index ebfb5f1..40432ec 100644 --- a/dibs-web/app/models/user.rb +++ b/dibs-web/app/models/user.rb @@ -1,7 +1,7 @@ class User < ActiveRecord::Base # has_many :user_groups # has_many :groups, :through => :user_groups - attr_accessible :id, :email, :password, :password_confirmation, :name + attr_accessible :id, :email, :password, :password_confirmation, :password_hash, :name attr_accessor :password before_save :encrypt_password diff --git a/dibs-web/public/index.html b/dibs-web/public/index.html index 1961916..447d53e 100644 --- a/dibs-web/public/index.html +++ b/dibs-web/public/index.html @@ -617,9 +617,6 @@ Contributors:
- - -

@@ -651,9 +648,6 @@ Contributors:
- - -

@@ -684,9 +678,6 @@ Contributors:
- - -
@@ -716,9 +707,6 @@ Contributors:
- - -
@@ -984,7 +972,7 @@ Contributors:
- + Save Delete
diff --git a/dibs-web/public/javascripts/admin-project-add.js b/dibs-web/public/javascripts/admin-project-add.js index 2acc880..19f11ce 100644 --- a/dibs-web/public/javascripts/admin-project-add.js +++ b/dibs-web/public/javascripts/admin-project-add.js @@ -28,7 +28,6 @@ Contributors: function adminProjectAddGitInit() { $("#adminProjectAddGit-name").val(""); - $("#adminProjectAddGit-password").val(""); $("#adminProjectAddGit-address").val(""); $("#adminProjectAddGit-branch").val(""); $("#adminProjectAddGit-status").empty(); @@ -62,7 +61,6 @@ function adminProjectAddGitInit() { function adminProjectAddBinaryInit() { $("#adminProjectAddBinary-name").val(""); - $("#adminProjectAddBinary-password").val(""); $("#adminProjectAddBinary-packagename").val(""); $("#adminProjectAddBinary-status").empty(); @@ -98,7 +96,6 @@ function adminProjectAddGitProject() { var changeInfoItem; var distId = $("#adminProject-distribution-select option:selected").val(); var name = $("#adminProjectAddGit-name").val(); - var password = $("#adminProjectAddGit-password").val(); var address = $("#adminProjectAddGit-address").val(); var branch = $("#adminProjectAddGit-branch").val(); var projectStatus = $("#adminProjectAddGit-status option:selected").val(); @@ -111,12 +108,12 @@ function adminProjectAddGitProject() { } } - if(name == "" || password == "" || address == "" || branch == ""){ - alert("You must input full data(Project name, Git password, Git address, Branch)"); + if(name == "" || address == "" || branch == ""){ + alert("You must input full data(Project name, Git address, Branch)"); return; } - changeInfoItem = {"DistId":distId, "Name":name, "ProjectPass":password, "Address":address, "Branch":branch, "ProjectStatus":projectStatus, "ProjectType":"GIT", "OSIdList":selectOsList.toString()}; + changeInfoItem = {"DistId":distId, "Name":name, "Address":address, "Branch":branch, "ProjectStatus":projectStatus, "ProjectType":"GIT", "OSIdList":selectOsList.toString()}; changeInfoList.push(changeInfoItem); addProject(changeInfoList, function () { @@ -129,7 +126,6 @@ function adminProjectAddBinaryProject() { var changeInfoItem; var distId = $("#adminProject-distribution-select option:selected").val(); var name = $("#adminProjectAddBinary-name").val(); - var password = $("#adminProjectAddBinary-password").val(); var pkgName = $("#adminProjectAddBinary-packagename").val(); var projectStatus = $("#adminProjectAddBinary-status option:selected").val(); var selectOsList = []; @@ -146,7 +142,7 @@ function adminProjectAddBinaryProject() { return; } - changeInfoItem = {"DistId":distId, "Name":name, "ProjectPass":password, "PackageName":pkgName, "ProjectStatus":projectStatus, "ProjectType":"BINARY", "OSIdList":selectOsList.toString()}; + changeInfoItem = {"DistId":distId, "Name":name, "PackageName":pkgName, "ProjectStatus":projectStatus, "ProjectType":"BINARY", "OSIdList":selectOsList.toString()}; changeInfoList.push(changeInfoItem); addProject(changeInfoList, function () { diff --git a/dibs-web/public/javascripts/admin-project-modify.js b/dibs-web/public/javascripts/admin-project-modify.js index be71258..49acac4 100644 --- a/dibs-web/public/javascripts/admin-project-modify.js +++ b/dibs-web/public/javascripts/admin-project-modify.js @@ -29,13 +29,11 @@ Contributors: function adminProjectModifyBinaryProjectInit(projectId) { var projectName = $("#adminProject-binary-"+projectId+"-name").html(); var projectStatus = $("#adminProject-binary-"+projectId+"-status").html(); - var projectPassword = $("#adminProject-binary-"+projectId+"-password").html(); var packageName = $("#adminProject-binary-"+projectId+"-packageName").html(); $("#adminProjectModifyBinary-save").attr("onClick", ""); $("#adminProjectModifyBinary-id").val(projectId); $("#adminProjectModifyBinary-name").val(projectName); - $("#adminProjectModifyBinary-password").val(projectPassword); $("#adminProjectModifyBinary-packageName").val(packageName); $("#adminProjectModifyBinary-status").empty(); $("#adminProjectModifyBinary-os").empty(); @@ -96,12 +94,10 @@ function adminProjectModifyGitProjectInit(projectId) { var projectAddress = $("#adminProject-git-"+projectId+"-address").html(); var projectBranch = $("#adminProject-git-"+projectId+"-branch").html(); var projectStatus = $("#adminProject-git-"+projectId+"-status").html(); - var projectPassword = $("#adminProject-git-"+projectId+"-password").html(); $("#adminProjectModifyGit-save").attr("onClick", ""); $("#adminProjectModifyGit-id").val(projectId); $("#adminProjectModifyGit-name").val(projectName); - $("#adminProjectModifyGit-password").val(projectPassword); $("#adminProjectModifyGit-address").val(projectAddress); $("#adminProjectModifyGit-branch").val(projectBranch); $("#adminProjectModifyGit-status").empty(); @@ -161,7 +157,6 @@ function adminProjectModfyBinaryProject() { var changeInfoItem; var projectId = $("#adminProjectModifyBinary-id").val(); var projectName = $("#adminProjectModifyBinary-name").val(); - var projectPassword = $("#adminProjectModifyBinary-password").val(); var projectStatus = $("#adminProjectModifyBinary-status option:selected").val(); var packageName = $("#adminProjectModifyBinary-packageName").val(); var selectOsList = []; @@ -170,12 +165,12 @@ function adminProjectModfyBinaryProject() { selectOsList.push($(this).val()); }); - if(projectId == "" || projectName == "" || projectPassword == "" || packageName == ""){ + if(projectId == "" || projectName == "" || packageName == ""){ alert("You must input full data"); return; } - changeInfoItem = {"Id":projectId, "Name":projectName, "ProjectPass":projectPassword, "ProjectStatus":projectStatus, "PackageName":packageName, "OSIdList":selectOsList.toString()}; + changeInfoItem = {"Id":projectId, "Name":projectName, "ProjectStatus":projectStatus, "PackageName":packageName, "OSIdList":selectOsList.toString()}; changeInfoList.push(changeInfoItem); modifyProject(changeInfoList, function () { @@ -189,7 +184,6 @@ function adminProjectModfyGitProject() { var changeInfoItem; var projectId = $("#adminProjectModifyGit-id").val(); var projectName = $("#adminProjectModifyGit-name").val(); - var projectPassword = $("#adminProjectModifyGit-password").val(); var projectAddress = $("#adminProjectModifyGit-address").val(); var projectBranch = $("#adminProjectModifyGit-branch").val(); var projectStatus = $("#adminProjectModifyGit-status option:selected").val(); @@ -199,12 +193,12 @@ function adminProjectModfyGitProject() { selectOsList.push($(this).val()); }); - if(projectId == "" || projectName == "" || projectPassword == "" || projectAddress == "" || projectBranch == ""){ + if(projectId == "" || projectName == "" || projectAddress == "" || projectBranch == ""){ alert("You must input full data"); return; } - changeInfoItem = {"Id":projectId, "Name":projectName, "ProjectPass":projectPassword, "ProjectAddress":projectAddress, "ProjectBranch":projectBranch, "ProjectStatus":projectStatus, "OSIdList":selectOsList.toString()}; + changeInfoItem = {"Id":projectId, "Name":projectName, "ProjectAddress":projectAddress, "ProjectBranch":projectBranch, "ProjectStatus":projectStatus, "OSIdList":selectOsList.toString()}; changeInfoList.push(changeInfoItem); modifyProject(changeInfoList, function () { diff --git a/dibs-web/public/javascripts/admin-project.js b/dibs-web/public/javascripts/admin-project.js index edaddce..7333d47 100644 --- a/dibs-web/public/javascripts/admin-project.js +++ b/dibs-web/public/javascripts/admin-project.js @@ -137,11 +137,6 @@ function adminProjectUpdateTable(projectList) { cell.setAttribute('id',"adminProject-git-"+id+"-status"); cell.innerHTML = projectStatus; - cell = row.insertCell(-1); - cell.setAttribute('hidden',"hidden"); - cell.setAttribute('id',"adminProject-git-"+id+"-password"); - cell.innerHTML = projectPassword; - cell = row.insertCell(-1); var button = document.createElement('a'); button.setAttribute('href','#adminProjectModifyGit'); @@ -185,11 +180,6 @@ function adminProjectUpdateTable(projectList) { cell.setAttribute('id',"adminProject-binary-"+id+"-status"); cell.innerHTML = projectStatus; - cell = row.insertCell(-1); - cell.setAttribute('hidden',"hidden"); - cell.setAttribute('id',"adminProject-binary-"+id+"-password"); - cell.innerHTML = projectPassword; - cell = row.insertCell(-1); var button = document.createElement('a'); button.setAttribute('href','#adminProjectModifyBinary');