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/application_helper.rb b/app/helpers/application_helper.rb index 4d8b53e3c..7f38d8db9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1442,6 +1442,8 @@ module ApplicationHelper email = $1 end return gravatar(email.to_s.downcase, options) unless email.blank? rescue nil + #options ={"class" => ["avatar2"],"width" =>["80px"],"height" =>["80px"]} + #return image_tag url_to_avatar(user), options else '' end diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb index ecfb097e9..6c11199fb 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -31,6 +31,7 @@ module MembersHelper } s + content_tag('div', content_tag('ul', links), :class => 'pagination_new') + end # add by nwb 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/tags_helper.rb b/app/helpers/tags_helper.rb index 8e9e6bbb9..17b68c3f6 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -12,6 +12,8 @@ module TagsHelper @obj = Issue.find_by_id(obj_id) when '4' @obj = Bid.find_by_id(obj_id) + when '5' + @obj = Forum.find_by_id(obj_id) when '6' @obj = Attachment.find_by_id(obj_id) when '7' @@ -44,6 +46,8 @@ module TagsHelper if user.id == obj_id @result = true end + when '5' + @result = is_forum_manager?(user.id,obj_id) when '7' if user.id == obj_id @result = true @@ -56,6 +60,17 @@ module TagsHelper end +# 鍒ゆ柇鐢ㄦ埛鏄惁鏄创鍚х殑绠$悊鍛 +# add by chenmin +def is_forum_manager?(user_id,forum_id) + @result = false + @user_id = Forum.find(forum_id).creator_id; + if @user_id == user.id + @result = true + end + return @result +end + def tagname_val ("#tag_name_name").value end \ No newline at end of file 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 %>
<% end %> -<%= l(:label_bids_reward_method) %><%= @contest.budget%>
-<%= l(:label_class_period) %> * - <%= text_field_tag :class_period, @course.class_period, :placeholder => "鍦ㄦ杈撳叆璇炬椂" %> <%= l(:label_class_hour)%> + <%= text_field_tag :class_period, @course.class_period, :placeholder => "鍦ㄦ杈撳叆璇炬椂",:maxlength=>5 %> <%= l(:label_class_hour)%> |
<%= l(:label_class_period) %> * - <%= text_field_tag :class_period, nil, :placeholder => "鍦ㄦ杈撳叆璇炬椂" %><%= l(:label_class_hour)%> + <%= text_field_tag :class_period, nil, :placeholder => "鍦ㄦ杈撳叆璇炬椂",:maxlength=>5 %><%= l(:label_class_hour)%> |