diff --git a/ReadMe.txt b/ReadMe.txt index 7e8af4e21..538457d3d 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -81,3 +81,10 @@ kw: 默认支持如下格式:"bmp,jpeg,jpg,png,gif" 可在configuration.yml中修改,格式:pic_types: "bmp,jpeg,jpg,png,gif"(注意:pic_types若前面有#号需去掉) 配置完成后重启服务 + +=================================[2014-08-16]==================================== +kw:数据迁移,project_scores表已存在 +bundle exec rake db:migrate:down VERSION=20140811022947 +bundle exec rake db:migrate:up VERSION=20140811022947 +bundle exec rake db:migrate +bundle exec rake project_score:calculate diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f47ba446e..4f731e580 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -279,7 +279,7 @@ class ApplicationController < ActionController::Base # Find project of id params[:id] def find_project - @project = Project.find(params[:id]) + @project = Project.find_by_id(params[:id]) rescue ActiveRecord::RecordNotFound render_404 end @@ -725,6 +725,12 @@ class ApplicationController < ActionController::Base #鏌ユ壘棣栭〉鐩稿叧淇℃伅 def find_first_page @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.nil? + @first_page = FirstPage.new + @first_page.page_type = 'project' + @first_page.description = "" + @first_page.save() + end @show_course = @first_page.show_course @show_contest = @first_page.show_contest end diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb index 94131a2e0..de686493b 100644 --- a/app/controllers/trackers_controller.rb +++ b/app/controllers/trackers_controller.rb @@ -17,7 +17,7 @@ class TrackersController < ApplicationController layout 'admin' - + helper "project_score" before_filter :require_admin, :except => :index before_filter :require_admin_or_api_request, :only => :index accept_api_auth :index @@ -38,6 +38,7 @@ class TrackersController < ApplicationController @tracker ||= Tracker.new(params[:tracker]) @trackers = Tracker.sorted.all @projects = Project.all + @courses = Course.all end def create diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index eaa96e82a..98b24bc12 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -295,8 +295,8 @@ class UsersController < ApplicationController # 娲昏穬搴︽帓搴, 灏辨槸鎵璋撶殑寰楀垎鎯呭喌 @s_type = 1 @users = scope. - joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). - reorder('user_scores.active DESC') + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') when '2' # 绮変笣鏁版帓搴 @s_type = 2 @@ -308,8 +308,8 @@ class UsersController < ApplicationController # 榛樿娲昏穬搴︽帓搴 @s_type = 1 @users = scope. - joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). - reorder('user_scores.active DESC') + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') end # limit and offset diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 80b4e3576..4e7cf0ce9 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -20,11 +20,12 @@ class WelcomeController < ApplicationController include WelcomeHelper helper :project_score caches_action :robots + before_filter :find_first_page, :only => [:index] # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] def index - @first_page = FirstPage.where("page_type = 'project'").first + #@first_page = FirstPage.where("page_type = 'project'").first #@show_course = @first_page.show_course if @first_page.nil? || @first_page.sort_type.nil? @projects = find_miracle_project(10, 3,"score desc") @@ -76,7 +77,7 @@ class WelcomeController < ApplicationController logo = get_avatar?(@course_page) id = params[:school_id] logo_link = "" - if id.nil? && User.current.user_extensions.school.nil? + if id.nil? && (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) if logo logo_link = url_to_avatar(@course_page) else @@ -148,8 +149,8 @@ class WelcomeController < ApplicationController private # 鍒ゆ柇缃戠珯鐨勫叆鍙o紝鏄绋 course 鍒欒烦杩噄ndex鍘绘覆鏌 course 鏂规硶 def entry_select - @first_page = FirstPage.where("page_type = 'project'").first - url = request.original_url + #@first_page = FirstPage.where("page_type = 'project'").first + url = request.original_url.gsub('/','') if url.include?(Setting.host_course) if @first_page.show_course == 1 course diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index a5506be93..10aa39df2 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -54,7 +54,7 @@ class ZipdownController < ApplicationController end rescue => e - render file: 'public/file_not_found.html' + render file: 'public/file_not_found.html' , :layout => 'course_base' end private diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index 07b0ee921..bdb070cc2 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -16,7 +16,7 @@ module ProjectScoreHelper end #鏂囨。鏁伴噺 - def document_num project + def documents_num project project.documents.count end @@ -48,8 +48,8 @@ module ProjectScoreHelper end #鏂囨。寰楀垎 - def document_score project - d_num = document_num project + def documents_score project + d_num = documents_num(project) d_num * 4 end @@ -67,7 +67,7 @@ module ProjectScoreHelper #璁$畻椤圭洰寰楀垎 def project_scores project - result = (issue_score project) + (news_score project) + (document_score project) + (changesets_score project) + (board_message_score project) + result = (issue_score project) + (news_score project) + (documents_score project) + (changesets_score project) + (board_message_score project) pss = ProjectScore.where("project_id = '#{project.id}'") if pss.nil? || pss.count == 0 ps = ProjectScore.new diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index 38f4f91f0..e981f16a1 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -384,6 +384,9 @@ module UserScoreHelper #鏇存柊鍒嗘暟 def update_score(option_number) option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number) + if option_number.total_score < 0 + option_number.total_score = 0 + end option_number.save option_number.total_score end diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 06bf45012..0677d324b 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -13,16 +13,17 @@ <% end %> -<%= button_tag "娴忚", :type=>"button", :onclick=>"CompatibleSend();" %> +<%#= button_tag "娴忚", :type=>"button", :onclick=>"CompatibleSend();" %> +<%= button_tag "娴忚", :type=>"button", :onclick=>"_file.click()" %> <%= file_field_tag 'attachments[dummy][file]', :id => '_file', :class => 'file_selector', diff --git a/app/views/contests/_new_softapplication.html.erb b/app/views/contests/_new_softapplication.html.erb index c83bdf6e9..92fed47fe 100644 --- a/app/views/contests/_new_softapplication.html.erb +++ b/app/views/contests/_new_softapplication.html.erb @@ -1,12 +1,98 @@ <%#= error_messages_for 'softapplication' %> + + + <%= form_for Softapplication.new, :url => softapplications_path do |f| %>
<%= hidden_field_tag 'contest_id', @contest.id %> <%= l(:label_work_name) %> * : - <%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %> - (<%= l(:label_workname_lengthlimit) %>) + <%= f.text_field :name, :required => true, :size => 60, :style => "width:320px;", :onblur => "regexName();" %> + (<%= l(:label_workname_lengthlimit) %>)

@@ -16,9 +102,9 @@ <%= l(:label_running_platform) %> * : - <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %> + <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:320px;", :onblur=>"regexWorkdescription();"%> - (<%= l(:label_workdescription_lengthlimit) %>) + (<%= l(:label_workdescription_lengthlimit) %>)

@@ -31,12 +117,12 @@ <%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %> - <%= f.select :app_type_name,work_type_opttion, {},{:style => "width:358px;",:onchange => "selectChange(this)"} %> + <%= f.select :app_type_name,work_type_opttion, {},{:style => "width:328px;",:onchange => "selectChange(this)"} %> <%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
@@ -46,7 +132,7 @@ <%= l(:label_work_description) %> * : - <%= f.text_field :description, :required => true, :size => 60, :style => "width:350px;" %> + <%= f.text_field :description, :required => true, :size => 60, :style => "width:320px;" %>
@@ -56,8 +142,8 @@ <%= l(:label_softapplication_developers) %> * : - <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %> - (<%= l(:label_workdescription_lengthlimit) %>) + <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:320px;", :onblur => 'regexDevelopers();' %> + (<%= l(:label_workdescription_lengthlimit) %>)

@@ -65,7 +151,7 @@ <%= l(:label_work_deposit_project) %>锛 - <%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %> + <%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:328px;" %> <%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %>
@@ -90,7 +176,8 @@

- <%= submit_tag l(:button_create) %> + + <%#= submit_tag l(:button_create) %> <%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", :type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -30px'" %> diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 3a7a6a8ee..3116a9a68 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -44,11 +44,11 @@ <% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%> <% hasCourse=true%> -
  • <%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %> +
  • <%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id} %>
      <% User.current.courses.each do |course| %> <% if !course_endTime_timeout?(course) %> -
    • <%= link_to course.name.truncate(10, omission: '...'), {:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %>
    • +
    • <%= link_to course.name.truncate(10, omission: '...'), {:controller => 'courses',:action => 'show',id:course.id} %>
    • <% end %> <% end %>
    diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 9edc803a2..c3ad0fe08 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -66,7 +66,7 @@ <% if @project.project_type == 0 %> <%= l(:label_project_grade)%> : - <%= link_to(format("%.2f" , project_scores(@project) ).to_i, {:controller => 'projects', + <%= link_to(format("%.2f" ,project_scores(@project) ).to_i, {:controller => 'projects', :action => 'show_projects_score', :remote => true, :id => @project.id diff --git a/app/views/projects/_tools_expand.html.erb b/app/views/projects/_tools_expand.html.erb index df6cd481b..7520bd4da 100644 --- a/app/views/projects/_tools_expand.html.erb +++ b/app/views/projects/_tools_expand.html.erb @@ -4,22 +4,22 @@

      椤圭洰浜ゆ祦

      -
    • <%= link_to l(:label_project_tool_response) ,project_feedback_path(@project) %>
    • -
    • <%= link_to l(:project_module_files) ,project_files_path(@project) %>
    • +
    • <%= link_to l(:label_project_tool_response) ,project_feedback_path(@project)%>
    • +
    • <%= link_to l(:project_module_files) ,project_files_path(@project) %>
    • <% if @project.enabled_modules.where("name = 'wiki'").count > 0 %>
    • <%= link_to l(:project_module_wiki), project_wiki_path(@project) %>
    • <% end %>

      杩涘害璺熻釜

      -
    • <%= link_to l(:project_module_calendar),project_calendar_path(@project) %>
    • -
    • <%= link_to l(:label_roadmap) ,project_roadmap_path(@project) %>
    • -
    • <%= link_to l(:project_module_gantt) ,project_gantt_path(@project) %>
    • +
    • <%= link_to l(:project_module_calendar),project_calendar_path(@project) %>
    • +
    • <%= link_to l(:label_roadmap) ,project_roadmap_path(@project) %>
    • +
    • <%= link_to l(:project_module_gantt) ,project_gantt_path(@project) %>

      鍏朵粬宸ュ叿

      <% if @project.enabled_modules.where(" name = 'dts'").count > 0 %>
    • <%= link_to l(:label_module_share) ,share_show_path(@project) %>
    • <% end %> -
    • <%= link_to l(:project_module_documents), project_documents_path(@project) %>
    • +
    • <%= link_to l(:project_module_documents), project_documents_path(@project) %>
    diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 71bea9cfa..3ea5bad92 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -25,13 +25,9 @@ <%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %> -
    -
    -
    - <%#= textilizable e.event_url,:description %> -
    -
    - <%= h(truncate(strip_tags(e.event_description).gsub(/ /, ' '), length: 30, omission: '...')) %> +
    + <%= textAreailizable e,:event_description %> + <%#= h(truncate(strip_tags(e.event_description).gsub(/ /, ' '), length: 30, omission: '...')) %>
    <%= l :label_activity_time %> diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index d735e1013..8df19a280 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -153,7 +153,7 @@

    <%=l(:label_current_hot_contest)%>

    - <%= link_to l(:label_more_information), {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %> + <%= link_to l(:label_more_information), {:controller => 'contests', :action => 'index'}, :target => "_blank" %>
    <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %> @@ -294,7 +294,7 @@

    <%=l(:label_current_attendingcontest_work)%>

    - <%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %> + <%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index'}, :target => "_blank" %>
    <% if Softapplication.count > 0%>
    diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index c979807b9..c46df7777 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -42,7 +42,7 @@
    - <% if @school_id.nil? and User.current.user_extensions.school.nil? %> + <% if @school_id.nil? and (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) %> <% else %> <% if @school_id == "0" %> <% else %> @@ -58,7 +58,7 @@ <% unless @course_page.nil? %> <%= @course_page.title %> - <% if @school_id.nil? and User.current.user_extensions.school.nil? %> + <% if @school_id.nil? and (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) %> , <%= @course_page.description %> <% else %> <% if @school_id == "0" %> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 31fb0432a..997b583c3 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -79,7 +79,7 @@ <%=project.description.truncate(100, omission: '...')%>
    - <%= content_tag "span", l(:label_project_score)+ ":" + project_scores(project).to_s, + <%= content_tag "span", l(:label_project_score)+ ":" + red_project_scores(project).to_i.to_s, :style => "cursor: pointer; display: inline-block; float: right; color: #ec6300;", :title => "椤圭洰寰楀垎锛岀患鍚堣冭檻浜嗛」鐩殑鍚勯」娲诲姩锛屽弽鏄犱簡璇ラ」鐩殑娲昏穬绋嬪害", :class => "tooltip", diff --git a/db/schema.rb b/db/schema.rb index 525cfb745..7d908db6f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -441,10 +441,10 @@ ActiveRecord::Schema.define(:version => 20140814062455) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "sort_type" - t.integer "show_course", :default => 1 - t.integer "show_contest", :default => 1 t.integer "image_width", :default => 107 t.integer "image_height", :default => 63 + t.integer "show_course", :default => 1 + t.integer "show_contest", :default => 1 end create_table "forums", :force => true do |t| diff --git a/lib/redmine.rb b/lib/redmine.rb index 4fa909325..64b39145e 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -408,7 +408,7 @@ Redmine::MenuManager.map :course_menu do |menu| end Redmine::MenuManager.map :user_menu do |menu| menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain } - menu.push :user_course, {:controller => 'users', :action => 'user_courses', :host => Setting.course_domain} + menu.push :user_course, {:controller => 'users', :action => 'user_courses'} #menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain} # menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index 03a2349a2..2467af7a0 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -656,7 +656,7 @@ input[class='nyan-clean-gray']:active, .nyan-clean-gray:active { } .tools li { - background: url("/images/sidebar/tool_tag_alpha.png") 10px 30% no-repeat transparent; + /*background: url("/images/sidebar/tool_tag_alpha.png") 10px 30% no-repeat transparent;*/ color: #3e3e3e; font-weight: 400; line-height: 1.5em;