diff --git a/Gemfile b/Gemfile index a8131fb3f..11acafe3c 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,11 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end -gem 'certified' +gem 'net-ssh', '2.9.1' +gem 'jenkins_api_client' +gem 'nokogiri' + +# gem 'certified' gem 'wechat',path: 'lib/wechat' gem 'grack', path:'lib/grack' diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 58d4a4f8c..6696b8360 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -103,7 +103,7 @@ module Mobile post "join" do authenticate! cs = CoursesService.new - status = cs.join_course({openid: params[:openid], invite_code: params[:invite_code]}, current_user) + status = cs.join_course({role: "10", openid: params[:openid], invite_code: params[:invite_code]}, current_user) { status: status[:state], messsge:CoursesService::JoinCourseError.message(status[:state]) diff --git a/app/assets/javascripts/quality_analyses.js.coffee b/app/assets/javascripts/quality_analyses.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/quality_analyses.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/quality_analyses.css.scss b/app/assets/stylesheets/quality_analyses.css.scss new file mode 100644 index 000000000..9404eb70f --- /dev/null +++ b/app/assets/stylesheets/quality_analyses.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the QualityAnalyses controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 43b488e96..7dea90e4b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1305,12 +1305,12 @@ class CoursesController < ApplicationController sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) if home.anonymous_comment ==0 sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) - sheet[count_row,9] = home.teacher_priority == 1 ? 0 : stu.absence_penalty - sheet[count_row,10] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,12] = format_time(stu.created_at) else - sheet[count_row,8] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,10] = format_time(stu.created_at) end @@ -1338,12 +1338,12 @@ class CoursesController < ApplicationController sheet[count_row,8] = stu.system_score.nil? ? l(:label_without_score) : stu.system_score.round(2) if home.anonymous_comment ==0 sheet[count_row,9] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) - sheet[count_row,10] = home.teacher_priority == 1 ? 0 : stu.absence_penalty - sheet[count_row,11] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,11] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty sheet[count_row,12] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,13] = format_time(stu.created_at) else - sheet[count_row,9] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,11] = format_time(stu.created_at) end @@ -1369,12 +1369,12 @@ class CoursesController < ApplicationController sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) if home.anonymous_comment ==0 sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) - sheet[count_row,8] = home.teacher_priority == 1 ? 0 : stu.absence_penalty - sheet[count_row,9] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,11] = format_time(stu.created_at) else - sheet[count_row,7] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) sheet[count_row,9] = format_time(stu.created_at) end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c8b272480..c216491b1 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -393,7 +393,7 @@ class ProjectsController < ApplicationController unless @project.gpid.nil? g = Gitlab.client @gitlab_branches = g.branches(@project.gpid) - @branch_names = g.branches(@project.gpid).map{|b| b.name} + @branch_names = @gitlab_branches.map{|b| b.name} @gitlab_default_branch = g.project(@project.gpid).default_branch end end @@ -645,7 +645,7 @@ class ProjectsController < ApplicationController params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0 params[:project][:hidden_repo] ? @project.hidden_repo = 1 : @project.hidden_repo = 0 # 更新公开私有时同步gitlab公开私有 - unless @project.gpid.nil? + if !@project.gpid.nil? && @project.is_public != (params[:project][:is_public] == "on" ? true : false) g = Gitlab.client params[:project][:is_public] ? g.edit_project(@project.gpid, 20, params[:branch]) : g.edit_project(@project.gpid, 0, params[:branch]) end diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb new file mode 100644 index 000000000..83e5960b9 --- /dev/null +++ b/app/controllers/quality_analysis_controller.rb @@ -0,0 +1,99 @@ +class QualityAnalysisController < ApplicationController + before_filter :find_project_by_project_id#, :except => [:getattachtype] + before_filter :authorize + layout "base_projects" + include ApplicationHelper + require 'jenkins_api_client' + require 'nokogiri' + require 'json' + require 'open-uri' + + def show + + end + + 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} + 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 + @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) + + else + qa.update_attribute(:sonar_version, version) + end + end + + 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 + end + + # Find project of id params[:project_id] + def find_project_by_project_id + @project = Project.find(params[:project_id]) + rescue ActiveRecord::RecordNotFound + render_404 + end + + # Authorize the user for the requested action + def authorize(ctrl = params[:controller], action = params[:action], global = false) + unless @project.archived? && @project.gpid.nil? + true + else + render_403 :message => :notice_not_authorized_archived_project + end + end + +end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 9e785c562..cbb5b2f69 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -30,11 +30,13 @@ class RepositoriesController < ApplicationController menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers] default_search_scope :changesets - before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats] + before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analysis] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :project_archive] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] - before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive] + before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive, :quality_analysis] + # 链接gitlab + before_filter :connect_gitlab, :only => [:quality_analysis] accept_rss_auth :revisions # hidden repositories filter // 隐藏代码过滤器 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -43,6 +45,7 @@ class RepositoriesController < ApplicationController helper :project_score #@root_path = RepositoriesHelper::ROOT_PATH $g=Gitlab.client + require 'net/ssh' rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new @@ -306,6 +309,37 @@ update end end + def quality_analysis + gitlab_branches = @g.branches(@project.gpid) + @branch_names = gitlab_branches.map{|b| b.name} + @gitlab_default_branch = @g.project(@project.gpid).default_branch + # language = params[:language] + # branch = params[:branch] + # path = params[:path] + # user_name = User.find(@project.user_id).try(:login) + # rep_name = params[:repository_id] + # host = "192.168.0.200" + # port = "1125" + # username = "git" + # password = "123123" + # server_cmd1 = "sh gitclone.sh" + " " + user_name + " " + rep_name + # # 连接到远程主机 foobar + # ssh = Net::SSH.start(host, username, :port => port, :password => password) do |ssh| + # result = ssh.exec!(server_cmd1) + # path = "/home/git/repo/" + user_name + "/" + rep_name + # # sonar 分析 + # # server_cmd2 + # # 删除clone的版本库 + # # server_cmd3 + # end + respond_to do |format| + format.js + format.html{ + render :layout => "base_projects" + } + end + end + def destroy DestroyRepositoryTask.new.destroy(User.current.id, @repository.id) @repository.hidden = true @@ -615,6 +649,14 @@ update project.project_score.update_attribute(:commit_time, date.created_at) end + # 链接gitlab + def connect_gitlab + @g = Gitlab.client + unless @project.gpid.nil? + @g_project = @g.project(@project.gpid) + end + end + def find_repository @repository = Repository.find(params[:id]) @project = @repository.project diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 3a72ba55e..9006c8a79 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1230,12 +1230,12 @@ class StudentWorkController < ApplicationController sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) if @homework.anonymous_comment ==0 sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,10] = @homework.teacher_priority == 1 ? 0 : homework.absence_penalty - sheet1[count_row,11] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,10] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.absence_penalty + sheet1[count_row,11] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,12] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,13] = format_time(homework.created_at) else - sheet1[count_row,9] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,9] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,11] = format_time(homework.created_at) end @@ -1263,12 +1263,12 @@ class StudentWorkController < ApplicationController sheet1[count_row,9] = homework.system_score.nil? ? l(:label_without_score) : homework.system_score.round(2) if @homework.anonymous_comment ==0 sheet1[count_row,10] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,11] = @homework.teacher_priority == 1 ? 0 : homework.absence_penalty - sheet1[count_row,12] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,11] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.absence_penalty + sheet1[count_row,12] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,13] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,14] = format_time(homework.created_at) else - sheet1[count_row,10] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,10] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,11] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,12] = format_time(homework.created_at) end @@ -1292,12 +1292,12 @@ class StudentWorkController < ApplicationController sheet1[count_row,5] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) if @homework.anonymous_comment ==0 sheet1[count_row,6] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,7] = @homework.teacher_priority == 1 ? 0 : homework.absence_penalty - sheet1[count_row,8] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,7] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.absence_penalty + sheet1[count_row,8] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,10] = format_time(homework.created_at) else - sheet1[count_row,6] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,6] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,7] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) sheet1[count_row,8] = format_time(homework.created_at) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c1f5863b8..b7972ff6f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1498,8 +1498,8 @@ class UsersController < ApplicationController # 减少数据库交互 watched_user_ids = User.watched_by(@user.id).count == 0 ? " " : ("," + User.watched_by(@user.id).map{|u| u.id.to_s }.join(',')) user_ids = "(" + @user.id.to_s + watched_user_ids + ")" - watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",") - blog_ids = "(" + watched_user_blog_ids + ")" + watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}") + blog_ids = watched_user_blog_ids.empty? ? "(-1)" : "(" + watched_user_blog_ids.map { |blog| blog.id}.join(",") + ")" @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 15d4ab2e1..7dcfa1948 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -4,22 +4,11 @@ class WechatsController < ActionController::Base include ApplicationHelper # ROOT_URL = "#{Setting.protocol}://#{Setting.host_name}/" - ROOT_URL = "http://wechat.trustie.net" + ROOT_URL = "http://www.trustie.net" # default text responder when no other match on :text do |request, content| #邀请码 - begin - uw = user_binded?(request[:FromUserName]) - if !uw - return sendBind() - else - return join_class({invite_code: content}, uw.user) - end - rescue => e - logger.error e.inspect - logger.error e.backtrace.join("\n") - return request.reply.text e - end + sendBindClass(request, {invite_code: content}) end # When receive 'help', will trigger this responder @@ -48,24 +37,13 @@ class WechatsController < ActionController::Base # When subscribe user scan scene_id in public account on :scan, with: 'scene_id' do |request, ticket| - begin - uw = user_binded?(request[:FromUserName]) - if !uw - return sendBind() - else - return join_class({ticket: ticket}, uw.user) - end - rescue => e - logger.error e.inspect - logger.error e.backtrace.join("\n") - return request.reply.text e - end + sendBindClass(request, {ticket: ticket}) end # When no any on :scan responder can match subscribe user scaned scene_id on :event, with: 'scan' do |request| if request[:EventKey].present? - request.reply.text "event scan got EventKey #{request[:EventKey]} Ticket #{request[:Ticket]}" + sendBindClass(request, {ticket: request[:Ticket]}) end end @@ -86,6 +64,9 @@ class WechatsController < ActionController::Base request.reply.text "User: #{request[:FromUserName]} click #{key}" end + on :click, with: 'DEV' do |request, key| + request.reply.text "此功能正在开发中,请耐心等待。" + end # When user view URL in the menu button on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| request.reply.text "#{request[:FromUserName]} view #{view}" @@ -161,6 +142,22 @@ class WechatsController < ActionController::Base end end + + def sendBindClass(request, params) + begin + uw = user_binded?(request[:FromUserName]) + if !uw + return sendBind(request) + else + return join_class(params, uw.user, request) + end + rescue => e + logger.error e.inspect + logger.error e.backtrace.join("\n") + return request.reply.text e + end + end + def default_msg(request) uw = user_binded?(request[:FromUserName]) if uw && uw.user @@ -187,20 +184,19 @@ class WechatsController < ActionController::Base end end - def join_class(params, user) + def join_class(params, user, request) course = nil - course = Course.where(qrcode: params[:ticket]) if params[:ticket] - course = Course.where(invite_code: params[:invite_code]) if params[:invite_code] - raise "课程不存在" if course.blank? + course = Course.where(qrcode: params[:ticket]).first if params[:ticket] + course = Course.where(invite_code: params[:invite_code]).first if params[:invite_code] + raise "课程不存在" unless course cs = CoursesService.new - status = cs.join_course(course.invite_code, user) + status = cs.join_course({invite_code: course.invite_code}, user) logger.info status if status[:state] != 0 raise CoursesService::JoinCourseError.message(status[:state]) end - course = status[:course] news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!', content: "课程名称: #{course.name}\n班级名称: #{course.name}\n任课老师: #{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} } return request.reply.news(news) do |article, n, index| # article is return object diff --git a/app/helpers/quality_analysis_helper.rb b/app/helpers/quality_analysis_helper.rb new file mode 100644 index 000000000..9c6c07109 --- /dev/null +++ b/app/helpers/quality_analysis_helper.rb @@ -0,0 +1,97 @@ +# encoding: utf-8 +module QualityAnalysisHelper + + def sqale_rating_status val + arr = [] + if val.to_i > 0 && val.to_i < 5 + arr << "很好" + arr << "b_green2" + elsif val.to_i > 5 && val.to_i < 10 + arr << "较好" + arr << "b_slow_yellow" + elsif val.to_i > 10 && val.to_i < 20 + arr << "中等" + arr << "b_yellow" + elsif val.to_i > 20 && val.to_i < 50 + arr << "较差" + arr << "b_slow_red" + elsif val.to_i > 20 + arr << "很差" + arr << "b_red" + end + end + + def complexity_status val + arr = [] + if val.to_i < 10 + arr << "良好" + arr << "b_green2" + elsif val.to_i > 10 && val.to_i < 15 + arr << "较高" + arr << "b_yellow" + elsif val.to_i > 15 + arr << "很高" + arr << "b_red" + end + end + + def duplicated_lines_density_status val + arr = [] + if val.to_i < 30 + arr << "良好" + arr << "b_green2" + elsif val.to_i > 30 && val.to_i < 50 + arr << "较高" + arr << "b_yellow" + elsif val.to_i > 50 + arr << "很高" + arr << "b_red" + end + end + + def comment_lines_density_status val + arr = [] + if val.to_i < 20 + arr << "较低" + arr << "b_yellow" + elsif val.to_i > 20 && val.to_i < 50 + arr << "正常" + arr << "b_green2" + elsif val.to_i > 50 + arr << "较高" + arr << "b_red" + end + end + + def score_sqale_rating val + if val.to_i > 0 && val.to_i < 5 + "5" + elsif val.to_i > 5 && val.to_i < 10 + "4" + elsif val.to_i > 10 && val.to_i < 20 + "3" + elsif val.to_i > 20 && val.to_i < 50 + "2" + elsif val.to_i > 20 + "1" + end + end + + def lines_scale val + if val.to_i < 5000 + "小型" + elsif val.to_i >5000 && val.to_i < 50000 + "中型" + else + "大型" + end + end + + #统计答题百分比,统计结果保留两位小数 + def statistics_result_percentage(e, t) + e = e.to_f + t = t.to_f + t == 0 ? 0 : format("%.2f", e*100/t) + end + +end diff --git a/app/models/project.rb b/app/models/project.rb index ceec0e182..bbc639f3d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -155,7 +155,7 @@ class Project < ActiveRecord::Base #ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用 after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?} # 创建project之后默认创建一个board,之后的board去掉了board的概念 - after_create :create_board_sync,:acts_as_forge_activities,:create_project_ealasticsearch_index + after_create :create_board_sync,:acts_as_forge_activities, :create_project_ealasticsearch_index before_destroy :delete_all_members,:delete_project_ealasticsearch_index after_update :update_project_ealasticsearch_index def remove_references_before_destroy diff --git a/app/models/quality_analysis.rb b/app/models/quality_analysis.rb new file mode 100644 index 000000000..229be9826 --- /dev/null +++ b/app/models/quality_analysis.rb @@ -0,0 +1,7 @@ +class QualityAnalysis < ActiveRecord::Base + attr_accessible :author_login, :project_id, :rep_identifier, :sonar_version, :branch, :path, :rep_identifier, :language + + def user_rep_name + self.author_login+":"+self.rep_identifier + end +end diff --git a/app/models/sonar_analysis.rb b/app/models/sonar_analysis.rb new file mode 100644 index 000000000..0bb2089de --- /dev/null +++ b/app/models/sonar_analysis.rb @@ -0,0 +1,3 @@ +class SonarAnalysis < ActiveRecord::Base + attr_accessible :author_login, :project_id, :rep_identifier +end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 41fb18b61..60c053997 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -351,7 +351,7 @@ class CoursesService #如果加入角色为教师或者教辅,并且当前是学生,或者是要成为教辅,当前不是教辅,或者要成为教师,当前不是教师。那么要发送请求 elsif (params[:role] != "10" && roleName == "Student") || (params[:role] == "7" && roleName != "TeachingAsistant" ) || (params[:role] == "9" && roleName != "Teacher" ) #如果已经发送过消息了,那么就要给个提示 - if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count != 0 + if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count != 0 @state = 7 else Mailer.run.join_course_request(course, User.current, params[:role]) diff --git a/app/views/attachments/_show_attachment_history.html.erb b/app/views/attachments/_show_attachment_history.html.erb index 6e2994a8d..61ccef344 100644 --- a/app/views/attachments/_show_attachment_history.html.erb +++ b/app/views/attachments/_show_attachment_history.html.erb @@ -1,7 +1,7 @@ 更新资源版本 -
+
当前版本 @@ -39,19 +39,19 @@
+
+ (未选择文件) + 您可以上传小于50MB的文件 +
- +

