diff --git a/Gemfile b/Gemfile index b482cb6fd..bb94100a5 100644 --- a/Gemfile +++ b/Gemfile @@ -3,14 +3,17 @@ source 'https://ruby.taobao.org/' unless RUBY_PLATFORM =~ /w32/ # unix-like only gem 'iconv' - gem "rmagick", "= 2.13.1" ## centos yum install ImageMagick-devel + if RUBY_PLATFORM =~ /darwin/ + gem "rmagick", "= 2.15.4" ## osx must be this version + else + gem "rmagick", "= 2.13.1" ## centos yum install ImageMagick-devel + end gem 'certified' + gem 'net-ssh', '2.9.1' + gem 'jenkins_api_client' + gem 'nokogiri' end -gem 'net-ssh', '2.9.1' -gem 'jenkins_api_client' -gem 'nokogiri' - gem 'wechat',path: 'lib/wechat' gem 'grack', path:'lib/grack' gem 'gitlab', path: 'lib/gitlab-cli' diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 33d988e35..8187055be 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -239,14 +239,23 @@ class AccountController < ApplicationController end def resendmail + result = {:status=>1, :email=>""} user = User.find(params[:user]) if params[:user] + result[:email] = user.mail token = Token.new(:user => user, :action => "register") if token.save - Mailer.run.register(token) - + # Mailer.run.register(token) + Mailer.register(token).deliver else yield if block_given? + result[:status] = 0 end + render :json => result + end + + def email_activation + + end private @@ -264,6 +273,7 @@ class AccountController < ApplicationController if user.nil? invalid_credentials elsif user.status == 2 + @user = user invalid_credentials_new elsif user.new_record? onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id }) @@ -375,8 +385,9 @@ class AccountController < ApplicationController def invalid_credentials_new logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" - flash[:error] = l(:notice_account_invalid_creditentials_new) - render signin_path(:login=>true) + # flash[:error] = l(:notice_account_invalid_creditentials_new) + # render signin_path(:login=>true) + render :action => 'email_activation' end # Register a user for email activation. diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 960bc61e6..a6b5f09cf 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -612,7 +612,7 @@ class AttachmentsController < ApplicationController @attachment.container.board.course) @course = @attachment.container.board.course else - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' + unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' @project = @attachment.project end end diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 9a72bb4df..ceb63d7b0 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -125,7 +125,9 @@ class BoardsController < ApplicationController if @order.to_i == 2 @type = 2 @topics.each do |topic| - topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count) + all_comments = [] + count=get_all_children(all_comments, topic).count + topic[:infocount] = get_praise_num(topic) + count if topic[:infocount] < 0 topic[:infocount] = 0 end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 8ef399d10..f5ad89832 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -44,7 +44,8 @@ class MessagesController < ApplicationController offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i]) page = 1 + offset / REPLIES_PER_PAGE end - @reply_count = @topic.children.count + all_comments = [] + @reply_count = get_all_children(all_comments, @topic).count @reply = Message.new(:subject => "RE: #{@message.subject}") if @course messages_replies = @topic.children. @@ -137,26 +138,32 @@ class MessagesController < ApplicationController # Reply to a topic def reply - if params[:reply][:content] == "" - if params[:is_board] - if @project - (redirect_to project_boards_path(@project), :notice => l(:label_reply_empty);return) - elsif @course - (redirect_to course_boards_path(@course), :notice => l(:label_reply_empty);return) - end - else - (redirect_to board_message_url(@board, @topic, :r => @reply), :notice => l(:label_reply_empty);return) - end + if params[:parent_id] + parent = Message.find params[:parent_id] + @reply = Message.new + @reply.author = User.current + @reply.board = parent.board + @reply.content = params[:content] + @reply.subject = "RE: #{parent.subject}" + @reply.reply_id = params[:reply_id] + # @reply.reply_id = params[:id] + parent.children << @reply + @topic = params[:activity_id].nil? ? parent : Message.find(params[:activity_id].to_i) + @user_activity_id = params[:user_activity_id] if params[:user_activity_id] + @is_course = params[:is_course] if params[:is_course] + @is_board = params[:is_board] if params[:is_board] + else + @quote = params[:quote][:quote] + @reply = Message.new + @reply.author = User.current + @reply.board = @board + @reply.safe_attributes = params[:reply] + @reply.content = @quote + @reply.content + @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject] + @topic.children << @reply + # @reply.reply_id = params[:id] end - @quote = params[:quote][:quote] - @reply = Message.new - @reply.author = User.current - @reply.board = @board - @reply.safe_attributes = params[:reply] - @reply.content = @quote + @reply.content - @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject] - # @reply.reply_id = params[:id] - @topic.children << @reply + update_course_activity(@topic.class,@topic.id) update_user_activity(@topic.class,@topic.id) update_forge_activity(@topic.class,@topic.id) @@ -182,14 +189,10 @@ class MessagesController < ApplicationController respond_to do |format| format.js end - elsif params[:is_board] - if @project - redirect_to project_boards_path(@project) - elsif @course - redirect_to course_boards_path(@course) - end + return else - redirect_to board_message_url(@board, @topic, :r => @reply) + redirect_to board_message_url(@board, @topic) + return end end @@ -251,6 +254,17 @@ class MessagesController < ApplicationController # Delete a messages def destroy + if params[:user_activity_id] + @message.destroy + @topic = Message.find(params[:activity_id].to_i) + @user_activity_id = params[:user_activity_id] + @is_course = params[:is_course] + @is_board = params[:is_board] + respond_to do |format| + format.js + end + return + end if @project (render_403; return false) unless @message.destroyable_by?(User.current) elsif @course @@ -299,12 +313,12 @@ class MessagesController < ApplicationController end def quote - @subject = @message.subject - @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') - - @content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> " - @temp = Message.new - @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, @message.author.show_name)}".html_safe + # @subject = @message.subject + # @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + # + # @content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> " + # @temp = Message.new + # @temp.content = "
#{@message.content.html_safe}
#{ll(Setting.default_language, :text_user_wrote, @message.author.show_name)}".html_safe end def preview diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 0883b3799..32c605516 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -127,12 +127,14 @@ class MyController < ApplicationController end @user.safe_attributes = params[:user] + @user.lastname = params[:lastname] + @user.firstname = "" @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') #@user.login = params[:login] unless @user.user_extensions.nil? if @user.user_extensions.identity == 2 - @user.firstname = params[:enterprise_name] + # @user.firstname = params[:enterprise_name] end end @@ -144,7 +146,7 @@ class MyController < ApplicationController # end @se.school_id = params[:occupation] - @se.gender = params[:gender] + @se.gender = params[:sex] @se.location = params[:province] if params[:province] @se.location_city = params[:city] if params[:city] @se.identity = params[:identity].to_i if params[:identity] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8664a1372..cb86f1165 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -653,12 +653,12 @@ class ProjectsController < ApplicationController def update @project.safe_attributes = params[:project] @project.organization_id = params[:organization_id] - params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0 - params[:project][:hidden_repo] ? @project.hidden_repo = 1 : @project.hidden_repo = 0 + params[:project][:is_public] == "on" ? @project.is_public = 1 : @project.is_public = 0 + params[:project][:hidden_repo] == "on" ? @project.hidden_repo = 1 : @project.hidden_repo = 0 # 更新公开私有时同步gitlab公开私有 - if !@project.gpid.nil? && @project.is_public != (params[:project][:is_public] == "on" ? true : false) + if !@project.gpid.nil? && @project.is_public != (params[:project][:is_public] == "on" ? 1 : 0) g = Gitlab.client - params[:project][:is_public] ? g.edit_project(@project.gpid, 20, params[:branch]) : g.edit_project(@project.gpid, 0, params[:branch]) + params[:project][:is_public] == "on" ? g.edit_project(@project.gpid, 20, params[:branch]) : g.edit_project(@project.gpid, 0, params[:branch]) end # end if validate_parent_id && @project.save diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 83e5960b9..bec66aeff 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -1,8 +1,11 @@ class QualityAnalysisController < ApplicationController before_filter :find_project_by_project_id#, :except => [:getattachtype] + before_filter :find_quality_analysis, :only => [:edit, :update_jenkins_job] before_filter :authorize + before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job, :index] layout "base_projects" include ApplicationHelper + include QualityAnalysisHelper require 'jenkins_api_client' require 'nokogiri' require 'json' @@ -12,72 +15,180 @@ class QualityAnalysisController < ApplicationController end + # params 说明:{identifier:版本库名} def create - gitlab_address = Redmine::Configuration['gitlab_address'] - jenkins_address = Redmine::Configuration['jenkins_address'] - @client = JenkinsApi::Client.new(:server_url => jenkins_address, - :username => "temp", - :password => '123123') - #@client.exists?(job_name) - @g = Gitlab.client - user_name = User.find(params[:user_id]).try(:login) - branch = params[:branch].nil? ? "master" : params[:branch] - language = params[:language] - path = params[:path] - identifier = params[:identifier] - qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first - version = qa.nil? ? 1 : qa.sonar_version + 1 - properties = "sonar.projectKey=#{user_name}:#{identifier} - sonar.projectName=#{user_name}:#{identifier} + begin + user_name = User.find(params[:user_id]).try(:login) + identifier = params[:identifier] + rep_id = params[:rep_id] + + # job_name and sonar_name 前者为job名字,后者为jenkins配置名 + job_name = "#{user_name}-#{rep_id}" + sonar_name = "#{user_name}:#{rep_id}" + + # Checks if the given job exists in Jenkins. + unless @client.job.exists?(job_name) + @g = Gitlab.client + branch = params[:branch] + language = swith_language_type(params[:language]) + path = params[:path].blank? ? "./" : params[:path] + qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first + version = qa.nil? ? 1 : qa.sonar_version + 1 + properties = "sonar.projectKey=#{sonar_name} + sonar.projectName=#{sonar_name} sonar.projectVersion=#{version} sonar.sources=#{path} sonar.language=#{language.downcase} sonar.sourceEncoding=utf-8" - git_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git" + git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git" - # # # modify config - @doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml'))) - @doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url - @doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}" - @doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties #sonar-properties - # - # replace config.xml of jenkins - @client = @client.job.create("#{user_name}_#{identifier}", @doc.to_xml) - # relace gitlab hook - # genkins address - @g.add_project_hook(@project.gpid, jenkins_address + "/project/#{user_name}_#{identifier}") - if qa.nil? - QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, :sonar_version => version, :path => path, :branch => branch, :language => language) + # 替换配置文件 + @doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml'))) + @doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url + @doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}" + @doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties - else - qa.update_attribute(:sonar_version, version) + # jenkins job创建 + jenkins_job = @client.job.create("#{job_name}", @doc.to_xml) + logger.info("Jenkins status of create ==> #{jenkins_job}") + + # 将地址作为hook值添加到gitlab + @g.add_project_hook(@project.gpid, @jenkins_address + "/project/#{job_name}") + # job创建完成后自动运行job,如果运行成功则返回‘200’ + code = @client.job.build("#{job_name}") + logger.error("build result ==> #{code}") + + # 判断调用sonar分析是否成功 + # 等待启动时间处理, 最长时间为30分钟 + for i in 0..60 do + sleep(60) + @current_build_status = @client.job.get_current_build_status("#{job_name}") + if (@current_build_status != "not_run" || @current_build_status != "running") + break + if i == 60 + @build_console_result = false + break + end + end + end + + @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text') + logger.info("@current_build_status is ==> #{@current_build_status}") + logger.info("@console_build is ==> #{@console_build}") + + d = @client.job.delete("#{job_name}") if jenkins_job == '200' && code != '201' + logger.error("delete result ==> #{code}") + if qa.blank? && @current_build_status == "success" + QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, + :sonar_version => version, :path => path, :branch => branch, :language => language, :sonar_name => "#{user_name}:#{rep_id}") + else + qa.update_attribute(:sonar_version, version) + end + end + rescue => e + puts e + end + respond_to do |format| + format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)} + # format.js{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)} end end + # get language type + def swith_language_type language + if language == "c#" + "cs" + elsif language == "python" + "py" + elsif language == "c" + "c++" + else + language + end + end + + def edit + @g = Gitlab.client + gitlab_branches = @g.branches(@project.gpid) + @branch_names = gitlab_branches.map{|b| b.name} + @gitlab_default_branch = @g.project(@project.gpid).default_branch + end + + # 更新Jenkins job,主要包括相关配置文件参数的更新,Trustie平台数据的更新 + def update_jenkins_job + begin + rep_id = Repository.where(:project_id => @project.id).first.try(:id) + logger.error("#############################===>666") + sonar_name = @quality_analysis.sonar_name + job_name = "#{@quality_analysis.author_login}-#{rep_id}" + version = @quality_analysis.sonar_version + path = params[:path].blank? ? "./" : params[:path] + language = swith_language_type(params[:language]) + branch = params[:branch] + identifier = @quality_analysis.rep_identifier + properties = "sonar.projectKey=#{sonar_name} + sonar.projectName=#{sonar_name} + sonar.projectVersion=#{version} + sonar.sources=#{path} + sonar.language=#{language.downcase} + sonar.sourceEncoding=utf-8" + git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git" + + # modify config.yml + @doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml'))) + @doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url + @doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}" + @doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties + + # update成功则返回 ‘200’ + jenkins_job = @client.job.update("#{job_name}", @doc.to_xml) + get_current_build_status = @client.job.get_current_build_status("Hjqreturn-1280") + logger.error("Failed to update job: ==> #{jenkins_job}") unless jenkins_job == '200' + + # 数据更新到Trustie数据库 + if jenkins_job == '200' + logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}") + @quality_analysis.path = path + @quality_analysis.language = language + @quality_analysis.branch = branch + @quality_analysis.save + end + rescue Exception => e + logger.error("Update jenkins job: #{e}") + end + respond_to do |format| + format.html{redirect_to project_quality_analysis_path(:project_id => @project.id)} + format.js + end + end + + # resource_id: login + @repository.id def index - @sonar_address = Redmine::Configuration['sonar_address'] - # if params[:resource_id].nil? - # @name_flag = true - # @quality_analyses = QualityAnalysis.where(:project_id => @project.id) - # # @quality_analyses.map {|qa| qa.} - # # if @quality_analyses.count > 0 - # # @quality_analyses.each do |qa| - # # ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"] - # # - # # end - # # end - # # projects_date = open(@sonar_address + "/api/projects/index").read - # # arr = JSON.parse(projects_date).map {|m| m["nm"]} - # # arr.map - # else - qa = QualityAnalysis.where(:project_id => @project.id).first - @resource_id = qa.author_login+":"+qa.rep_identifier - @name_flag = false - complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,file_line,files,functions,classes,directories").read - @complexity =JSON.parse(complexity_date).first - issue_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations").read - @sonar_issues = JSON.parse(issue_date).first - # end + begin + @branch = params[:branch] + @resource_id = params[:resource_id] + @sonar_address = Redmine::Configuration['sonar_address'] + @jenkins_address = Redmine::Configuration['jenkins_address'] + if params[:resource_id].nil? + @name_flag = true + projects_date = open(@sonar_address + "/api/projects/index").read + arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"] + @quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)} + + else + if params[:current_build_status] == "failure" + job_name = params[:job_name] + @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"] + end + complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,file_line,files,functions,classes,directories").read + @complexity =JSON.parse(complexity_date).first + issue_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations").read + @sonar_issues = JSON.parse(issue_date).first + end + rescue => e + puts e + end + end # Find project of id params[:project_id] @@ -87,6 +198,14 @@ class QualityAnalysisController < ApplicationController render_404 end + def find_quality_analysis + begin + @quality_analysis = QualityAnalysis.find(params[:id]) + rescue + render_404 + end + end + # Authorize the user for the requested action def authorize(ctrl = params[:controller], action = params[:action], global = false) unless @project.archived? && @project.gpid.nil? @@ -96,4 +215,14 @@ class QualityAnalysisController < ApplicationController end end + def connect_jenkins + @gitlab_address = Redmine::Configuration['gitlab_address'] + @jenkins_address = Redmine::Configuration['jenkins_address'] + + # connect jenkins + @client = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => "temp", :password => '123123') + rescue => e + logger.error("failed to connect Jenkins ==> #{e}") + end + end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index cbb5b2f69..d0904ddf5 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -20,6 +20,8 @@ require 'SVG/Graph/BarHorizontal' require 'digest/sha1' require 'redmine/scm/adapters/abstract_adapter' require 'tempfile' +require 'json' +require 'open-uri' class ChangesetNotFound < Exception; end class InvalidRevisionParam < Exception; end @@ -372,7 +374,7 @@ update @changesets = g.commits(@project.gpid, :ref_name => @rev) g_project = g.project(@project.gpid) # 总的提交数 - @changesets_all_count = @project.gpid.nil? ? 0 : g_project.commit_count + @changesets_all_count = @project.gpid.nil? ? 0 : commit_count(@project, @rev) @g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch # 访问该页面的是会后则刷新 if @project.project_score.nil? diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index e0aff6254..44f4378fe 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -150,4 +150,55 @@ class SchoolController < ApplicationController format.js end end + + #申请高校(单位) name:名称 province:省 city:市 address:地址 remarks:备注 + def apply_add_school + + data = {result:0,name:params[:name],school_id:0} + #0 成功 1参数错误 2名称已存在 + data[:result] = 0 + + #检验参数 + if params[:name] == "" || params[:province] == "" || params[:city] == "" || params[:address] == "" + data[:result] = 1 + else + school_id = School.find_by_sql("select id from schools where name='#{params[:name]}'").first + if school_id + data[:result] = 2 + else + school = School.new + school.name = params[:name].strip + school.pinyin = Pinyin.t(params[:name].strip, splitter: '') + school.save + + #status 0未处理 1通过 2拒绝 + applyschool = ApplyAddSchools.new + applyschool.school_id = school.id + applyschool.name = school.name + applyschool.province = params[:province] + applyschool.city = params[:city] + applyschool.address = params[:address] + applyschool.remarks = params[:remarks] + applyschool.save + + data[:school_id] = school.id + end + end + render :json =>data + end + + def search_repeat_schoolname + status = 0 + name = params[:name] + + if name + school_id = School.find_by_sql("select id from schools where name='#{name}'").first + + if school_id + status = 1 + end + end + + render :json =>status + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f96056457..2925950e6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -90,6 +90,8 @@ class UsersController < ApplicationController case params[:type] when 'JournalsForMessage' @comment = JournalsForMessage.find params[:comment].to_i + when 'Message' + @comment = Message.find params[:comment].to_i end end @@ -111,6 +113,13 @@ class UsersController < ApplicationController @user_activity_id = params[:user_activity_id] @activity_id = params[:activity_id] @type = 'JournalsForMessage' + when 'Message' + @reply = Message.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @is_course = params[:is_course] + @is_board = params[:is_board] + @type = 'Message' end respond_to do |format| format.js @@ -1248,6 +1257,12 @@ class UsersController < ApplicationController render :layout=>'new_base_user' end + #给某人留言 + def feedBackTo + + + end + def user_comments end @@ -3275,7 +3290,12 @@ class UsersController < ApplicationController @journals = obj.children.reorder("created_at desc") when 'Message' obj = Message.where('id = ?', params[:id].to_i).first - @journals = obj.children.reorder("created_on desc") + @type = 'Message' + @is_course = params[:is_course] + @is_board = params[:is_board] + @user_activity_id = params[:div_id].to_i if params[:div_id] + comments = [] + @journals = get_all_children(comments, obj) when 'News' obj = News.where('id = ?', params[:id].to_i).first @journals = obj.comments.reorder("created_on desc") diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 188531c37..828739cc4 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -359,6 +359,27 @@ class WordsController < ApplicationController UserExtensions.introduction(user, message) redirect_to user_url(user.id) end + + #邮箱激活问题留言 留言成功给出提示框 + def leave_email_activation_message + status = 1 #成功 + me = User.find(params[:user]) + if me + #课程使者id=1 + @user = User.find(1) + if params[:text].size>0 && @user + # @user.add_jour(me, params[:text]) + #私信 + message = "【未收到激活邮件的用户反馈,用户邮箱:"+me.mail+"】
#{@message.content.html_safe}
您的账号尚未激活,请先进入您的注册邮箱,激活您的账号。
+ + <%#= link_to l(:label_mail_resend), { :controller => 'account', :action => 'resendmail',:user => @user}, :class=>"email_verify_btn mt30 ml30", :remote => true, :method => 'get' %> +如果您尚未收到激活邮件,请按照以下步骤操作:
+<%= f.text_field :login, :size => 25, :required => true %> - <%= l(:label_max_number) %> -
-<%= f.password_field :password, :size => 25, :required => true %> - <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %> -
-<%= f.password_field :password_confirmation, :size => 25, :required => true %>
- <% end %> - -- <%= f.text_field :mail,:size => 25, :required => true %> - -
-
-
- <%= "#{l(:label_mail_attention)} " %> <%= "#{l(:label_mail_attention1)} " %>
-
<%= submit_tag l(:button_submit) %> | -
<%= f.text_field :identity_url %>
-<% end %> -<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %> -<%= custom_field_tag_with_label :user, value %>
-<% end %> - -<% password_min_length = Setting.password_min_length %> - \ No newline at end of file diff --git a/app/views/attachments/_form_course.html.erb b/app/views/attachments/_form_course.html.erb index 6d921903d..1d51e951a 100644 --- a/app/views/attachments/_form_course.html.erb +++ b/app/views/attachments/_form_course.html.erb @@ -2,31 +2,31 @@ <% if defined?(container) && container && container.saved_attachments %> <% if isReply %> <% container.saved_attachments.each_with_index do |attachment, i| %> - +<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly', :readonly=>'readonly')%> <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%> - <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "#{i+1}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload', :containerid => "2") %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> -
+ <% end %> <% else %> <% container.attachments.each_with_index do |attachment, i| %> - + <% end %> <% end %> <% end %> diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 7d8aaed86..b1cd86484 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -91,9 +91,10 @@请加入师姐师兄答疑群
QQ群号:173184401
+ + + diff --git a/app/views/layouts/_syllabus_base_info.html.erb b/app/views/layouts/_syllabus_base_info.html.erb index cf4926d82..4b205d356 100644 --- a/app/views/layouts/_syllabus_base_info.html.erb +++ b/app/views/layouts/_syllabus_base_info.html.erb @@ -1,10 +1,10 @@ -该模块暂时没有相关内容
<% else %> diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index ddc504640..9d043fbb5 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -63,9 +63,9 @@ <% when 'course' %>质量等级
-<%= @complexity["msr"][9]["frmt_val"] %>
+<% if @complexity["msr"].count > 3 %> + <%= render :partial => "hightchars" %> +质量等级
+<%= @complexity["msr"][9].nil? ? "A" : @complexity["msr"][9]["frmt_val"] %> +
+复杂度
+<%= @complexity["msr"][6].nil? ? 0 : @complexity["msr"][6]["val"] %> +
+复杂度
-<%= @complexity["msr"][6]["val"] %>
+代码重复度
+<%= @complexity["msr"][7].nil? ? 0 : @complexity["msr"][7]["frmt_val"] %> +
+注释率
+<%= @complexity["msr"][5].nil? ? 0 : @complexity["msr"][5]["frmt_val"] %> +
+代码重复度
-<%= @complexity["msr"][7]["frmt_val"] %>
-注释率
-<%= @complexity["msr"][5]["frmt_val"] %>
-代码行数
-<%= @complexity["msr"][0]["frmt_val"] %>
+<%= @complexity["msr"][0].nil? ? 0 : @complexity["msr"][0]["frmt_val"] %>
文件
-<%= @complexity["msr"][2]["frmt_val"] %>
+<%= @complexity["msr"][2].nil? ? 0 : @complexity["msr"][2]["frmt_val"] %>
目录
-<%= @complexity["msr"][3]["frmt_val"] %>
+<%= @complexity["msr"][3].nil? ? 0 : @complexity["msr"][3]["frmt_val"] %>
类
-<%= @complexity["msr"][1]["frmt_val"] %>
+<%= @complexity["msr"][1].nil? ? 0 : @complexity["msr"][1]["frmt_val"] %>
方法
-<%= @complexity["msr"][4]["frmt_val"] %>
+<%=@complexity["msr"][4].nil? ? 0 : @complexity["msr"][4]["frmt_val"] %>
创建老师:<%=@syllabus.user.show_name %> 创建时间:<%=format_date @syllabus.created_at %>
+<%= count>0 ? "#{count}" : "0" %>回复|<%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %>赞
<%= count>0 ? "#{count}" : "0" %>回复|<%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %>赞
更新:<%=course.time %>学期:<%=current_time_and_term(course) %>
+更新:<%=format_date Time.at(course.updatetime) %>学期:<%=current_time_and_term(course) %>
<%=studentCount course %>学生|<%=visable_course_homework course %>作业|<%=visable_attachemnts_incourse(@course).count %>资源