diff --git a/ReadMe.txt b/ReadMe.txt index b5822682b..7e8af4e21 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -75,3 +75,9 @@ bundle exec rake db:migrate:up version=20140725062302 kw: Mysql2::Error,存储过程,CALL sp_project_status_cursor(); bundle exec rake db:migrate:down version=20130828004955 bundle exec rake db:migrate:up version=20130828004955 + +=================================[2014-08-13]==================================== +kw:配置支持的图片格式 +默认支持如下格式:"bmp,jpeg,jpg,png,gif" +可在configuration.yml中修改,格式:pic_types: "bmp,jpeg,jpg,png,gif"(注意:pic_types若前面有#号需去掉) +配置完成后重启服务 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1e22bba06..ccbff8e50 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -76,6 +76,7 @@ class ProjectsController < ApplicationController # helper :watcherlist helper :words helper :project_score + helper :user_score ### added by william include ActsAsTaggableOn::TagsHelper @@ -111,7 +112,7 @@ class ProjectsController < ApplicationController per_page_option = 10 @projects_all = Project.active.visible. - joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id"). + joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").joins("LEFT JOIN #{ProjectScore.table_name} ON #{Project.table_name}.id = #{ProjectScore.table_name}.project_id"). where("#{Project.table_name}.project_type = ? ", Project::ProjectType_project) @project_count = @projects_all.count @@ -134,7 +135,7 @@ class ProjectsController < ApplicationController @projects = @projects_all.order("created_on desc") @s_type = 0 when '1' - @projects = @projects_all.order("grade desc") + @projects = @projects_all.order("score desc") @s_type = 1 when '2' @projects = @projects_all.order("watchers_count desc") @@ -148,7 +149,7 @@ class ProjectsController < ApplicationController @projects = @projects[@project_pages.offset, @project_pages.per_page] else - @projects = @projects = @projects_all.order("grade desc") + @projects = @projects = @projects_all.order("score desc") @s_type = 1 end @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index ae9336161..26ed51a59 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -5,12 +5,18 @@ class StoresController < ApplicationController layout 'base_stores' def search + begin q = "%#{params[:name].strip}%" (redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank? result = find_public_attache q @searched_attach = paginateHelper result @result_all_count = result.count; + rescue Exception => e + #render 'stores' + redirect_to stores_path + end + end def find_public_attache keywords diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 4a0586c95..80b4e3576 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -27,14 +27,14 @@ class WelcomeController < ApplicationController @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,"grade desc") + @projects = find_miracle_project(10, 3,"score desc") else case @first_page.sort_type when 0 @projects = find_miracle_project(10, 3,"created_on desc") #@projects = @projects_all.order("created_on desc") when 1 - @projects = find_miracle_project(10, 3,"grade desc") + @projects = find_miracle_project(10, 3,"score desc") #@projects = @projects_all.order("grade desc") when 2 @projects = find_miracle_project(10, 3,"watchers_count desc") @@ -48,7 +48,7 @@ class WelcomeController < ApplicationController # @projects = @projects[@project_pages.offset, @project_pages.per_page] else - @projects = @projects_all.order("grade desc") + @projects = @projects_all.order("score desc") end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9f8b8fff5..4d8b53e3c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -32,7 +32,7 @@ module ApplicationHelper extend Forwardable def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter - + #Added by young #Define the course menu's link class # 涓嶆槸鏁扮粍鐨勮浆鍖栨垚鏁扮粍锛岀劧鍚庡垽鏂綋鍓峬enu_item鏄惁鍦ㄧ粰瀹氱殑鍒楄〃 @@ -53,10 +53,10 @@ module ApplicationHelper def authorize_for_course(controller, action) User.current.allowed_to?({:controller => controller, :action => action}, @course) end - + def authorize_for_contest(controller, action) User.current.allowed_to?({:controller => controller, :action => action}, @contest) - end + end # Display a link if user is authorized # @@ -309,7 +309,7 @@ module ApplicationHelper s << h(block_given? ? yield(project) : project.name) else end - + if project.try(:project_type) == Project::ProjectType_project unless User.current.member_of?(@project) s << "" @@ -382,7 +382,7 @@ module ApplicationHelper s << "\n" end end - classes = (ancestors.empty? ? 'root' : 'child') + classes = (ancestors.empty? ? 'root' : 'child') s << h(block_given? ? yield(project) : project.name) ancestors << project end @@ -545,11 +545,11 @@ module ApplicationHelper def authoring(created, author, options={}) l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created)).html_safe end - + def added_time(created) l(:label_added_time, :age => time_tag(created)).html_safe end - + def user_url_and_time(user_name, user_url, created) unless user_name.nil? || user_name == '' l(:label_added_time_by, :author => link_to(user_name, user_url), :age => time_tag(created)).html_safe @@ -679,15 +679,15 @@ module ApplicationHelper def textilizable(*args) options = args.last.is_a?(Hash) ? args.pop : {} case args.size - when 1 - obj = options[:object] - text = args.shift - when 2 - obj = args.shift - attr = args.shift - text = obj.send(attr).to_s - else - raise ArgumentError, 'invalid arguments to textilizable' + when 1 + obj = options[:object] + text = args.shift + when 2 + obj = args.shift + attr = args.shift + text = obj.send(attr).to_s + else + raise ArgumentError, 'invalid arguments to textilizable' end return '' if text.blank? project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil) @@ -716,6 +716,48 @@ module ApplicationHelper text.html_safe end + # + #鏍煎紡鍖栧瓧绗︿覆锛屼笉杞箟html浠g爜 + def textAreailizable(*args) + options = args.last.is_a?(Hash) ? args.pop : {} + case args.size + when 1 + obj = options[:object] + text = args.shift + when 2 + obj = args.shift + attr = args.shift + text = obj.send(attr).to_s + else + raise ArgumentError, 'invalid arguments to textilizable' + end + return '' if text.blank? + project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil) + only_path = options.delete(:only_path) == false ? false : true + + text = text.dup + macros = catch_macros(text) + text = Redmine::WikiFormatting.to_html("CKEditor", text, :object => obj, :attribute => attr) + + @parsed_headings = [] + @heading_anchors = {} + @current_section = 0 if options[:edit_section_links] + + parse_sections(text, project, obj, attr, only_path, options) + text = parse_non_pre_blocks(text, obj, macros) do |text| + [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name| + send method_name, text, project, obj, attr, only_path, options + end + end + parse_headings(text, project, obj, attr, only_path, options) + + if @parsed_headings.any? + replace_toc(text, @parsed_headings) + end + + text.html_safe + end + def parse_non_pre_blocks(text, obj, macros) s = StringScanner.new(text) tags = [] @@ -809,7 +851,7 @@ module ApplicationHelper else wiki_page_id = page.present? ? Wiki.titleize(page) : nil parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil - url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, + url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, :id => wiki_page_id, :version => nil, :anchor => anchor, :parent => parent) end end @@ -823,7 +865,7 @@ module ApplicationHelper end end end - + def select_option_helper option tmp = Hash.new tmp={"" => ""} @@ -1135,7 +1177,7 @@ module ApplicationHelper end def lang_options_for_select(blank=true) - { 'Chinese绠浣撲腑鏂 '=> 'zh', :English => :en} + { 'Chinese绠浣撲腑鏂 '=> 'zh', :English => :en} end def label_tag_for(name, option_tags = nil, options = {}) @@ -1198,7 +1240,7 @@ module ApplicationHelper end end html.html_safe - end + end def delete_link(url, options={}) options = { @@ -1212,8 +1254,8 @@ module ApplicationHelper def preview_link(url, form, target='preview', options={}) content_tag 'a', l(:label_preview), { - :href => "#", - :onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|, + :href => "#", + :onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|, :accesskey => accesskey(:preview) }.merge(options) end @@ -1300,13 +1342,13 @@ module ApplicationHelper start_of_week = start_of_week.to_i % 7 tags = javascript_tag( - "var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " + - "showOn: 'button', buttonImageOnly: true, buttonImage: '" + + "var datepickerOptions={dateFormat: 'yy-mm-dd',minDate: new Date(), firstDay: #{start_of_week}, " + + "showOn: 'button', buttonImageOnly: true, buttonImage: '" + path_to_image('/images/calendar.png') + - "', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};") + "', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true, onClose: function(dateText, inst) {TimeClose(dateText,inst);}, beforeShow : function(input){TimeBeforeShow(input);} };") jquery_locale = l('jquery.locale', :default => current_language.to_s) unless jquery_locale == 'en' - tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js") + tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js") end tags end @@ -1474,14 +1516,14 @@ module ApplicationHelper options end end - + # Add by Tao def url_to_avatar(source) source = nil if source.kind_of?(String) get_avatar(source) end # Endof Tao's code - + def date_format_local(time) date = time.strftime("%Y骞%m鏈%d鏃") end @@ -1497,7 +1539,7 @@ module ApplicationHelper def link_to_content_update(text, url_params = {}, html_options = {}) link_to(text, url_params, html_options) end - + #added by nie # Display watcher picture def show_more_watchers?(obj) @@ -1507,7 +1549,7 @@ module ApplicationHelper return false end end - + def show_watcher_profile(obj) count = 0 html = '' @@ -1532,7 +1574,7 @@ module ApplicationHelper return false end end - + def show_bid_project(bid) html = '' if bid.projects.where('is_public = 1').count == 0 @@ -1544,15 +1586,15 @@ module ApplicationHelper end html.html_safe end - + def show_bid_fans_picture(obj) html = '' if obj.watcher_users.count == 0 html << (content_tag "span", l(:label_project_no_follow)) else - obj.watcher_users.take(12).each do |user| + obj.watcher_users.take(12).each do |user| html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name) - end + end end html.html_safe end @@ -1573,7 +1615,7 @@ module ApplicationHelper return false end end - + def show_contest_project(bid) html = '' if contest.projects.where('is_public = 1').count == 0 @@ -1585,7 +1627,7 @@ module ApplicationHelper end html.html_safe end - + def show_contest_project(contest) html = '' if contest.projects.where('is_public = 1').count == 0 @@ -1597,7 +1639,7 @@ module ApplicationHelper end html.html_safe end - + def show_contest_softapplication(contest) html = '' if contest.softapplications.where('is_public = 1').count == 0 @@ -1609,19 +1651,19 @@ module ApplicationHelper end html.html_safe end - + def show_contest_fans_picture(obj) html = '' if obj.watcher_users.count == 0 html << (content_tag "span", l(:label_project_no_follow)) else - obj.watcher_users.take(12).each do |user| + obj.watcher_users.take(12).each do |user| html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name) - end + end end html.html_safe - end - + end + #display fans picture def show_more_fans?(obj) if obj.watcher_users.count > 12 @@ -1630,20 +1672,20 @@ module ApplicationHelper return false end end - + def show_fans_picture(obj) html = '' if obj.watcher_users.count == 0 html << (content_tag "span", l(:label_no_current_fans)) else - obj.watcher_users.take(12).each do |user| + obj.watcher_users.take(12).each do |user| html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name) - end + end end html.html_safe end - - # added by bai + + # added by bai def show_more_participate?(obj) if obj.join_in_contests.count > 12 return true @@ -1651,7 +1693,7 @@ module ApplicationHelper return false end end - + def show_participate_picture(obj) html = '' count = 0 @@ -1664,10 +1706,10 @@ module ApplicationHelper if count >= 12 break end - end + end html.html_safe - end - + end + #end # add by huang @@ -1682,7 +1724,7 @@ module ApplicationHelper end end html.html_safe - end + end # end #added by william @@ -1691,7 +1733,7 @@ module ApplicationHelper end #end - + def hadcommittedhomework(cur,curb) bid = Bid.find_by_id(curb) return true if bid.nil? @@ -1706,7 +1748,7 @@ module ApplicationHelper else true end - + end def render_dynamic_nav @@ -1717,10 +1759,10 @@ module ApplicationHelper end def bootstrap_render_dynamic_nav - + main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain} main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain} - main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain} + main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain} course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'} course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain} @@ -1732,20 +1774,20 @@ module ApplicationHelper forum_link = link_to l(:label_project_module_forums), {:controller => "forums", :action => "index"} stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'} - + school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'} - - + + #@nav_dispaly_project_label nav_list = Array.new nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1 nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1 nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1 - + nav_list.push(main_project_link) if @nav_dispaly_main_project_label nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1 nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1 - + nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1 nav_list.push(projects_link) if @nav_dispaly_project_label nav_list.push(users_link) if @nav_dispaly_user_label @@ -1755,7 +1797,7 @@ module ApplicationHelper nav_list.push(stores_link) if @nav_dispaly_store_all_label content_li = '' - nav_list.collect do |nav_item| + nav_list.collect do |nav_item| content_li << content_tag(:li, nav_item) end content_li.html_safe @@ -1764,12 +1806,12 @@ module ApplicationHelper def current_user User.current end - + # def hadcommittedforcontest(curu) # message = JournalsForMessage.find_by_sql("select * from journals_for_messages where jour_type = 'Softapplication' ") # message.each do |createmessage| - # if createmessage.user_id == curu - # return true + # if createmessage.user_id == curu + # return true # end # end # end @@ -1782,11 +1824,12 @@ module ApplicationHelper logos.push(link_to image_tag('/images/footer_logo/iscas.png', :alt=>"iscas"), "http://www.iscas.ac.cn" ) logos.push(link_to image_tag('/images/footer_logo/inforbus.png', :alt=>"inforbus"), "http://www.inforbus.com" ) - logos.collect! { |logo| + logos.collect! { |logo| content_tag(:li, logo.html_safe, :class => li_class.to_s) } content_tag(:ul, logos.join("").html_safe, :class => ul_class.to_s).html_safe end - + + end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 5e7f7c18c..315a86340 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -73,7 +73,7 @@ module IssuesHelper ancestors.each do |ancestor| s << '
' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id))) end - s << '
' + s << '
' subject = h(issue.subject) if issue.is_private? subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index 6cf7e7767..07b0ee921 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -65,26 +65,34 @@ module ProjectScoreHelper b_m_num * 2 end - #椤圭洰寰楀垎 + #璁$畻椤圭洰寰楀垎 def project_scores project result = (issue_score project) + (news_score project) + (document_score project) + (changesets_score project) + (board_message_score project) - pss = ProjectStatus.where("project_id = '#{project.id}'") + pss = ProjectScore.where("project_id = '#{project.id}'") if pss.nil? || pss.count == 0 - ps = ProjectStatus.new - ps.grade = result + ps = ProjectScore.new + ps.score = result ps.project = project - ps.watchers_count = project.watcher_users.count - ps.changesets_count = project.changesets.count ps.save else ps = pss.first - ps.grade = result - if ps.changesets_count.nil? || ps.changesets_count == "" - ps.changesets_count = project.changesets.count - end + ps.score = result ps.save end result end + #璇诲彇椤圭洰寰楀垎 + def red_project_scores project + grade = 0 + pss = ProjectScore.where("project_id = '#{project.id}'") + if pss.nil? || pss.count == 0 + grade + else + ps = pss.first + grade = ps.score + grade + end + end + end \ No newline at end of file diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index dc43de32a..38f4f91f0 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -445,7 +445,7 @@ FROM `users` where id = #{user.id}") def messges_for_issue_num(user,project=nil) if project.nil? - Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count + Journal.includes(:user).where("user_id = '#{user.id}' and notes is not null and notes != ''").all.count else Journal.includes(:user).joins(:issue).where("#{Journal.table_name}.user_id = '#{user.id}' and #{Issue.table_name}.project_id = '#{project.id}' and #{Journal.table_name}.notes != '' and #{Journal.table_name}.notes is not null").all.count end @@ -475,6 +475,16 @@ FROM `users` where id = #{user.id}") end + def issues_status_score(user,project=nil) + if project.nil? + #Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count + User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id) AS m_score FROM users WHERE users.id = '#{user.id}'") + else + #Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count + User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id and issues.project_id = '#{project.id}') AS m_score FROM users WHERE users.id = '#{user.id}'") + end + end + #鏇存柊瀵圭暀瑷鐨勫洖澶嶆暟閲 def update_replay_for_message(user,type,project=nil) option_number = get_option_number(user,type) @@ -491,6 +501,14 @@ FROM `users` where id = #{user.id}") end + def replay_for_message_score(user,project=nil) + if project.nil? + User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project') as m_score FROM users WHERE users.id = '#{user.id}'") + else + User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project' and jour_id = '#{project.id}') as m_score FROM users WHERE users.id = '#{user.id}'") + end + end + #鏇存柊瀵瑰笘瀛愮殑鍥炲鏁伴噺 def update_replay_for_memo(user,type,project=nil) option_number = get_option_number(user,type) @@ -506,6 +524,14 @@ FROM `users` where id = #{user.id}") end end + def replay_for_memo_score(user,project=nil) + if project.nil? + User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = users.id AND boards.project_id != -1) FROM users WHERE users.id = #{user.id}") + else + User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = users.id AND boards.project_id = #{project.id}) FROM users WHERE users.id = #{user.id}") + end + end + #鏇存柊琚叧娉ㄧ殑浜烘暟 def update_follow(user,type) option_number = get_option_number(user,type) @@ -517,6 +543,10 @@ FROM `users` where id = #{user.id}") Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count end + def follow_score(user) + User.find_by_sql("SELECT users.id, (SELECT COUNT(*) * 2 FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = '#{user.id}') FROM users WHERE users.id = '#{user.id}'") + end + #鏇存柊甯栧瓙韪╁悇椤规暟閲 def update_tread(user,type,project=nil) option_number = get_option_number(user,type) @@ -542,7 +572,7 @@ FROM `users` where id = #{user.id}") end target_user = obj.author level = UserLevels.get_level(pt.user)#pt.user.get_level - project = pt.project + #project = pt.project if level == 1 && target_user.id == user.id result << pt elsif level == 2 && target_user.id == user.id @@ -560,7 +590,7 @@ FROM `users` where id = #{user.id}") result2 = [] pts.each do |pt| obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) - if obj.nil? + if obj.nil? || (pt.praise_tread_object_type == "Issue" && obj.project.nil?) || (pt.praise_tread_object_type == "Message" && obj.board.nil?) || (pt.praise_tread_object_type == "Message" && obj.board.project.nil?) next end if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id) @@ -568,7 +598,7 @@ FROM `users` where id = #{user.id}") end target_user = obj.author level = UserLevels.get_level(pt.user)#pt.user.get_level - project = pt.project + #project = pt.project if level == 1 && target_user.id == user.id result << pt elsif level == 2 && target_user.id == user.id @@ -600,7 +630,7 @@ FROM `users` where id = #{user.id}") result2 = [] pts.each do |pt| obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) - if obj.nil? + if obj.nil? || (pt.praise_tread_object_type == "Issue" && obj.project.nil?) || (pt.praise_tread_object_type == "Message" && obj.board.nil?) || (pt.praise_tread_object_type == "Message" && obj.board.project.nil?) next end if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id) @@ -608,7 +638,7 @@ FROM `users` where id = #{user.id}") end target_user = obj.author level = UserLevels.get_level(pt.user)#pt.user.get_level - project = pt.project + #project = pt.project if level == 1 && target_user.id == user.id result << pt elsif level == 2 && target_user.id == user.id diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 48d590c4b..4964e6cd2 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -428,13 +428,13 @@ module WelcomeHelper resultSet.take(limit) end - def sort_project_by_hot_rails project_type=0, order_by='grade DESC', limit=15 + def sort_project_by_hot_rails project_type=0, order_by='score DESC', limit=15 # Project.find_by_sql(" # SELECT p.id, p.name, p.description, p.identifier, t.project_id # FROM projects AS p LEFT OUTER JOIN ( # SELECT project_id,grade FROM project_statuses # WHERE project_type = #{project_type} ORDER BY #{order_by} LIMIT #{limit} ) AS t ON p.id = t.project_id ") - Project.visible.joins(:project_status).where("#{Project.table_name}.project_type = ?", project_type).order(order_by).limit(limit).all + Project.visible.joins(:project_status).joins("LEFT JOIN #{ProjectScore.table_name} ON #{Project.table_name}.id = #{ProjectScore.table_name}.project_id").where("#{Project.table_name}.project_type = ?", project_type).order(order_by).limit(limit).all end def sort_bid_by_hot_rails reward_type, limit = 10 diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index c6cb3b39d..8278ce035 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_helper.rb @@ -40,4 +40,14 @@ module WikiHelper link_to(h(parent.pretty_title), {:controller => 'wiki', :action => 'show', :id => parent.title, :project_id => parent.project, :version => nil}) }) end + + def wiki_content_format wiki + text = wiki.text.html_safe + text = parse_non_pre_blocks(text, wiki, text) do |text| + [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name| + send method_name, text, project, wiki, attr, only_path, options + end + end + text + end end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 67e46eb5e..bcd8852f5 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -26,6 +26,8 @@ class Attachment < ActiveRecord::Base belongs_to :author, :class_name => "User", :foreign_key => "author_id" belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" + include UserScoreHelper + validates_presence_of :filename, :author validates_length_of :filename, :maximum => 255 validates_length_of :disk_filename, :maximum => 255 @@ -68,8 +70,9 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location - before_save :be_user_score # user_score - after_destroy :delete_from_disk + after_create :be_user_score # user_score + after_update :be_user_score + after_destroy :delete_from_disk,:down_user_score # add by nwb # 鑾峰彇鎵鏈夊彲鍏紑鐨勮祫婧愭枃浠跺垪琛 @@ -504,9 +507,16 @@ class Attachment < ActiveRecord::Base type = self.container_type types = %w|Document News Version Project Issue Message WikiPage| if types.include?(type) - UserScore.project(:push_file, User.current,self, { attachment_id: self.id }) + #UserScore.project(:push_file, self.author,self, { attachment_id: self.id }) + end end + update_attachment(self.author,1) + end + + #鍒犻櫎闄勪欢鏃堕噸鏂扮粺璁$敤鎴风殑闄勪欢鏁伴噺寰楀垎 + def down_user_score + update_attachment(self.author,1) end end diff --git a/app/models/changeset.rb b/app/models/changeset.rb index a56dee691..38bdd0cc8 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -18,7 +18,7 @@ class Changeset < ActiveRecord::Base belongs_to :repository belongs_to :user - + include UserScoreHelper #after_save :be_user_score # user_score has_many :filechanges, :class_name => 'Change', :dependent => :delete_all @@ -64,6 +64,8 @@ class Changeset < ActiveRecord::Base } after_create :scan_for_issues,:be_user_score # user_score + after_update :be_user_score + after_destroy :down_user_score before_create :before_create_cs # fq @@ -305,6 +307,13 @@ class Changeset < ActiveRecord::Base UserScore.project(:push_code, self.user,self, { changeset_id: self.id }) #鏇存柊鐢ㄦ埛绛夌骇 UserLevels.update_user_level(self.user) + update_changeset(self.user,1) + end + + #绉垎鍒锋柊 + def down_user_score + UserLevels.update_user_level(self.user) + update_changeset(self.user,1) end end diff --git a/app/models/course_attachment.rb b/app/models/course_attachment.rb new file mode 100644 index 000000000..eccaacdb9 --- /dev/null +++ b/app/models/course_attachment.rb @@ -0,0 +1,3 @@ +class CourseAttachment < ActiveRecord::Base + attr_accessible :attachtype, :author_id, :content_type, :description, :digest, :disk_directory, :disk_filename, :downloads, :filename, :filesize, :integer, :is_public +end diff --git a/app/models/document.rb b/app/models/document.rb index 1467903b0..42692bc22 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -20,9 +20,9 @@ class Document < ActiveRecord::Base belongs_to :project belongs_to :user belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id" - - after_create :be_user_score # user_score - + include UserScoreHelper + after_save :be_user_score # user_score + after_destroy :down_user_score acts_as_attachable :delete_permission => :delete_documents @@ -68,5 +68,10 @@ class Document < ActiveRecord::Base # update user score def be_user_score UserScore.project(:push_document, self.user,self,{ document_id: self.id }) + update_document(self.user,1) + end + + def down_user_score + update_document(self.user,1) end end diff --git a/app/models/forum.rb b/app/models/forum.rb index cd9c210dd..24b5b15e0 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -11,7 +11,7 @@ class Forum < ActiveRecord::Base 'creator_id' validates_presence_of :name, :creator_id, :description validates_length_of :name, maximum: 50 - validates_length_of :description, maximum: 255 + #validates_length_of :description, maximum: 255 validates :name, :uniqueness => true acts_as_taggable diff --git a/app/models/issue.rb b/app/models/issue.rb index 1978f5405..68afe21a2 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -79,7 +79,7 @@ class Issue < ActiveRecord::Base # fq after_create :act_as_activity,:be_user_score_new_issue after_update :be_user_score - before_destroy :down_user_score + after_destroy :down_user_score # after_create :be_user_score # end @@ -138,10 +138,10 @@ class Issue < ActiveRecord::Base nil when 'default' user_ids = [user.id] + user.groups.map(&:id) - "(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))" + "(#{table_name}.is_private = #{connection.quoted_false}) OR (#{table_name}.author_id = #{user.id} OR #{table_name}.tracker_id IN (#{user_ids.join(',')}) OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))" when 'own' user_ids = [user.id] + user.groups.map(&:id) - "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))" + "(#{table_name}.author_id = #{user.id} OR #{table_name}.tracker_id IN (#{user_ids.join(',')}) OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))" else '1=0' end @@ -159,9 +159,9 @@ class Issue < ActiveRecord::Base when 'all' true when 'default' - !self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to)) - when 'own' - self.author == user || user.is_or_belongs_to?(assigned_to) + (!self.is_private? ||self.tracker == user) || (self.author == user || user.is_or_belongs_to?(assigned_to)) + when 'own' + self.tracker == user || self.author == user || user.is_or_belongs_to?(assigned_to) else false end @@ -1009,9 +1009,10 @@ class Issue < ActiveRecord::Base s << ' overdue' if overdue? s << ' child' if child? s << ' parent' unless leaf? - s << ' private' if is_private? + #s << ' private' if is_private? s << ' created-by-me' if User.current.logged? && author_id == User.current.id s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id + s << ' tracker-id' if User.current.logged? && tracker_id == User.current.id s end @@ -1508,35 +1509,38 @@ class Issue < ActiveRecord::Base def be_user_score #缂洪櫡瀹屾垚搴︽洿鏂 if self.done_ratio_changed? - UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id }) - #update_issue_done_ratio(User.current,1) + UserScore.project(:update_issue_ratio, self.author,self,{ issue_id: self.id }) + #update_issue_done_ratio(self.author,1) end #缂洪櫡鐘舵佹洿鏀 if self.status_id_changed? - #鍗忓悓寰楀垎 - UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id}) - #update_issues_status(self.author , 1) + #鍗忓悓寰楀垎 + UserScore.joint(:change_issue_status, self.author,nil,self, {issue_id: self.id}) + #update_issues_status(self.author , 1) end end #鍙戝竷缂洪櫡 def be_user_score_new_issue - UserScore.project(:post_issue, User.current,self, { issue_id: self.id }) + UserScore.project(:post_issue, self.author,self, { issue_id: self.id }) update_post_issue(self.author,1) end def down_user_score #缂洪櫡瀹屾垚搴︽洿鏂 - if self.done_ratio_changed? - UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id }) - #update_issue_done_ratio(User.current,1) - end + #if self.done_ratio_changed? + # UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id }) + # update_issue_done_ratio(User.current,1) + #end #缂洪櫡鐘舵佹洿鏀 - if self.status_id_changed? - #鍗忓悓寰楀垎 - UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id}) - #update_issues_status(self.author , 1) - end + #if self.status_id_changed? + # #鍗忓悓寰楀垎 + # UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id}) + # update_issues_status(self.author , 1) + #end + update_post_issue(self.author,1) + update_issue_done_ratio(User.current,1) + update_issues_status(self.author , 1) end diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index f428c5d81..7e70d55c7 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -132,7 +132,7 @@ class IssueQuery < Query :type => :list_optional, :values => group_values ) unless group_values.empty? - role_values = Role.givable.collect {|r| [r.name, r.id.to_s] } + role_values = Role.project_role.collect {|r| [r.name, r.id.to_s] } add_available_filter("assigned_to_role", :type => :list_optional, :values => role_values ) unless role_values.empty? diff --git a/app/models/journal.rb b/app/models/journal.rb index c08d8d630..0fe2b804b 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -46,11 +46,11 @@ class Journal < ActiveRecord::Base before_create :split_private_notes # fq - after_create :act_as_activity,:be_user_score + after_save :act_as_activity,:be_user_score # end #after_destroy :down_user_score #before_save :be_user_score - before_destroy :down_user_score + after_destroy :down_user_score scope :visible, lambda {|*args| user = args.shift || User.current @@ -162,8 +162,9 @@ class Journal < ActiveRecord::Base if !self.notes.nil? && self.notes.gsub(' ','') != '' #鍗忓悓寰楀垎鍔犲垎 UserScore.joint(:post_issue_message, self.user,self.issue.author,self, { message_id: self.id }) + update_messges_for_issue(self.user,1) end - #update_messges_for_issue(User.current,1) + end # 鍑忓皯鐢ㄦ埛鍒嗘暟 -by zjc def down_user_score @@ -171,7 +172,8 @@ class Journal < ActiveRecord::Base if !self.notes.nil? && self.notes.gsub(' ','') != '' #鍗忓悓寰楀垎鍑忓垎 UserScore.joint(:delete_issue_message, self.user,self.issue.author,self, { message_id: self.id }) + update_messges_for_issue(self.user,1) end - #update_messges_for_issue(User.current,1) + end end diff --git a/app/models/journal_detail.rb b/app/models/journal_detail.rb index c2b0aaa2a..82a63b028 100644 --- a/app/models/journal_detail.rb +++ b/app/models/journal_detail.rb @@ -19,9 +19,9 @@ class JournalDetail < ActiveRecord::Base include UserScoreHelper belongs_to :journal before_save :normalize_values - after_create :be_user_score - #after_destroy :down_user_score - before_destroy :down_user_score + after_save :be_user_score + after_destroy :down_user_score + #before_destroy :down_user_score private def normalize_values @@ -45,23 +45,21 @@ class JournalDetail < ActiveRecord::Base def be_user_score #鏇存柊缂洪櫡瀹屾垚搴 if self.prop_key == 'done_ratio' - #update_issue_done_ratio(User.current,1) + update_issue_done_ratio(self.journal.user,1) #鏇存柊缂洪櫡鐘舵 elsif self.prop_key == 'status_id' - #update_issues_status(User.current , 1) + update_issues_status(self.journal.user , 1) end end #鏇存柊鐢ㄦ埛鍒嗘暟 def down_user_score - #update_issue_done_ratio(User.current,1) - #update_issues_status(User.current , 1) if self.prop_key == 'done_ratio' - + update_issue_done_ratio(self.journal.user,1) #鏇存柊缂洪櫡鐘舵 elsif self.prop_key == 'status_id' - UserScore.joint(:delete_issue_status, self.journal.user,nil,self, {issue_id: self.id}) + update_issues_status(self.journal.user, 1) end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index c79004794..dd687f263 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -54,10 +54,10 @@ class JournalsForMessage < ActiveRecord::Base validates :notes, presence: true after_create :act_as_activity #huang - after_create :reset_counters!,:be_user_score + after_create :reset_counters! after_destroy :reset_counters! - #before_save :be_user_score - #before_destroy :down_user_score + after_save :be_user_score + after_destroy :down_user_score # default_scope { where('m_parent_id IS NULL') } @@ -142,8 +142,8 @@ class JournalsForMessage < ActiveRecord::Base #鏂板缓浜嗙暀瑷鍥炲 if self.reply_id != 0 #鍗忓悓寰楀垎鍔犲垎 - UserScore.joint(:reply_message, User.current,User.find(self.reply_id),self, { journals_for_messages_id: self.id }) - update_replay_for_message(User.current,1) + UserScore.joint(:reply_message, self.user,User.find(self.reply_id),self, { journals_for_messages_id: self.id }) + update_replay_for_message(self.user,1) end end # 鏇存柊鐢ㄦ埛鍒嗘暟 -by zjc @@ -151,7 +151,8 @@ class JournalsForMessage < ActiveRecord::Base #鍒犻櫎浜嗙暀瑷鍥炲 if self.reply_id != 0 #鍗忓悓寰楀垎鍑忓垎 - UserScore.joint(:reply_message_delete, User.current,User.find(self.reply_id), { journals_for_messages_id: self.id }) + UserScore.joint(:reply_message_delete, self.user,User.find(self.reply_id), { journals_for_messages_id: self.id }) + update_replay_for_message(self.user,1) end end end diff --git a/app/models/memo.rb b/app/models/memo.rb index 1d191e39d..2c0d3571f 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -8,12 +8,13 @@ class Memo < ActiveRecord::Base # 鑻ユ槸涓婚甯栵紝鍒欏唴瀹瑰彲浠ユ槸绌 #validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? } validates_length_of :subject, maximum: 50 - validates_length_of :content, maximum: 3072 + #validates_length_of :content, maximum: 3072 validate :cannot_reply_to_locked_topic, :on => :create acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC" acts_as_attachable has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id' # acts_as_searchable :column => ['subject', 'content'], # #:include => { :forum => :p} diff --git a/app/models/message.rb b/app/models/message.rb index a57797af1..647a665dc 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -21,6 +21,8 @@ class Message < ActiveRecord::Base belongs_to :board belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC" acts_as_attachable belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id' @@ -59,12 +61,11 @@ class Message < ActiveRecord::Base after_create :add_author_as_watcher, :reset_counters! after_update :update_messages_board - after_destroy :reset_counters!#,:down_user_score + after_destroy :reset_counters!,:down_user_score # fq after_create :act_as_activity,:be_user_score #before_save :be_user_score - before_destroy :down_user_score # end scope :visible, lambda {|*args| @@ -151,11 +152,11 @@ class Message < ActiveRecord::Base #鏂板缓message涓旀棤parent鐨勪负鍙戝笘 if self.parent_id.nil? && !self.board.project.nil? UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id }) - #update_memo_number(User.current,1) + update_memo_number(User.current,1) #鏂板缓message涓旀湁parent鐨勪负鍥炲笘 elsif !self.parent_id.nil? && !self.board.project.nil? UserScore.joint(:reply_posting, self.author,self.parent.author,self, { message_id: self.id }) - #update_replay_for_memo(User.current,1) + update_replay_for_memo(User.current,1) end end @@ -163,10 +164,10 @@ class Message < ActiveRecord::Base def down_user_score if self.parent_id.nil? && !self.board.project.nil? UserScore.joint(:delete_message, self.author,nil,self, { message_id: self.id }) + update_memo_number(User.current,1) elsif !self.parent_id.nil? && !self.board.project.nil? UserScore.joint(:reply_deleting, self.author,self.parent.author,self, { message_id: self.id }) + update_replay_for_memo(User.current,1) end - #update_memo_number(User.current,1) - #update_replay_for_memo(User.current,1) end end diff --git a/app/models/praise_tread.rb b/app/models/praise_tread.rb index 98253d837..0a7282d26 100644 --- a/app/models/praise_tread.rb +++ b/app/models/praise_tread.rb @@ -3,7 +3,8 @@ class PraiseTread < ActiveRecord::Base belongs_to :user belongs_to :praise_tread_object, polymorphic: true after_create :be_user_score - + after_destroy :down_user_score + include UserScoreHelper def self.find_object_by_type_and_id(type,id) @obj = nil case type @@ -28,7 +29,7 @@ class PraiseTread < ActiveRecord::Base # 鑾峰彇瑁佸畾瀵硅薄涓篗essage鏃禡essage鎵灞炵殑椤圭洰鎴栬绋 def project project = nil - if self.praise_tread_object_type == 'Message' + if self.praise_tread_object_type == 'Message' || self.praise_tread_object_type == 'Issues' obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) project = obj.project end @@ -38,15 +39,37 @@ class PraiseTread < ActiveRecord::Base #鏇存柊鐢ㄦ埛鍒嗘暟 - by zjc def be_user_score #韪╄创鍚ф垨璁ㄨ鍖哄笘瀛 - if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message') + if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) target_user = obj.author UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id }) + update_tread(User.current,1) + update_tread(target_user,1) #椤惰创鍚ф垨璁ㄨ鍖哄笘瀛 - elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message') + elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) target_user = obj.author UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id }) + update_praise(target_user,1) + #鏇存柊鐢ㄦ埛绛夌骇 + UserLevels.update_user_level(target_user) + end + end + + def down_user_score + #韪╄创鍚ф垨璁ㄨ鍖哄笘瀛 + if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') + obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) + target_user = obj.author + #UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id }) + update_tread(User.current,1) + update_tread(target_user,1) + #椤惰创鍚ф垨璁ㄨ鍖哄笘瀛 + elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') + obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) + target_user = obj.author + #UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id }) + update_praise(target_user,1) #鏇存柊鐢ㄦ埛绛夌骇 UserLevels.update_user_level(target_user) end diff --git a/app/models/project_score.rb b/app/models/project_score.rb new file mode 100644 index 000000000..a2e229f50 --- /dev/null +++ b/app/models/project_score.rb @@ -0,0 +1,4 @@ +class ProjectScore < ActiveRecord::Base + attr_accessible :project_id, :score + belongs_to :project, foreign_key: :project_id +end diff --git a/app/models/role.rb b/app/models/role.rb index cba219d0d..57fccd53c 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -67,6 +67,16 @@ class Role < ActiveRecord::Base :in => ISSUES_VISIBILITY_OPTIONS.collect(&:first), :if => lambda {|role| role.respond_to?(:issues_visibility)} + #鑾峰彇椤圭洰鐩稿叧瑙掕壊 + def self.project_role + self.givable[0..2] + end + + #鑾峰彇璇剧▼鐩稿叧瑙掕壊 + def self.course_role + self.givable[3..5] + end + # Copies attributes from another role, arg can be an id or a Role def copy_from(arg, options={}) return unless arg.present? diff --git a/app/models/watcher.rb b/app/models/watcher.rb index e2e255a1e..420bd0d84 100644 --- a/app/models/watcher.rb +++ b/app/models/watcher.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Watcher < ActiveRecord::Base + include UserScoreHelper belongs_to :watchable, :polymorphic => true belongs_to :user #Added by nie @@ -23,7 +24,7 @@ class Watcher < ActiveRecord::Base has_one :users_status #end after_create :be_user_score - before_destroy :down_user_score + after_destroy :down_user_score validates_presence_of :user validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id] @@ -79,6 +80,7 @@ class Watcher < ActiveRecord::Base if self.watchable_type == 'Principal' #褰卞搷鍔涘緱鍒 UserScore.influence(:followed_by, self.user,self.watchable,self, { watcher_id: self.id }) + update_follow(self.watchable,1) end end @@ -87,6 +89,7 @@ class Watcher < ActiveRecord::Base #鍙栨秷鍏虫敞 if self.watchable_type == 'Principal' UserScore.influence(:cancel_followed, self.user,self.watchable,self, { watcher_id: self.id }) + update_follow(self.watchable,1) end end diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb index 2f520a236..762ceae9e 100644 --- a/app/views/admin/projects.html.erb +++ b/app/views/admin/projects.html.erb @@ -1,45 +1,45 @@ -
-<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %> -
- -

<%=l(:label_project_plural)%>

- -<%= form_tag({}, :method => :get) do %> -
<%= l(:label_filter_plural) %> - -<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %> - -<%= text_field_tag 'name', params[:name], :size => 30 %> -<%= submit_tag l(:button_apply), :class => "small", :name => nil %> -<%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %> -
-<% end %> -  - -
- - - - - - - - -<% project_tree(@projects) do |project, level| %> - <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>"> - - - - - -<% end %> - -
<%=l(:label_project)%><%=l(:field_is_public)%><%=l(:field_created_on)%>
<%= link_to_project_settings(project, {}, :title => project.short_description) %><%= checked_image project.is_public? %><%= format_date(project.created_on) %> - <%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %> - <%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %> - <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %> - <%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %> -
-
- -<% html_title(l(:label_project_plural)) -%> +
+<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %> +
+ +

<%=l(:label_project_plural)%>

+ +<%= form_tag({}, :method => :get) do %> +
<%= l(:label_filter_plural) %> + +<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %> + +<%= text_field_tag 'name', params[:name], :size => 30 %> +<%= submit_tag l(:button_apply), :class => "small", :name => nil %> +<%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %> +
+<% end %> +  + +
+ + + + + + + + +<% project_tree(@projects) do |project, level| %> + <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>"> + + + + + +<% end %> + +
<%=l(:label_project)%><%=l(:field_is_public)%><%=l(:field_created_on)%>
<%= link_to_project_settings(project, {}) %><%= checked_image project.is_public? %><%= format_date(project.created_on) %> + <%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %> + <%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %> + <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %> + <%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %> +
+
+ +<% html_title(l(:label_project_plural)) -%> diff --git a/app/views/admin/search.html.erb b/app/views/admin/search.html.erb index 67c97366e..5d49d84fa 100644 --- a/app/views/admin/search.html.erb +++ b/app/views/admin/search.html.erb @@ -26,7 +26,7 @@  
- +
<%= sort_header_tag('login', :caption => l(:field_login)) %> @@ -37,20 +37,20 @@ <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %> <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %> <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %> - + <% for user in @users -%> "> - - - - - - - - + + + + + + + <% end -%> diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb index 834c9f6c2..4a76a42ef 100644 --- a/app/views/admin/users.html.erb +++ b/app/views/admin/users.html.erb @@ -37,18 +37,9 @@ <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %> <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %> <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %> - + - - - - - - - - - <% for user in @users -%> "> @@ -59,7 +50,7 @@ - <% end -%> diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb index b0bc22479..0961e3cf8 100644 --- a/app/views/bids/_history.html.erb +++ b/app/views/bids/_history.html.erb @@ -5,7 +5,7 @@
<%= render :partial => 'new', :locals => {:bid => @bid, :sta => @state} %>
-<% label = ''; +<% label = '' case @bid.reward_type when 1 label = l(:label_respond_requirement) diff --git a/app/views/bids/_new.html.erb b/app/views/bids/_new.html.erb index cf9f8df30..7dd7492c0 100644 --- a/app/views/bids/_new.html.erb +++ b/app/views/bids/_new.html.erb @@ -41,7 +41,7 @@
<%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %><%= h(user.firstname) %><%= h(user.lastname) %><%= checked_image user.admin? %><%= format_time(user.created_on) %> <%= change_status_link(user) %> + <%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %><%= h(user.firstname) %><%= h(user.lastname) %><%= checked_image user.admin? %><%= format_time(user.created_on) %> <%= change_status_link(user) %> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %>
<%= checked_image user.admin? %> <%= format_time(user.created_on) %> <%= change_status_link(user) %> + <%= change_status_link(user) %> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %>
+ <%= submit_tag l(:button_clear_meassge), :name => nil, :onclick => "clearMessage('bid_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> - <%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('bid_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
diff --git a/app/views/bids/show.html.erb b/app/views/bids/show.html.erb index 96ed4ea75..3107d8bd6 100644 --- a/app/views/bids/show.html.erb +++ b/app/views/bids/show.html.erb @@ -4,11 +4,11 @@

<%= link_to(@bid.author.lastname+@bid.author.firstname, user_path(@bid.author))%>锛<%= link_to(@bid.name,respond_path(@bid)) %>

<% if @bid.reward_type.nil? or @bid.reward_type == 1%> -

+

<%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %>  <%= l(:label_RMB_sign) %><%= @bid.budget %>

<% elsif @bid.reward_type == 2%> -

+

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

<% else %> diff --git a/app/views/contestnotifications/_form.html.erb b/app/views/contestnotifications/_form.html.erb index 7e7b10a23..afcb60657 100644 --- a/app/views/contestnotifications/_form.html.erb +++ b/app/views/contestnotifications/_form.html.erb @@ -3,7 +3,7 @@ <%= l(:bale_news_notice) %>
-

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

+

<%= f.text_field :title, :required => true, :size => 60,:maxlength => 60, :style => "width:488px;" %>

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

diff --git a/app/views/contests/_new.html.erb b/app/views/contests/_new.html.erb index 804c59429..7ef0e71f1 100644 --- a/app/views/contests/_new.html.erb +++ b/app/views/contests/_new.html.erb @@ -40,7 +40,7 @@ + <%= submit_tag l(:button_clear_meassge), :name => nil, :onclick => "clearMessage('contest_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "contest_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> - <%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('contest_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
diff --git a/app/views/courses/feedback.html.erb b/app/views/courses/feedback.html.erb index 903b0b5fc..a5d7326e0 100644 --- a/app/views/courses/feedback.html.erb +++ b/app/views/courses/feedback.html.erb @@ -79,7 +79,7 @@ function checkMaxLength() { return false;"} %> <% end %> <% if journal.delete_by_user?(User.current) %> - <%= link_to(l(:button_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => journal.user}, :method => :delete,:remote => true)%> + <%= link_to(l(:button_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => journal.user}, :method => :delete,:confirm => l(:text_are_you_sure),:remote => true)%> <% end %> diff --git a/app/views/documents/show.html.erb b/app/views/documents/show.html.erb index 2964a06ba..45f54ad9b 100644 --- a/app/views/documents/show.html.erb +++ b/app/views/documents/show.html.erb @@ -9,7 +9,7 @@ <% end %>
-

<%=h @document.title %>

+

<%=h @document.title %>

<%#=h @document.category.name %>
<%= format_date @document.created_on %>

diff --git a/app/views/forums/_form.html.erb b/app/views/forums/_form.html.erb index f67aa1181..993563954 100644 --- a/app/views/forums/_form.html.erb +++ b/app/views/forums/_form.html.erb @@ -13,16 +13,19 @@
--> <% end %> -
+
<%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share' %>
-
- <%= f.text_area :description, :required => true, :rows => 4, :style => 'width: 100%;resize: none;', :class => 'create-share' %> +
+ + <%= f.text_area :description, :required => true, :id => 'editor01' %> + +

(<%= l(:lable_forums_max_length) %>)

- <%= f.submit :value=>(l :button_submit) ,:class => 'nyan-clean-gray', :style => 'font-size: 14px; padding: 0px 3px' %> - <%= link_to l(:button_back), forums_path,:class => 'nyan-clean-gray',:style => 'font-size: 14px; padding: 0px 3px; color: #000' %> + <%= submit_tag l(:button_submit) %> + <%= link_to l(:button_back), forums_path ,:style => 'font-size: 14px; padding: 0px 3px;' %>
<% end %> diff --git a/app/views/forums/new.html.erb b/app/views/forums/new.html.erb index 19c911c37..2e8924c90 100644 --- a/app/views/forums/new.html.erb +++ b/app/views/forums/new.html.erb @@ -4,7 +4,7 @@ @nav_dispaly_main_contest_label = 1 %> <% @nav_dispaly_forum_label = 1%> -

<%= l :label_forum_new %>

+

<%= l :label_forum_new %>

<%= render 'form' %> diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index d558abe3f..48913a38d 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -18,8 +18,9 @@

<%= f.text_field :subject, :required => true%>

<%= f.text_area :content, :required => true, :id => 'editor02' %>

-
+

(<%= l(:lable_memos_max_length) %>)

+ <%= l(:label_attachment_plural) %>
<%= render :partial => 'attachments/form', :locals => {:container => @memo} %>

diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index fb64a0995..fae799a93 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -78,7 +78,7 @@ :name => nil , :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> - <%= submit_tag l(:button_clear), :name => nil, :class => "enterprise", + <%= submit_tag l(:button_clear_meassge), :name => nil, :class => "enterprise", :onclick => "clearMessage('new_form_user_message');", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %> diff --git a/app/views/homework_attach/_evaluation_add_jour.html.erb b/app/views/homework_attach/_evaluation_add_jour.html.erb index aacbf4c12..5ba198013 100644 --- a/app/views/homework_attach/_evaluation_add_jour.html.erb +++ b/app/views/homework_attach/_evaluation_add_jour.html.erb @@ -78,7 +78,7 @@ :name => nil , :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> - <%= submit_tag l(:button_clear), :name => nil, :class => "enterprise", + <%= submit_tag l(:button_clear_meassge), :name => nil, :class => "enterprise", :onclick => "clearMessage('new_form_user_message');", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %> diff --git a/app/views/issues/_attributes.html.erb b/app/views/issues/_attributes.html.erb index b17283f3b..ebf6dbc91 100644 --- a/app/views/issues/_attributes.html.erb +++ b/app/views/issues/_attributes.html.erb @@ -46,6 +46,43 @@

<%= f.text_field :estimated_hours, :size => 3, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('estimated_hours') %> <%= l(:field_hours) %>

<% end %>
-

+ +

<%= l(:label_attachment_plural) %>
<%= render :partial => 'attachments/form', :locals => {:container => @memo} %>

diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 2c3248d06..75030797b 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -48,7 +48,7 @@
<%= label_tag l(:field_subject) %>: <%=h @memo.subject %>
- <%=h sanitize(@memo.content.html_safe) %> + <%= textAreailizable(@memo,:content) %>

<% if @memo.attachments.any?%> <% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %> diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb index 4456f36e9..0bae1a761 100644 --- a/app/views/messages/_project_show.html.erb +++ b/app/views/messages/_project_show.html.erb @@ -161,7 +161,8 @@

- <%= textilizable message, :content, :attachments => message.attachments %> + <%= textAreailizable message,:content,:attachments => message.attachments %> + <%#= message.content.html_safe %>
<%= link_to_attachments message, :author => false %> diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index 6e5888363..5996852ef 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -1,5 +1,5 @@ -<% if @project %> - <%= render :partial => 'project_show', locals: {project: @project} %> -<% elsif @course %> - <%= render :partial => 'course_show', locals: {course: @course} %> -<% end %> +<% if @project %> + <%= render :partial => 'project_show', locals: {project: @project} %> +<% elsif @course %> + <%= render :partial => 'course_show', locals: {course: @course} %> +<% end %> diff --git a/app/views/projects/_member_list.html.erb b/app/views/projects/_member_list.html.erb index cdf6c459d..89a88e51c 100644 --- a/app/views/projects/_member_list.html.erb +++ b/app/views/projects/_member_list.html.erb @@ -23,8 +23,8 @@ <% else%> <%= content_tag "div", content_tag("p", rolesToLanguage(member.roles.sort.collect(&:to_s)).join(', ')), :class => "clear avatar_name" %>
-

- <%= l(:label_user_for_project_grade) %>: <%= format("%.2f" ,UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade).to_i %> +

+ <%= l(:label_user_for_project_grade) %>: <%= format("%.2f" ,user_scores(member.user,2,@project).total_score).to_i %>

<% end %> diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index e9a733ece..3d7cdfb6c 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -128,7 +128,7 @@ <% if @project.project_type !=1 %> <%= l(:label_project_grade)%>: - <%= link_to(format("%.2f" , project_scores(@project) ).to_i, + <%= link_to(format("%.2f" , red_project_scores(@project) ).to_i, {:controller => 'projects', :action => 'show_projects_score', :remote => true, :id => @project.id}, :style=>"color: #EC6300;") %> diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index e299be182..71bea9cfa 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -1,7 +1,8 @@ <% if @events_by_day.size >0 %>

- <%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %> + <% # 鏆傛椂闅愯棌鏃堕棿鐨勬樉绀%> + <%#= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %>

<% @events_by_day.keys.sort.reverse.each do |day| %> diff --git a/app/views/stores/_search_bar.html.erb b/app/views/stores/_search_bar.html.erb index c91f90e96..884f8b263 100644 --- a/app/views/stores/_search_bar.html.erb +++ b/app/views/stores/_search_bar.html.erb @@ -4,5 +4,5 @@    <%= submit_tag l(:label_search), :class => "enterprise"%> <% end %> -
鍏ㄧ珯鏂囦欢鎼滅储銆備笉浼氭悳绱㈢鏈夐」鐩腑鐨勫唴瀹广佸鐢熷凡缁忔彁浜ょ殑浣滀笟銆
+
鍏ㄧ珯鏂囦欢鎼滅储銆備笉浼氭悳绱㈢鏈夐」鐩腑鐨勫唴瀹广
\ No newline at end of file diff --git a/app/views/stores/index.html.erb b/app/views/stores/index.html.erb index 8ad37f504..6984169d7 100644 --- a/app/views/stores/index.html.erb +++ b/app/views/stores/index.html.erb @@ -21,7 +21,7 @@ <% k.each do |c1|%>
- <%= link_to c1.filename, (attachFromUrl c1), {:title => c1.filename, :target => "_blank"} %> + <%= link_to c1.filename, (attachFromUrl c1), {:title => c1.filename, :target => "_blank"} %>
<%= c1.downloads %> @@ -32,7 +32,7 @@
<% end -%>
- +
<% end; reset_cycle %>
diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb index f5057aba3..531ed6966 100644 --- a/app/views/tags/_tag_name.html.erb +++ b/app/views/tags/_tag_name.html.erb @@ -43,32 +43,32 @@ <% case object_flag %> <% when '1' %> - - <% if User.current.eql?(obj) %> + + <% if User.current.eql?(obj) %> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> - + <% when '2' %> - + <% if (ProjectInfo.find_by_project_id(obj.id)).try(:user_id) == User.current.id %> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> - + <% when '3' %> - + <% if (ProjectInfo.find_by_project_id(obj.project_id)).try(:user_id) == User.current.id %> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> - + <% when '4' %> <% if obj.author_id == User.current.id %> - + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, :taggable_id => obj.id, :taggable_type => object_flag %> - + <% end %> <% when '6' %> @@ -82,10 +82,10 @@ <% end %> <% when '7' %> <% if obj.author_id == User.current.id %> - + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, :taggable_id => obj.id, :taggable_type => object_flag %> - + <% end %> <% when '9' %> @@ -94,6 +94,14 @@ :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> <% end %> + +
diff --git a/app/views/users/_activity_new_score_index.html.erb b/app/views/users/_activity_new_score_index.html.erb index 0ceb8f157..b592b508d 100644 --- a/app/views/users/_activity_new_score_index.html.erb +++ b/app/views/users/_activity_new_score_index.html.erb @@ -1,8 +1,9 @@ -
鎶鏈緱鍒嗭細
-
    韪╁埆浜虹殑甯栧瓙 -2
-
    甯栧瓙琚竴绾т細鍛橀《 +4
-
    甯栧瓙琚簩绾т細鍛橀《 +6
-
    甯栧瓙琚笁绾т細鍛橀《 +8
-
    甯栧瓙琚竴绾т細鍛樿俯 -2
-
    甯栧瓙琚簩绾т細鍛樿俯 -4
-
    甯栧瓙琚笁绾т細鍛樿俯 -6
\ No newline at end of file + +
    韪╁埆浜虹殑甯栧瓙鏁伴噺 * (-2) = <%= option_num.tread %> * (-2) = <%= option_num.tread * (-2) %>
+
    甯栧瓙琚竴绾т細鍛橀《鐨勬鏁 * 4 = <%= option_num.praise_by_one %> * 4 = <%= option_num.praise_by_one * 4 %>
+
    甯栧瓙琚簩绾т細鍛橀《鐨勬鏁 * 6 = <%= option_num.praise_by_two %> * 6 = <%= option_num.praise_by_two * 6 %>
+
    甯栧瓙琚笁绾т細鍛橀《鐨勬鏁 * 8 = <%= option_num.praise_by_three %> * 8 = <%= option_num.praise_by_three * 8 %>
+
    甯栧瓙琚竴绾т細鍛樿俯鐨勬鏁 * (-2) = <%= option_num.tread_by_one %> * (-2) = <%= option_num.tread_by_one * (-2) %>
+
    甯栧瓙琚簩绾т細鍛樿俯鐨勬鏁 * (-4) = <%= option_num.tread_by_two %> * (-4) = <%= option_num.tread_by_two * (-4) %>
+
    甯栧瓙琚笁绾т細鍛樿俯鐨勬鏁 * (-6) = <%= option_num.tread_by_three %> * (-6) = <%= option_num.tread_by_three * (-6) %>
+
    鎶鏈緱鍒 = <%= option_num.tread * (-2) %> + <%= option_num.praise_by_one * 4 %> + <%= option_num.praise_by_two * 6 %> + <%= option_num.praise_by_three * 8 %> + (<%= option_num.tread_by_one * (-2) %>) + ( <%= option_num.tread_by_two * (-4) %>) + (<%= option_num.tread_by_three * (-6) %>) = <%= skill(option_num) %>
\ No newline at end of file diff --git a/app/views/users/_influence_new_score_index.html.erb b/app/views/users/_influence_new_score_index.html.erb index 9985d26cd..9977494b9 100644 --- a/app/views/users/_influence_new_score_index.html.erb +++ b/app/views/users/_influence_new_score_index.html.erb @@ -1,6 +1,7 @@ -
椤圭洰璐$尞寰楀垎锛
-
    鎻愪氦浠g爜 +4
-
    鎻愪氦鏂囨。 +4
-
    鎻愪氦闄勪欢 +4
-
    鏇存柊缂洪櫡瀹屾垚搴 +2
-
    鍙戝竷缂洪櫡 +4
\ No newline at end of file + +
    鎻愪氦浠g爜娆℃暟 * 4 = <%= option_num.changeset %> * 4 = <%= option_num.changeset * 4 %>
+
    鎻愪氦鏂囨。娆℃暟 * 4 = <%= option_num.document %> * 4 = <%= option_num.document * 4 %>
+
    鎻愪氦闄勪欢娆℃暟 * 4 = <%= option_num.attachment %> * 4 = <%= option_num.attachment * 4 %>
+
    鏇存柊缂洪櫡瀹屾垚搴︽鏁 * 2 = <%= option_num.issue_done_ratio %> * 2 = <%= option_num.issue_done_ratio * 2 %>
+
    鍙戝竷缂洪櫡鏁伴噺 * 4 = <%= option_num.post_issue %> * 4 = <%= option_num.post_issue * 4 %>
+
    椤圭洰璐$尞寰楀垎 = <%= option_num.changeset * 4 %> + <%= option_num.document * 4 %> + <%= option_num.attachment * 4 %> + <%= option_num.issue_done_ratio * 2 %> + <%= option_num.post_issue * 4 %> = <%= active(option_num) %>
\ No newline at end of file diff --git a/app/views/users/_memberships.html.erb b/app/views/users/_memberships.html.erb index 5f61d2ce2..2c18ed416 100644 --- a/app/views/users/_memberships.html.erb +++ b/app/views/users/_memberships.html.erb @@ -1,4 +1,4 @@ -<% roles = Role.find_all_givable %> +<% roles = Role.find_all_givable[0..2] %> <% projects = Project.active.all %>
@@ -50,12 +50,19 @@

<%= l(:label_no_data) %>

<% end %>
+
<% if projects.any? %> -
<%=l(:label_project_new)%> +
<%=l(:label_project_new)%> <%= form_for(:membership, :remote => true, :url => user_memberships_path(@user)) do %> -<%= select_tag 'membership[project_id]', options_for_membership_project_select(@user, projects) %> +
<%= select_tag 'membership[project_id]', options_for_membership_project_select(@user, projects)%>

<%= l(:label_role_plural) %>: <% roles.each do |role| %> diff --git a/app/views/users/_project_new_score_index.html.erb b/app/views/users/_project_new_score_index.html.erb index 45e0b0600..d627fba91 100644 --- a/app/views/users/_project_new_score_index.html.erb +++ b/app/views/users/_project_new_score_index.html.erb @@ -1,2 +1,3 @@ -

褰卞搷鍔涘緱鍒嗭細
-
    琚叧娉ㄤ汉鏁 +2/浜
+ +
    琚叧娉ㄤ汉鏁 * 2 = <%= option_num.follow %> * 2 = <%= option_num.follow * 2 %>
+
    褰卞搷鍔涘緱鍒 = <%= option_num.follow * 2 %>
diff --git a/app/views/users/_score_new_index.html.erb b/app/views/users/_score_new_index.html.erb index ff13e5299..539c55f80 100644 --- a/app/views/users/_score_new_index.html.erb +++ b/app/views/users/_score_new_index.html.erb @@ -1,34 +1,10 @@ -<%# messages_count = @user.messages.count %> -<%# messages_score = messages_count * 0.05%> -<%# finall_messages_score = messages_score %> - -<%# journals_count = @user.journals.count %> -<%# journals_score = journals_count * 0.1 %> -<%# user_changesets_count = @user.changesets.count %> -<%# user_changesets_score = user_changesets_count * 0.3 %> -<%# finall_user_project_score = journals_score + user_changesets_score %> - -<%# journals_for_messages_count = @user.journals_messages.count %> -<%# activities_count = @user.activities.count %> -<%# journals_for_messages_score = journals_for_messages_count * 0.05 %> -<%# activities_score = activities_count * 0.2 %> -<%# finall_activity_score = journals_for_messages_score + activities_score %> - -<%# news_count = @user.news.count %> -<%# news_score = news_count * 0.1 %> -<%# wiki_contents_count = @user.wiki_contents.count %> -<%# wiki_contents_score = wiki_contents_count * 0.1 %> -<%# comments_count = @user.comments.count %> -<%# comments_score = comments_count * 0.1 %> -<%# finall_influence_score = news_score + wiki_contents_score + comments_score %> -<%# finall_user_score = finall_messages_score + finall_user_project_score + finall_activity_score + finall_influence_score %>
<%= l(:label_user_score) %>
= <%= l(:label_user_score_of_collaboration) %> + <%= l(:label_user_score_of_influence) %> + <%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %>
-
= <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_i %> - + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
-
= <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_i %>
+
= <%= format("%.2f" ,collaboration(option_num)).to_i %> + <%= format("%.2f" , influence(option_num) ).to_i %> + + <%= "(" if skill(option_num) < 0 %> <%= format("%.2f" , skill(option_num)).to_i %> <%= ")" if skill(option_num) < 0 %> + <%= format("%.2f" , active(option_num)).to_i %>
+
= <%= format("%.2f" ,option_num.total_score).to_i %>
diff --git a/app/views/users/_show_new_score.html.erb b/app/views/users/_show_new_score.html.erb index e9ca499f4..c0e731a65 100644 --- a/app/views/users/_show_new_score.html.erb +++ b/app/views/users/_show_new_score.html.erb @@ -1,28 +1,4 @@ -<%# messages_count = @user.messages.count %> -<%# messages_score = messages_count * 0.05%> -<%# finall_messages_score = messages_score %> - -<%# journals_count = @user.journals.count %> -<%# journals_score = journals_count * 0.1 %> -<%# user_changesets_count = @user.changesets.count %> -<%# user_changesets_score = user_changesets_count * 0.3 %> -<%# finall_user_project_score = journals_score + user_changesets_score %> - -<%# journals_for_messages_count = @user.journals_messages.count %> -<%# activities_count = @user.activities.count %> -<%# journals_for_messages_score = journals_for_messages_count * 0.05 %> -<%# activities_score = activities_count * 0.2 %> -<%# finall_activity_score = journals_for_messages_score + activities_score %> - -<%# news_count = @user.news.count %> -<%# news_score = news_count * 0.1 %> -<%# wiki_contents_count = @user.wiki_contents.count %> -<%# wiki_contents_score = wiki_contents_count * 0.1 %> -<%# comments_count = @user.comments.count %> -<%# comments_score = comments_count * 0.1 %> -<%# finall_influence_score = news_score + wiki_contents_score + comments_score %> -<%# finall_user_score = finall_messages_score + finall_user_project_score + finall_activity_score + finall_influence_score %>

<%= l(:label_user_score) %>

@@ -37,8 +13,9 @@ - - + + <% option_num = get_option_number(@user,1) %> +
<%= l(:label_user_score) %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= l(:label_user_score) %>
<%= format("%.2f" , option_num.total_score).to_i %>
@@ -46,31 +23,57 @@ - - - <%= link_to l(:label_user_score) , {:controller => 'users', :action => 'score_new_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.total_score).to_i %> -
- - <%= link_to l(:label_user_score_of_collaboration), {:controller => 'users',:action => 'topic_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %> -
- - <%= link_to l(:label_user_score_of_influence), {:controller => 'users',:action => 'project_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_i %> -
- - <%= link_to l(:label_user_score_of_skill), {:controller => 'users',:action => 'activity_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %> -
- - <%= link_to l(:label_user_score_of_active), {:controller => 'users',:action => 'influence_new_score_index', :remote => true} %> 锛 - <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %> -
-
+ + +
    +
  • + <%= link_to l(:label_user_score) ,"javascript:void(0)", :onclick => "show_div('score_new_index')" %> : + <%= format("%.2f" , option_num.total_score).to_i %> +
  • +
  • + <%= link_to l(:label_user_score_of_collaboration), "javascript:void(0)", :onclick => "show_div('topic_new_score_index')" %> : + <%= format("%.2f" , collaboration(option_num)).to_i %> +
  • +
  • + <%= link_to l(:label_user_score_of_influence),"javascript:void(0)", :onclick => "show_div('project_new_score_index')" %> : + <%= format("%.2f" , influence(option_num)).to_i %> +
  • +
  • + <%= link_to l(:label_user_score_of_skill),"javascript:void(0)", :onclick => "show_div('activity_new_score_index')" %> : + <%= format("%.2f" , skill(option_num)).to_i %> +
  • +
  • + <%= link_to l(:label_user_score_of_active), "javascript:void(0)", :onclick => "show_div('influence_new_score_index')" %> 锛 + <%= format("%.2f" , active(option_num)).to_i %> +
  • +
- <%= render :partial => 'users/score_new_index', :locals => {:index => 0 } %> + <%= render :partial => 'users/score_new_index', :locals => {:index => 0,:option_num => option_num } %>
diff --git a/app/views/users/_topic_new_score_index.html.erb b/app/views/users/_topic_new_score_index.html.erb index 908932c9e..02bc1de4f 100644 --- a/app/views/users/_topic_new_score_index.html.erb +++ b/app/views/users/_topic_new_score_index.html.erb @@ -1,6 +1,7 @@ -
鍗忓悓寰楀垎锛
-
    鍙戝笘 +2
-
    瀵圭己闄风暀瑷 +1
-
    鏇存敼涓娆$己闄风姸鎬 +1
-
    瀵圭暀瑷鐨勫洖澶 +1
-
    瀵瑰笘瀛愮殑鍥炲 +1
\ No newline at end of file + +
    鍙戝笘鏁伴噺 * 2 = <%= option_num.memo %> * 2 = <%= option_num.memo * 2 %>
+
    瀵圭己闄风暀瑷鏁伴噺 * 1 = <%= option_num.messages_for_issues %> * 1 = <%= option_num.messages_for_issues * 1 %>
+
    鏇存敼缂洪櫡鐘舵佹鏁 * 1 = <%= option_num.issues_status %> * 1= <%= option_num.issues_status * 1 %>
+
    瀵圭暀瑷鐨勫洖澶嶆暟閲 * 1 = <%= option_num.replay_for_message %> * 1 = <%= option_num.replay_for_message * 1 %>
+
    瀵瑰笘瀛愮殑鍥炲鏁伴噺 * 1 = <%= option_num.replay_for_memo %> * 1 = <%= option_num.replay_for_memo * 1 %>
+
    鍗忓悓寰楀垎 = <%= option_num.memo * 2 %> + <%= option_num.messages_for_issues * 1 %> + <%= option_num.issues_status * 1 %> + <%= option_num.replay_for_message * 1 %> + <%= option_num.replay_for_memo * 1 %> = <%= collaboration(option_num) %> 銆
diff --git a/app/views/users/_user_score.html.erb b/app/views/users/_user_score.html.erb index 338d72ada..e9334a047 100644 --- a/app/views/users/_user_score.html.erb +++ b/app/views/users/_user_score.html.erb @@ -1,6 +1,7 @@ <%= l(:label_user_grade)%>: -<%= link_to(format("%.2f" ,user_scores(user,1).total_score ).to_i, {:controller => 'users', + +<%= link_to(format("%.2f" ,get_option_number(user,1).total_score ).to_i, {:controller => 'users', :action => 'show_new_score', :remote => true, :id => user.id diff --git a/app/views/users/show_new_score.html.erb b/app/views/users/show_new_score.html.erb index 0efae940c..be61d3faa 100644 --- a/app/views/users/show_new_score.html.erb +++ b/app/views/users/show_new_score.html.erb @@ -1,28 +1,5 @@ -<% messages_count = @user.messages.count %> -<% messages_score = messages_count * 0.05%> -<% finall_messages_score = messages_score %> -<% journals_count = @user.journals.count %> -<% journals_score = journals_count * 0.1 %> -<% user_changesets_count = @user.changesets.count %> -<% user_changesets_score = user_changesets_count * 0.3 %> -<% finall_user_project_score = journals_score + user_changesets_score %> - -<% journals_for_messages_count = @user.journals_messages.count %> -<% activities_count = @user.activities.count %> -<% journals_for_messages_score = journals_for_messages_count * 0.05 %> -<% activities_score = activities_count * 0.2 %> -<% finall_activity_score = journals_for_messages_score + activities_score %> - -<% news_count = @user.news.count %> -<% news_score = news_count * 0.1 %> -<% wiki_contents_count = @user.wiki_contents.count %> -<% wiki_contents_score = wiki_contents_count * 0.1 %> -<% comments_count = @user.comments.count %> -<% comments_score = comments_count * 0.1 %> -<% finall_influence_score = news_score + wiki_contents_score + comments_score %> -<% finall_user_score = finall_messages_score + finall_user_project_score + finall_activity_score + finall_influence_score %> <%= h html_title %> @@ -52,8 +29,8 @@ - - + +
<%= l(:label_user_score) %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= l(:label_user_score) %>
<%= format("%.2f" , get_option_number(@user,1).total_score).to_i %>
diff --git a/app/views/welcome/_search_bar.html.erb b/app/views/welcome/_search_bar.html.erb index 73a497835..302aa3c26 100644 --- a/app/views/welcome/_search_bar.html.erb +++ b/app/views/welcome/_search_bar.html.erb @@ -4,5 +4,5 @@    <%= submit_tag l(:label_search), :class => "enterprise"%> <% end %> -
鍏ㄧ珯鏂囦欢鎼滅储銆備笉浼氭悳绱㈢鏈夐」鐩腑鐨勫唴瀹瑰拰瀛︾敓宸茬粡鎻愪氦鐨勪綔涓氥
+
鍏ㄧ珯鏂囦欢鎼滅储銆備笉浼氭悳绱㈢鏈夐」鐩腑鐨勫唴瀹广
\ No newline at end of file diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index f2140fd9b..d735e1013 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -14,7 +14,7 @@ $('#' + id).val(''); } } - + $(function(){ $("#main").find("a").attr("target", "_blank"); setCss(); @@ -118,23 +118,23 @@ +
- +
<% if get_avatar?(@contest_page) %> <%= image_tag(url_to_avatar(@contest_page), width:@contest_page.image_width,height: @contest_page.image_height) %> <% else %> <%= image_tag '/images/transparent.png', width:@contest_page.image_width,height: @contest_page.image_height %> <% end %> -
+
<% unless @contest_page.nil? %> <%= @contest_page.title %> , <%= @contest_page.description %> <% end %>
- +
<%= form_tag({controller: :welcome, action: :search }, method: :get) do %> <%= text_field_tag 'name', params[:name], :placeholder => l(:label_search_intimation), name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%> @@ -162,7 +162,7 @@
<%= image_tag('/images/contest1.png')%>
- +
<%= link_to(contest.name, contest_contestnotifications_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> @@ -172,19 +172,19 @@ (<%= link_to("#{contest.contesting_softapplications.count}"+l(:label_work_quantity), show_attendingcontest_contest_path(contest), :target => "_blank") %>) <% end %>
- +
<%=contest.description.truncate(100, omission: '...')%>

- +
- + <%=l(:label_release_time)%>: <%=format_time contest.created_on %>
- + - <% end; reset_cycle %> - + <% end; reset_cycle %> +
@@ -299,31 +299,31 @@ <% if Softapplication.count > 0%>
<% find_all_hot_softapplication.map do |softapplication| break if(softapplication == find_all_hot_softapplication[5]) %> - +
  • <%= image_tag('/images/app1.png')%>
    - +
    <%= link_to(softapplication.name, softapplication_path(softapplication.id), :class => "d-g-blue d-p-project-name", :title => "#{softapplication.name}", :target => "_blank") %>
    - +
    ><%=softapplication.description.to_s.truncate(50, omission: '...')%>

    - +
    <%=l(:label_release_time)%>: <%=format_time softapplication.created_at %>
    - +
  • - <% end; reset_cycle %> - + <% end; reset_cycle %> +
    <% else %>

    <%= l(:label_no_ftapplication) %>

    - + <% end %> diff --git a/app/views/wiki/_content.html.erb b/app/views/wiki/_content.html.erb index 60b6a7452..96d358381 100644 --- a/app/views/wiki/_content.html.erb +++ b/app/views/wiki/_content.html.erb @@ -1,4 +1,5 @@
    - <%= textilizable content, :text, :attachments => content.page.attachments, + <%= textAreailizable content, :text, :attachments => content.page.attachments, :edit_section_links => (@sections_editable && {:controller => 'wiki', :action => 'edit', :project_id => @page.project, :id => @page.title}) %> + <%#= content.text.html_safe %>
    diff --git a/app/views/wiki/edit.html.erb b/app/views/wiki/edit.html.erb index 85b964a9b..3a1abdd83 100644 --- a/app/views/wiki/edit.html.erb +++ b/app/views/wiki/edit.html.erb @@ -1,5 +1,6 @@ <%= wiki_page_breadcrumb(@page) %> +

    <%= h @page.pretty_title %>

    <%= form_for @content, :as => :content, @@ -12,8 +13,15 @@ <% end %> <%= error_messages_for 'content' %> +
    +

    <%=text_area_tag 'content[text]', @text, :required => true, :id => 'editor02', :cols => 100, :rows => 25 %>

    + +
    +
    -<%= text_area_tag 'content[text]', @text, :cols => 100, :rows => 25, +<%#= text_area_tag 'content[text]', @text, :cols => 100, :rows => 25, :class => 'wiki-edit', :accesskey => accesskey(:edit) %> +

    瀵逛笉璧凤紝璇ユ枃浠剁幇鍦ㄤ笉鑳戒笅杞!

    +

    杩斿洖涓婚〉

    -
    -
    -

    Trustie Team.

    +
    +
    +

    Trustie寮鍙戝洟闃.

    +
    +
    - -
    - - + + diff --git a/public/file_not_found.html.erb b/public/file_not_found.html.erb new file mode 100644 index 000000000..b3b45203a --- /dev/null +++ b/public/file_not_found.html.erb @@ -0,0 +1,42 @@ + + + + + File not found + + + +
    + +

    <%= l(:lable_file_not_found) %>

    +

    <%= l(:lable_goto_homepage) %>

    + +
    +
    +

    <%= l(:lable_trustie_team) %>

    +
    +
    + +
    + + diff --git a/test/fixtures/project_scores.yml b/test/fixtures/project_scores.yml new file mode 100644 index 000000000..2c01fdc7c --- /dev/null +++ b/test/fixtures/project_scores.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + project_id: MyString + score: 1 + +two: + project_id: MyString + score: 1 diff --git a/test/unit/project_score_test.rb b/test/unit/project_score_test.rb new file mode 100644 index 000000000..d22e60883 --- /dev/null +++ b/test/unit/project_score_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ProjectScoreTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end