描述:

- +
-
-
(未选择文件)
-
您可以上传小于50MB的文件
-
diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index 0799953bf..96c9a2b7d 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -49,7 +49,7 @@
-

快速进入课程通道

+

快速加入课程通道

只要持有课程邀请码,就可以快速加入所在课程。课程页面搜索不到的私有课程只能从此通道进入哦!

@@ -68,7 +68,7 @@
  • 课程邀请码是所在课程页面中显示的邀请码
  • - 身      份: + <% if User.current.logged? && User.current.extensions && User.current.extensions.identity == 0%> +
  • <% else %>
    - <% unless file.description.blank? %> -
    -
    资源描述:<%= file.description %>
    - <% end %> + 资源描述:<% if file.description.blank? %>未添加<% else %><%= file.description %><% end %>
    <% end %> diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index b8b38f7b9..4d3645a33 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -48,15 +48,12 @@
    <%= render :partial => 'files/file_description', :locals => {:file => file} %>
    -
    <% else %>
    - <% unless file.description.blank? %> -
    -
    资源描述:<%= file.description %>
    - <% end %> + 资源描述:<% if file.description.blank? %>未添加<% else %><%= file.description %><% end %>
    <% end %>
    diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index 48fb4c86f..36dc80a18 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -40,16 +40,13 @@
    <%= render :partial => 'files/file_description', :locals => {:file => file} %>
    -
    <% else %> -
    - <% unless file.description.blank? %> -
    -
    资源描述:<%= file.description %>
    - <% end %> -
    +
    + 资源描述:<% if file.description.blank? %>未添加<% else %><%= file.description %><% end %> +
    <% end %>
    diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index 8aedc3c03..0edf22e58 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -42,15 +42,12 @@
    <%= render :partial => 'files/file_description', :locals => {:file => file} %>
    -
    <% else %>
    - <% unless file.description.blank? %> -
    -
    资源描述:<%= file.description %>
    - <% end %> + 资源描述:<% if file.description.blank? %>未添加<% else %><%= file.description %><% end %>
    <% end %> <%# end %> diff --git a/app/views/forums/create.js.erb b/app/views/forums/create.js.erb index bea3f3872..ee8172cbd 100644 --- a/app/views/forums/create.js.erb +++ b/app/views/forums/create.js.erb @@ -1,7 +1,7 @@ <%if @save_flag%> //$('#new_forum_div').slideToggle();$('#create_btn').parent().slideToggle(); //$('#reorder_time').click(); - window.location.href= "http://"+"<%= Setting.host_name%>"+"/forums/" + "<%= @forum.id%>" + window.location.href= "<%= host_with_protocol %>"+"/forums/" + "<%= @forum.id%>" <%else%> $("#error").html("<%= @forum.errors.full_messages[0]%>").show(); <%end %> diff --git a/app/views/layouts/_show_messages_list.html.erb b/app/views/layouts/_show_messages_list.html.erb index f67250e46..a4df961d3 100644 --- a/app/views/layouts/_show_messages_list.html.erb +++ b/app/views/layouts/_show_messages_list.html.erb @@ -5,18 +5,20 @@ diff --git a/app/views/organizations/_org_custom_left1.html.erb b/app/views/organizations/_org_custom_left1.html.erb index ee88f3315..8632dd57a 100644 --- a/app/views/organizations/_org_custom_left1.html.erb +++ b/app/views/organizations/_org_custom_left1.html.erb @@ -66,7 +66,7 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{get_image_path_from_content(document.content)}", :width => "299", :height => "246"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank" %> <% end %> -
    +
    <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => document.title %>

    <%= time_from_now(document.created_at) %><%= link_to document.creator.show_name, user_path(document.creator), :class => "por_hot_name link-blue", :target => "_blank" %>

    <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => document.id, :content=> document.content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> @@ -85,9 +85,11 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{get_image_path_from_content(content)}", :width => "299", :height => "246"), board_message_url_in_org(message.board.id, message.id), :target => "_blank" %> <% end %> - <%= link_to title, board_message_url_in_org(message.board.id, message.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => title %> -

    <%= time_from_now(message.created_on) %><%= link_to message.author.show_name, user_path(message.author), :class => "por_hot_name link-blue", :target => "_blank" %>

    - <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => message.id, :content=> content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
    + <%= link_to title, board_message_url_in_org(message.board.id, message.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => title %> +

    <%= time_from_now(message.created_on) %><%= link_to message.author.show_name, user_path(message.author), :class => "por_hot_name link-blue", :target => "_blank" %>

    + <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => message.id, :content=> content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
    <% else %>
    @@ -96,9 +98,11 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{get_image_path_from_content(content)}", :width => "299", :height => "246"), board_message_path(message.board.id, message.id), :target => "_blank" %> <% end %> - <%= link_to title, board_message_path(message.board.id, message.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => title %> -

    <%= time_from_now(message.created_on) %><%= link_to message.author.show_name, user_path(message.author), :class => "por_hot_name link-blue", :target => "_blank" %>

    - <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => message.id, :content=> content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
    + <%= link_to title, board_message_path(message.board.id, message.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => title %> +

    <%= time_from_now(message.created_on) %><%= link_to message.author.show_name, user_path(message.author), :class => "por_hot_name link-blue", :target => "_blank" %>

    + <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => message.id, :content=> content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
    <% end %> <% end %> @@ -111,9 +115,11 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{path}", :width => "299", :height => "246"), news_path(news), :target => "_blank" %> <% end %> - <%= link_to news.title, news_path(news), :class => 'por_hot_title_r link-black', :target => "_blank", :title => news.title %> -

    <%= time_from_now(news.created_on) %><%= link_to news.author.show_name, user_path(news.author), :class => "por_hot_name link-blue", :target => "_blank" %>

    - <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => news.id, :content=> news.description, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
    + <%= link_to news.title, news_path(news), :class => 'por_hot_title_r link-black', :target => "_blank", :title => news.title %> +

    <%= time_from_now(news.created_on) %><%= link_to news.author.show_name, user_path(news.author), :class => "por_hot_name link-blue", :target => "_blank" %>

    + <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => news.id, :content=> news.description, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
    <% end %> <% end %> @@ -121,4 +127,8 @@ <%# end %>
    -
    \ No newline at end of file +
    + + \ No newline at end of file diff --git a/app/views/organizations/_org_custom_left3.html.erb b/app/views/organizations/_org_custom_left3.html.erb index fb2b83dd2..ff412d869 100644 --- a/app/views/organizations/_org_custom_left3.html.erb +++ b/app/views/organizations/_org_custom_left3.html.erb @@ -71,7 +71,7 @@ <% end %> <% end %>
    - <% unless acts[1..4].nil? %> + <% unless acts[1..4].blank? %> <% acts[1..4].each do |activity| %> <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' %> <% document = activity.org_act %> @@ -110,10 +110,10 @@ <% end %> <% end %>
    - <% unless acts[5..16].nil? %> + <% unless acts[5..16].blank? %>
    - 分享邀请码 + +

    1.将此页面分享给好友,邀请好友加入班级
    2.通过微信扫一扫加入班级
    3.输入邀请码加入班级
    diff --git a/public/images/code-analysis-icon.png b/public/images/code-analysis-icon.png new file mode 100644 index 000000000..18869da0e Binary files /dev/null and b/public/images/code-analysis-icon.png differ diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 66ead54ba..a04df39ac 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -547,6 +547,7 @@ function observeSearchfield(fieldId, targetId, url) { $.ajax({ url: url, type: 'get', + dataType: 'jsonp', data: {q: $this.val()}, success: function(data){ if(targetId) $('#'+targetId).html(data); }, beforeSend: function(){ $this.addClass('ajax-loading'); }, @@ -1289,7 +1290,24 @@ function clear_data(k,mdu){ } } -function expand_reply(container, btnid, id, type, div_id) { +function expand_reply(container,btnid){ + var target = $(container).children(); + var btn = $(btnid); + if(btn.data('init')=='0'){ + btn.data('init',1); + btn.html('收起回复'); + target.show(); + }else{ + btn.data('init',0); + btn.html('展开更多'); + target.hide(); + target.eq(0).show(); + target.eq(1).show(); + target.eq(2).show(); + } +} + +function expand_all_reply(container, btnid, id, type, div_id) { var target = $(container); var btn = $(btnid); if (btn.data('init') == '0') { diff --git a/public/javascripts/wechat/build/app.min.js b/public/javascripts/wechat/build/app.min.js index 365ed28c0..52dcd34ca 100644 --- a/public/javascripts/wechat/build/app.min.js +++ b/public/javascripts/wechat/build/app.min.js @@ -1,19 +1,20 @@ -var app=angular.module("wechat",["ngRoute"]);app.constant("config",{rootPath:"/assets/wechat/",rootUrl:"/",apiUrl:"/api/v1/"}),app.run(["$rootScope","auth","$location","$routeParams",function(t,a,e,r){g_redirect_path&&g_redirect_path.length>0&&(e.path(g_redirect_path),g_redirect_path=null),t.$on("$routeChangeError",function(t,a,r){a&&a.templateUrl&&(a.templateUrl.endsWith("login.html")||a.templateUrl.endsWith("reg.html")||e.path("/login"))}),t.$on("$routeChangeStart",function(t,a,e){})}]); +var app=angular.module("wechat",["ngRoute"]);app.constant("config",{rootPath:"/assets/wechat/",rootUrl:"/",apiUrl:"/api/v1/"}),app.run(["$rootScope","auth","$location","$routeParams",function(t,a,e,r){g_redirect_path&&g_redirect_path.length>1&&(e.path(g_redirect_path),g_redirect_path=null),t.$on("$routeChangeError",function(t,a,r){a&&a.templateUrl&&(a.templateUrl.endsWith("login.html")||a.templateUrl.endsWith("reg.html")||e.path("/login"))}),t.$on("$routeChangeStart",function(t,a,e){})}]); app.factory("alertService",function(){function t(){this.title=null,this.message=null,this.visible=null,this.cb=null}return t.prototype.showMessage=function(t,e,n){this.message=e,this.title=t,this.visible=!0,this.cb=n},t.prototype.dismiss=function(){this.message=null,this.title=null,this.visible=!1,this.cb&&this.cb()},{create:function(){return new t}}}),app.factory("auth",["$http","$routeParams","$q","session","config",function(t,e,n,o,a){var i=function(){var a=n.defer(),i=c();if(i&&i.length>10)a.resolve(i);else{window.g_code||e.code||o.get("code");t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?a.reject(t.data.message):(o.save("token",t.data.token),a.resolve(t.data.token))})["catch"](function(t){a.reject(t)})}return a.promise},c=function(){return o.get("token")};return{get_bind:i,token:c}}]),app.factory("session",function(){return{save:function(t,e){sessionStorage.setItem(t,e)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},e=function(e,n){t[e]=n},n=function(e){return t[e]};return{save:e,get:n}}),app.factory("common",["$http","auth","$routeParams",function(t,e,n){var o=function(n,o,a,i){if(a.comment&&!(a.comment.length<=0)){var c=a.comment.replace(/\n/g,"
    "),s={type:o,content:c,token:e.token()};a.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+n,data:s}).then(function(t){a.disabled=!1,"function"==typeof i&&i()},function(t){})}},a=function(n,o){return t({method:"GET",url:apiUrl+o+"/"+n+"?token="+e.token()})},i=function(n){n.praise_count+=1,n.has_praise=!0,t({method:"POST",url:apiUrl+"praise/"+n.act_id,data:{token:e.token(),type:n.act_type}}).then(function(t){console.log(t.data)},function(t){})},c=function(n){n.praise_count-=1,n.has_praise=!1,t({method:"POST",url:apiUrl+"praise/"+n.act_id,data:{token:e.token(),type:n.act_type}}).then(function(t){console.log(t.data)},function(t){})},s=function(t){t.scope.formData={comment:""};var e=function(e){a(e,t.type).then(function(e){t.loadCallback(e.data)},function(t){})};e(t.id),t.scope.addReply=function(n){console.log(n.comment),o(t.id,t.replyType,n,function(){t.scope.formData={comment:""},e(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=i,t.scope.decreasePraise=c};return{init:s,addCommonReply:o,loadCommonData:a,addCommonPraise:i,decreaseCommonPraise:c}}]); -app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]); +app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"教辅":""}}); app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,t,e,o,i,c,n,r,s){e.replaceUrl=function(a){return a},e.alertService=s.create(),console.log("ActivityController load"),e.page=n.get("page")||0,e.activities=n.get("activities")||[],e.has_more=n.get("has_more"),e.loadActData=function(a){e.page=a,o({method:"POST",url:apiUrl+"activities",data:{token:c.token(),page:a}}).then(function(a){a.data.page>0?e.activities=e.activities.concat(a.data.data):e.activities=a.data.data,n.save("activities",e.activities),e.has_more=a.data.count+10*a.data.page
    加载中...
    '}}]); -app.config(["$routeProvider","$httpProvider","$locationProvider","config",function(e,o,r,t){var l=t.rootPath,n={delay:["auth",function(e){return e.get_bind()}]},s=function(e,o){return{templateUrl:l+e,controller:o,resolve:n}};e.when("/login",{templateUrl:l+"login.html",controller:"LoginController"}).when("/reg",{templateUrl:l+"reg.html",controller:"RegController"}).when("/activites",s("activities.html","ActivityController")).when("/issues/:id",s("issue_detail.html","IssueController")).when("/project_discussion/:id",s("project_discussion.html","DiscussionController")).when("/homework/:id",s("homework_detail.html","HomeworkController")).when("/course_notice/:id",s("course_notice.html","CourseNoticeController")).when("/course_discussion/:id",s("course_discussion.html","DiscussionController")).when("/journal_for_message/:id",s("jour_message_detail.html","JournalsController")).when("/blog_comment/:id",s("blog_detail.html","BlogController")).when("/add_class",s("add_class.html","AddClassController")).when("/myclass",s("myclass.html","MyClassController")).otherwise({redirectTo:"/activites"}),o.interceptors.push(["$q","$rootScope",function(e,o){return void 0==o.activeCalls&&(o.activeCalls=0),{request:function(e){return o.activeCalls+=1,e},requestError:function(e){return o.activeCalls-=1,e},response:function(e){return o.activeCalls-=1,e},responseError:function(e){return o.activeCalls-=1,e}}}])}]); \ No newline at end of file +app.config(["$routeProvider","$httpProvider","$locationProvider","config",function(e,o,t,r){var l=r.rootPath,n={delay:["auth",function(e){return e.get_bind()}]},i=function(e,o){return{templateUrl:l+e,controller:o,resolve:n}};e.when("/login",{templateUrl:l+"login.html",controller:"LoginController"}).when("/reg",{templateUrl:l+"reg.html",controller:"RegController"}).when("/activites",i("activities.html","ActivityController")).when("/issues/:id",i("issue_detail.html","IssueController")).when("/project_discussion/:id",i("project_discussion.html","DiscussionController")).when("/homework/:id",i("homework_detail.html","HomeworkController")).when("/course_notice/:id",i("course_notice.html","CourseNoticeController")).when("/course_discussion/:id",i("course_discussion.html","DiscussionController")).when("/journal_for_message/:id",i("jour_message_detail.html","JournalsController")).when("/blog_comment/:id",i("blog_detail.html","BlogController")).when("/add_class",i("add_class.html","AddClassController")).when("/myclass",i("myclass.html","MyClassController")).when("/invite_code",i("invite_code.html","InviteCodeController")).otherwise({redirectTo:"/activites"}),o.interceptors.push(["$q","$rootScope",function(e,o){return void 0==o.activeCalls&&(o.activeCalls=0),{request:function(e){return o.activeCalls+=1,e},requestError:function(e){return o.activeCalls-=1,e},response:function(e){return o.activeCalls-=1,e},responseError:function(e){return o.activeCalls-=1,e}}}])}]); \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index c69f3c0cc..d0a5e7ab3 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1372,6 +1372,7 @@ a:hover.comment_ding_link{ color:#269ac9;} .comment_content{ color:#333;} .t_txt{ margin-top:10px;} .orig_reply_box{border-top:1px solid #e3e3e3; width:95%; padding:15px 0px 15px 25px;} +.orig_reply_box2{border-top:1px solid #e3e3e3; width:95%; padding:10px 25px 10px 0;} .orig_textarea{width:90%; margin-bottom:10px;} .orig_sub{ float:right; background-color:#269ac9; color:#fff; height:25px; line-height:25px; text-align:center; width:80px; border:none;} .orig_sub:hover{ background:#297fb8;} @@ -1420,3 +1421,9 @@ a.pages-big{ width:50px;} /*未登录回复提示*/ .visitor-box {width:620px; height:33px; line-height:33px; text-align:center; vertical-align: middle; border:1px solid #ccc; background-color: #fff;} + +/*更新资源文件的描述框*/ +.H60 {height:60px !important;} +.W420 {width:420px;} +.W300 {width:300px !important;} +.W600{ width:600px;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 6812faf34..7fad9854f 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1553,6 +1553,7 @@ a:hover.comment_ding_link{ color:#269ac9;} .comment_content{ color:#333;} .t_txt{ margin-top:10px;} .orig_reply_box{border-top:1px solid #e3e3e3; width:95%; padding:15px 0px 15px 25px;} +.orig_reply_box2{border-top:1px solid #e3e3e3; width:95%; padding:10px 25px 10px 0;} .orig_textarea{width:90%; margin-bottom:10px;} .orig_sub{ float:right; background-color:#269ac9; color:#fff; height:25px; line-height:25px; text-align:center; width:80px; border:none;} .orig_sub:hover{ background:#297fb8;} @@ -1796,3 +1797,9 @@ input.new_loggin_input{ /*未登录回复提示*/ .visitor-box {width:620px; height:33px; line-height:33px; text-align:center; vertical-align: middle; border:1px solid #ccc; background-color: #fff;} + +/*更新资源文件的描述框*/ +.H60 {height:60px !important;} +.W420 {width:420px;} +.W300 {width:300px !important;} +.W600{ width:600px;} diff --git a/public/stylesheets/org_custom.css b/public/stylesheets/org_custom.css index 95df98738..5ff340272 100644 --- a/public/stylesheets/org_custom.css +++ b/public/stylesheets/org_custom.css @@ -25,31 +25,31 @@ a.por_edit_index{ position:absolute; font-size:14px; right:5px; top:15px;} .por_h2_index{ font-size:18px; font-weight:normal; color:#3b94d6; width:100%; border-bottom:1px solid #e8e5e5; height:40px; line-height:40px;} a.por_more_index{ font-size:12px; color:#999; } .por_hotbar_left li{ width:365px; padding:12px 5px 12px 0; border-bottom:1px dashed #e8e5e5;} -a.por_hot_title{ font-size:16px; display:block; font-weight:bold; width:365px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} -.por_hot_txt{ color:#666; line-height:20px;max-height:60px;overflow:hidden;text-overflow:ellipsis;} +a.por_hot_title{ font-size:16px; display:block; width:365px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color: #02253f;} +.por_hot_txt{ color:#637379; line-height:20px;max-height:60px;overflow:hidden;text-overflow:ellipsis;} .por_time{ color:#999;} a.por_hot_name{color:#3b94d6;} .por_hotbar_right{ padding:5px 0 5px 10px; margin-top:15px; width:300px; } .por_hotbar_right img{ width:300px; height:246px;} -.por_hot_title_r{ font-size:16px; display:block; font-weight:bold; width:300px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +.por_hot_title_r{ font-size:16px; display:block; width:300px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color: #02253f;} .por_hot_txt_r{color:#666; line-height:20px;max-height:80px;overflow:hidden;text-overflow:ellipsis;} .por_course{ } .por_course_bar{ width:328px; margin:0 7px; padding:20px 0 0px;} -a.por_course_title{font-size:14px; margin-bottom:10px; display:block; font-weight:bold; width:328px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +a.por_course_title{font-size:16px; margin-bottom:10px; display:block; width:328px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color: #02253f;} .por_course_bar img{ width:140px; height:100px; } -.por_course_txt { width:180px; margin-left:5px;color:#666; line-height:20px;max-height:80px;overflow:hidden;text-overflow:ellipsis;} +.por_course_txt { width:180px; margin-left:5px;color:#637379; line-height:20px;max-height:80px;overflow:hidden;text-overflow:ellipsis;} .por_course_time{color:#3b94d6; margin-left:5px;} .por_post{ padding-bottom:5px;} -.por_post_left{ width:394px; margin-top:15px;} +.por_post_left{ width:385px; margin-top:15px; margin-right: 9px;} .por_post_leftbar img{ width:377px; height:163px;} .por_post_leftbar { border-bottom:1px dashed #e8e5e5; padding-bottom:5px; margin-bottom:10px;} -a.por_post_title{font-size:18px; display:block; width:377px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} -.por_post_txt{color:#666; line-height:20px;max-height:40px;overflow:hidden;text-overflow:ellipsis; } +a.por_post_title{font-size:18px; display:block; width:377px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} +.por_post_txt{color:#637379; line-height:20px;max-height:40px;overflow:hidden;text-overflow:ellipsis; margin-bottom: 5px;} .post_icons_grey{ width:4px; height:4px; margin:10px 5px 0 0; background-color:#b3b3b3; display:block; line-height:20px;} .por_post_list li{ height:35px;} .por_post_list li a{ font-size:14px; } -a.por_hidden_w390{ display:block; width:390px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} -a.por_hidden_w270{ display:block; width:280px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +a.por_hidden_w390{ display:block; width:390px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} +a.por_hidden_w270{ display:block; width:280px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} .por_post_right{ width:280px; border-left:1px solid #e8e5e5; margin-top:15px; padding-left:10px;} .por_news_list li{ padding:15px 0; border-bottom:1px dashed #e8e5e5;} .por_users_img{ width:40px; height:40px; -webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;} @@ -57,11 +57,11 @@ a.por_hidden_w270{ display:block; width:280px; overflow:hidden; white-space: now .por_news_p{ line-height:20px;max-height:40px;min-width:240px;overflow:hidden;text-overflow:ellipsis; } a.por_zan{ background:url(../images/org_custom/icons_por.png) 0 -41px no-repeat; height:15px; width:20px; display:block; padding-left:15px; line-height:20px; color:#999;} a.por_zan:hover{background:url(../images/org_custom/icons_por.png) -34px -42px no-repeat; color:#3b94d6; } -.por_hidden_w205{ font-size:14px; display:block; width:205px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +.por_hidden_w205{ font-size:14px; display:block; width:205px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} .por_projects{ padding-bottom:10px; margin-top:10px;} .por_projects ul li{ padding:5px 0;} .por_projects ul{ margin-top:5px;} -.por_project_p{ line-height:20px;max-height:40px;overflow:hidden;text-overflow:ellipsis; margin-top:5px; margin-left:10px; color:#666; } +.por_project_p{ line-height:20px;max-height:40px;overflow:hidden;text-overflow:ellipsis; margin-top:5px; margin-left:10px; color:#637379; margin-bottom: 5px;} .por_project_li{border-bottom:1px dashed #ccc; padding-bottom:10px; margin-bottom:5px;} .por_time a{ color:#3b94d6;} .por_teachers{ margin-top:20px; } @@ -78,7 +78,7 @@ a.por_more_teacher{ font-size:12px; } .por_teachers_li{ margin-top:10px;} .por_teachers_li li{ padding:10px 0;} .por_teachers_img{ width:60px; height:60px; -webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;} -a.por_teachers_name{ display:block; width:75px; font-size:18px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +a.por_teachers_name{ display:block; width:75px; font-size:18px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} .por_teachers_p{ font-size:14px; color:#999; width:150px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} .por_teachers_span{ color:#999;} .por_teachers_span a{ margin:0 5px; color:#999;} diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index ac65d34c2..bde560613 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -1247,5 +1247,44 @@ a.pages-big{ width:50px;} .red-cir-btn{ background:#e74c3c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;} .green-cir-btn{ background:#28be6c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;} +/*20160622质量分析*/ +.analysis-tag-wrap {width:100%; color:#000; height:20px; line-height:20px; vertical-align:middle;} +.analysis-tag {width:10px; height:20px; background-color:#777;} +.analysis-block {padding:15px; border:1px solid #d9d9d9;} +.flex {display:flex;} +.analysis-genral {flex:1; display:block; text-align:center;} +.analysis-block-icon {background:url(../images/code-analysis-icon.png) -2px -8px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-serious-icon {background:url(../images/code-analysis-icon.png) -2px -34px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-main-icon {background:url(../images/code-analysis-icon.png) -2px -59px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-secondary-icon {background:url(../images/code-analysis-icon.png) -2px -85px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-info-icon {background:url(../images/code-analysis-icon.png) -2px -111px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.quality-percentage {width:320px; height:14px; display:inline-block;} +.quality-percentage-rate {width:50%; height:14px; background-color:#0a6c99; display:inline-block;} +.image-cir {border-radius:50%;} +.analysis-genral-icon {position:absolute; padding:1px 5px; display:inline-block; top:5px;} +.contribute-list-avatar {width:80px; vertical-align:middle; text-align:center;} +.contribute-list-code {width:160px; vertical-align:middle; text-align:center;} +.contribute-list-problem {width:170px; vertical-align:middle; text-align:center;} +.contribute-list-rate {width:228px; vertical-align:middle; text-align:center;} +.contribute-list-height {height:80px;} +.contribute-list-line-height {line-height:80px;} + +/*20160623分析结果*/ +.analysis-result-list {padding:5px;} +.analysis-result-list:nth-of-type(odd){background:#fff;}/*奇数行*/ +.analysis-result-list:nth-of-type(even){background:#f5f5f5;}/*偶数行*/ +.analysis-result-name {width:200px; cursor:pointer;} +.analysis-result-version {width:90px; text-align:right; cursor:pointer;} +.analysis-result-loc {width:60px; text-align:right; cursor:pointer;} +.analysis-result-debt {width:160px; text-align:right; cursor:pointer;} +.analysis-result-time {width:150px; text-align:right; cursor:pointer;} +.analysis-name-icon {background:url(../images/code-analysis-icon.png) -2px -148px no-repeat; width:16px; height:16px; display:inline-block; vertical-align:middle;} + /*未登录回复提示*/ .visitor-box {width:620px; height:33px; line-height:33px; text-align:center; vertical-align: middle; border:1px solid #ccc; background-color: #fff;} + +/*更新资源文件的描述框*/ +.H60 {height:60px !important;} +.W420 {width:420px;} +.W300 {width:300px !important;} +.W600{ width:600px;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 74cbff5dd..500923519 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -27,6 +27,7 @@ a.btn_message_free{ background:#ff5722; display:block; text-align:center; color h2{ font-size:18px; } h3{ font-size:14px; } h4{ font-size:14px; } +.f8 {font-size:8px;} .f12{font-size:12px; font-weight:normal;} .f14{font-size:14px;} .f16{font-size:16px;} @@ -130,6 +131,7 @@ h4{ font-size:14px; } .mt12 { margin-top:12px !important;} .mt15 {margin-top:15px;} .mt19 {margin-top:19px !important;} +.mt35 {margin-top:35px;} .ml70{margin-left: 70px;} .mb0 {margin-bottom: 0px !important;} .mb4{ margin-bottom:4px;} @@ -137,6 +139,8 @@ h4{ font-size:14px; } .mb8 {margin-bottom:8px;} .mb10{ margin-bottom:10px !important;} .mb20{ margin-bottom:20px;} +.mb30 {margin-bottom:30px;} +.mb40 {margin-bottom:40px;} .pl10 {padding-left:10px;} .pl15{ padding-left:15px;} .pl5{ padding-left:5px;} @@ -228,6 +232,7 @@ a.c_green{ color:#28be6c;} .b_grey{ background: #F5F5F5;} .b_dgrey{ background: #CCC;} +.c_white {color:#fff;} .c_orange{color:#e8770d;} .c_dark{ color:#2d2d2d;} .c_lorange{ color:#ff9900;} @@ -239,6 +244,11 @@ a.c_green{ color:#28be6c;} .c_dblue{ color:#09658c;} .b_blue{background:#64bdd9;} .b_green{background:#28be6c;} +.b_slow_yellow{background:#adde18;} +.b_yellow{background:#DDDF0D;} +.b_slow_red{background:#df8538;} +.b_green2 {background:#63c360;} +.b_red {background:#d60308;} .b_w{ background:#fff !important;} /*add by Tim*/ @@ -341,6 +351,8 @@ a:hover.bgreen_n_btn{background:#08a384;} .orange_btn_cir{ background:#e67e22; padding:1px 10px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal; font-size:12px;white-space:nowrap;} .bgreen_btn_cir{ background:#1abc9c; padding:1px 10px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal; font-size:12px;white-space:nowrap;} .grey_border{border:1px solid #dddddd !important;} +.borderRadius {border-radius:5px;} +.tac {text-align:center;} /* commonpic */ .pic_date{ display:block; background:url(../images/new_project/public_icon.png) -31px 0 no-repeat; width:16px; height:15px; float:left;} .pic_add{ display:block; background:url(../images/new_project/public_icon.png) -31px -273px no-repeat; width:16px; height:15px; float:left;} @@ -1167,4 +1179,7 @@ a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; /*未登录回复提示*/ .visitor-box {width:620px; height:33px; line-height:33px; text-align:center; vertical-align: middle; border:1px solid #ccc; background-color: #fff;} -.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;} \ No newline at end of file +.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;} + +/*20160622代码分析弹窗*/ +.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;} \ No newline at end of file diff --git a/spec/controllers/quality_analysis_controller_spec.rb b/spec/controllers/quality_analysis_controller_spec.rb new file mode 100644 index 000000000..d25575a85 --- /dev/null +++ b/spec/controllers/quality_analysis_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe QualityAnalysisController, :type => :controller do + +end diff --git a/spec/factories/quality_analyses.rb b/spec/factories/quality_analyses.rb new file mode 100644 index 000000000..a48e6e33f --- /dev/null +++ b/spec/factories/quality_analyses.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :quality_analyasis, class: 'QualityAnalysis' do + project_id 1 + author_login "MyString" + rep_identifier "MyString" + end +end diff --git a/spec/models/quality_analysis_spec.rb b/spec/models/quality_analysis_spec.rb new file mode 100644 index 000000000..d18ede452 --- /dev/null +++ b/spec/models/quality_analysis_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe QualityAnalysis, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end