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 %> -<%= 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/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 3002cb769..1327f13e9 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -53,7 +53,7 @@ <% end %> -
+
<% if @topics.any? %>
@@ -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/contests/show_contest.html.erb b/app/views/contests/show_contest.html.erb index c379bc668..91279b7bb 100644 --- a/app/views/contests/show_contest.html.erb +++ b/app/views/contests/show_contest.html.erb @@ -6,7 +6,7 @@

<%= l(:label_bids_reward_method) %><%= @contest.budget%>

-
+
<%= @contest.description %> <% unless @course.nil?%>

<%= 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)%>

<% else %>

<%= 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)%>

<% end %> diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index 86b6742d6..c19096f99 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -1,3 +1,11 @@ + <%= labelled_fields_for :issue, @issue do |f| %> <%= call_hook(:view_issues_form_details_top, { :issue => @issue, :form => f }) %> diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 4c2a63844..616e2323d 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -38,7 +38,7 @@ <% end -%>
    -
    +
    <%= textilizable issue, :description %>
    diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 804b52d68..f5018fc94 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -37,26 +37,26 @@ + -->
    <%= link_to_function l(:label_issue_query), 'submit_query_form("query_form")', :class => 'icon icon-checked' %> <%= link_to l(:label_issue_cancel_query), {:set_filter => 1, :project_id => @project}, :class => 'icon icon-reload' %> 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 eea7a0f61..c3ad0fe08 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -50,7 +50,7 @@
  • - +