diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8402c05f0..8a5bfd9fb 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -8,6 +8,7 @@ class CoursesController < ApplicationController menu_item :overview menu_item :feedback, :only => :feedback menu_item :homework, :only => :homework + menu_item :new_homework menu_item l(:label_sort_by_time), :only => :index menu_item l(:label_sort_by_active), :only => :index diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 2fcc2e89b..932ffaa7a 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -44,7 +44,7 @@ class DocumentsController < ApplicationController @grouped = documents.group_by {|d| d.title.first.upcase} when 'author' # @grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author} - @grouped = documents.group_by {|d| d.user.name } + @grouped = documents.group_by(&:user) else @grouped = documents.group_by(&:category) end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index ee524ec55..9171407eb 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -16,7 +16,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class FilesController < ApplicationController - layout 'base_projects'#by young + if @project + layout 'base_projects' #by young + else + layout 'base_courses' + end menu_item :files before_filter :find_project_by_project_id#, :except => [:getattachtype] @@ -122,6 +126,7 @@ class FilesController < ApplicationController end end end + @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] show_attachments @containers @@ -261,20 +266,63 @@ class FilesController < ApplicationController 'filename' => "#{Attachment.table_name}.filename", 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" + sort='' + if params[:sort] + params[:sort].split(",").each do |sort_type| + order_by = sort_type.split(":") + + case order_by[0] + when "filename" + attribute = "filename" + when "size" + attribute = "filesize" + when "attach_type" + attribute = "attachtype" + when "content_type" + attribute = "created_on" + when "field_file_dense" + attribute = "is_public" + when "downloads" + attribute = "downloads" + when "created_on" + attribute = "created_on" + end + + if order_by.count == 1 + sort += "#{Attachment.table_name}.#{attribute} asc " + elsif order_by.count == 2 + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + end + if sort_type != params[:sort].split(",").last + sort += "," + end + end + end if @project + @isproject = true @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] - @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort - elsif @course - @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)] - end - show_attachments @containers + @containers += @project.versions.includes(:attachments).reorder(sort).all + + #render :layout => 'base_projects' + elsif @course + @isproject = false + @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] + # show_attachments @containers + # @attachtype = params[:type].to_i + # @contenttype = params[:contentType].to_s + + end + + show_attachments @containers @attachtype = params[:type].to_i @contenttype = params[:contentType].to_s respond_to do |format| format.js + format.html end + end end diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 69dda5be0..fa2784f22 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -1,282 +1,282 @@ -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -#+ -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -class MyController < ApplicationController - layout "users_base" - before_filter :require_login - - helper :issues - helper :users - helper :custom_fields - - BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues, - 'issuesreportedbyme' => :label_reported_issues, - 'issueswatched' => :label_watched_issues, - 'news' => :label_news_latest, - 'calendar' => :label_calendar, - 'documents' => :label_document_plural, - 'timelog' => :label_spent_time - }.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze - - DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'], - 'right' => ['issuesreportedbyme'] - }.freeze - - def index - - page - render :action => 'page' - end - - # Show user's page - def page - @user = User.current - @Issues= Issue.visible.open. - where(:assigned_to_id => ([User.current.id] + User.current.group_ids)) - @limit = 10 - @feedback_count = @Issues.count - @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] - @offset ||= @feedback_pages.offset - @curse_attachments = @Issues[@offset, @limit] - - @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT - end - - def page2 - @limit = 10 - @user = User.current - @Issues= Issue.visible.open. - where(:assigned_to_id => ([User.current.id] + User.current.group_ids)) - @feedback_count = @Issues.count - @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] - @offset ||= @feedback_pages.offset - @curse_attachments = @Issues[@offset, @limit] - @state = false - @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT - respond_to do |format| - format.js - end - end - - # Edit user's account - def account - @user = User.current - lg=@user.login - @pref = @user.pref - diskfile = disk_filename('User', @user.id) - diskfile1 = diskfile + 'temp' - if request.post? - @user.safe_attributes = params[:user] - @user.pref.attributes = params[:pref] - @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') - @user.login = params[:login] - unless @user.user_extensions.nil? - if @user.user_extensions.identity == 2 - @user.firstname = params[:enterprise_name] - end - end - - @se = @user.extensions - @se.school_id = params[:occupation] if params[:occupation] - @se.gender = params[:gender] - @se.location = params[:province] if params[:province] - @se.location_city = params[:city] if params[:city] - @se.identity = params[:identity].to_i if params[:identity] - @se.technical_title = params[:technical_title] if params[:technical_title] - @se.student_id = params[:no] if params[:no] - - if @user.save && @se.save - # 头像保存 - if File.exist?(diskfile1) - if File.exist?(diskfile) - File.delete(diskfile) - end - File.open(diskfile1, "rb") do |f| - buffer = f.read(10) - if buffer != "DELETE" - File.open(diskfile1, "rb") do |f1| - File.open(diskfile, "wb") do |f| - buffer = "" - while (buffer = f1.read(8192)) - f.write(buffer) - end - end - end - - # File.rename(diskfile + 'temp',diskfile); - end - end - end - - # 确保文件被删除 - if File.exist?(diskfile1) - File.delete(diskfile1) - end - - @user.pref.save - @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) - set_language_if_valid @user.language - flash[:notice] = l(:notice_account_updated) - redirect_to user_url(@user) - return - else - # 确保文件被删除 - if File.exist?(diskfile1) - File.delete(diskfile1) - end - @user.login = lg - end - else - # 确保文件被删除 - if File.exist?(diskfile1) - File.delete(diskfile1) - end - end - end - - # Destroys user's account - def destroy - @user = User.current - unless @user.own_account_deletable? - redirect_to my_account_url - return - end - - if request.post? && params[:confirm] - @user.destroy - if @user.destroyed? - logout_user - flash.now[:notice] = l(:notice_account_deleted) - end - redirect_to home_url - end - end - - # Manage user's password - def password - @user = User.current - unless @user.change_password_allowed? - flash.now[:error] = l(:notice_can_t_change_password) - redirect_to my_account_url - return - end - if request.post? - if @user.check_password?(params[:password]) - @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] - - if @user.save - flash.now[:notice] = l(:notice_account_password_updated) - redirect_to my_account_url - end - else - flash.now[:error] = l(:notice_account_wrong_password) - end - end - end - - # Create a new feeds key - def reset_rss_key - if request.post? - if User.current.rss_token - User.current.rss_token.destroy - User.current.reload - end - User.current.rss_key - flash[:notice] = l(:notice_feeds_access_key_reseted) - end - redirect_to my_account_url - end - - # Create a new API key - def reset_api_key - if request.post? - if User.current.api_token - User.current.api_token.destroy - User.current.reload - end - User.current.api_key - flash[:notice] = l(:notice_api_access_key_reseted) - end - redirect_to my_account_url - end - - # User's page layout configuration - def page_layout - @user = User.current - @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup - @block_options = [] - BLOCKS.each do |k, v| - unless %w(top left right).detect {|f| (@blocks[f] ||= []).include?(k)} - @block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize] - end - end - end - - # Add a block to user's page - # The block is added on top of the page - # params[:block] : id of the block to add - def add_block - block = params[:block].to_s.underscore - if block.present? && BLOCKS.key?(block) - @user = User.current - layout = @user.pref[:my_page_layout] || {} - # remove if already present in a group - %w(top left right).each {|f| (layout[f] ||= []).delete block } - # add it on top - layout['top'].unshift block - @user.pref[:my_page_layout] = layout - @user.pref.save - end - redirect_to my_page_layout_url - end - - # Remove a block to user's page - # params[:block] : id of the block to remove - def remove_block - block = params[:block].to_s.underscore - @user = User.current - # remove block in all groups - layout = @user.pref[:my_page_layout] || {} - %w(top left right).each {|f| (layout[f] ||= []).delete block } - @user.pref[:my_page_layout] = layout - @user.pref.save - redirect_to my_page_layout_url - end - - # Change blocks order on user's page - # params[:group] : group to order (top, left or right) - # params[:list-(top|left|right)] : array of block ids of the group - def order_blocks - group = params[:group] - @user = User.current - if group.is_a?(String) - group_items = (params["blocks"] || []).collect(&:underscore) - group_items.each {|s| s.sub!(/^block_/, '')} - if group_items and group_items.is_a? Array - layout = @user.pref[:my_page_layout] || {} - # remove group blocks if they are presents in other groups - %w(top left right).each {|f| - layout[f] = (layout[f] || []) - group_items - } - layout[group] = group_items - @user.pref[:my_page_layout] = layout - @user.pref.save - end - end - render :nothing => true - end -end +# Redmine - project management software +# Copyright (C) 2006-2013 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +#+ +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class MyController < ApplicationController + layout "users_base" + before_filter :require_login + + helper :issues + helper :users + helper :custom_fields + + BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues, + 'issuesreportedbyme' => :label_reported_issues, + 'issueswatched' => :label_watched_issues, + 'news' => :label_news_latest, + 'calendar' => :label_calendar, + 'documents' => :label_document_plural, + 'timelog' => :label_spent_time + }.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze + + DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'], + 'right' => ['issuesreportedbyme'] + }.freeze + + def index + + page + render :action => 'page' + end + + # Show user's page + def page + @user = User.current + @Issues= Issue.visible.open. + where(:assigned_to_id => ([User.current.id] + User.current.group_ids)) + @limit = 10 + @feedback_count = @Issues.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @curse_attachments = @Issues[@offset, @limit] + + @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT + end + + def page2 + @limit = 10 + @user = User.current + @Issues= Issue.visible.open. + where(:assigned_to_id => ([User.current.id] + User.current.group_ids)) + @feedback_count = @Issues.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @curse_attachments = @Issues[@offset, @limit] + @state = false + @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT + respond_to do |format| + format.js + end + end + + # Edit user's account + def account + @user = User.current + lg=@user.login + @pref = @user.pref + diskfile = disk_filename('User', @user.id) + diskfile1 = diskfile + 'temp' + if request.post? + @user.safe_attributes = params[:user] + @user.pref.attributes = params[:pref] + @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') + @user.login = params[:login] + unless @user.user_extensions.nil? + if @user.user_extensions.identity == 2 + @user.firstname = params[:enterprise_name] + end + end + + @se = @user.extensions + @se.school_id = params[:occupation] if params[:occupation] + @se.gender = params[:gender] + @se.location = params[:province] if params[:province] + @se.location_city = params[:city] if params[:city] + @se.identity = params[:identity].to_i if params[:identity] + @se.technical_title = params[:technical_title] if params[:technical_title] + @se.student_id = params[:no] if params[:no] + + if @user.save && @se.save + # 头像保存 + if File.exist?(diskfile1) + if File.exist?(diskfile) + File.delete(diskfile) + end + File.open(diskfile1, "rb") do |f| + buffer = f.read(10) + if buffer != "DELETE" + File.open(diskfile1, "rb") do |f1| + File.open(diskfile, "wb") do |f| + buffer = "" + while (buffer = f1.read(8192)) + f.write(buffer) + end + end + end + + # File.rename(diskfile + 'temp',diskfile); + end + end + end + + # 确保文件被删除 + if File.exist?(diskfile1) + File.delete(diskfile1) + end + + @user.pref.save + @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) + set_language_if_valid @user.language + flash[:notice] = l(:notice_account_updated) + redirect_to user_url(@user) + return + else + # 确保文件被删除 + if File.exist?(diskfile1) + File.delete(diskfile1) + end + @user.login = lg + end + else + # 确保文件被删除 + if File.exist?(diskfile1) + File.delete(diskfile1) + end + end + end + + # Destroys user's account + def destroy + @user = User.current + unless @user.own_account_deletable? + redirect_to my_account_url + return + end + + if request.post? && params[:confirm] + @user.destroy + if @user.destroyed? + logout_user + flash.now[:notice] = l(:notice_account_deleted) + end + redirect_to home_url + end + end + + # Manage user's password + def password + @user = User.current + unless @user.change_password_allowed? + flash.now[:error] = l(:notice_can_t_change_password) + redirect_to my_account_url + return + end + if request.post? + if @user.check_password?(params[:password]) + @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] + + if @user.save + flash.now[:notice] = l(:notice_account_password_updated) + redirect_to my_account_url + end + else + flash.now[:error] = l(:notice_account_wrong_password) + end + end + end + + # Create a new feeds key + def reset_rss_key + if request.post? + if User.current.rss_token + User.current.rss_token.destroy + User.current.reload + end + User.current.rss_key + flash[:notice] = l(:notice_feeds_access_key_reseted) + end + redirect_to my_account_url + end + + # Create a new API key + def reset_api_key + if request.post? + if User.current.api_token + User.current.api_token.destroy + User.current.reload + end + User.current.api_key + flash[:notice] = l(:notice_api_access_key_reseted) + end + redirect_to my_account_url + end + + # User's page layout configuration + def page_layout + @user = User.current + @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup + @block_options = [] + BLOCKS.each do |k, v| + unless %w(top left right).detect {|f| (@blocks[f] ||= []).include?(k)} + @block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize] + end + end + end + + # Add a block to user's page + # The block is added on top of the page + # params[:block] : id of the block to add + def add_block + block = params[:block].to_s.underscore + if block.present? && BLOCKS.key?(block) + @user = User.current + layout = @user.pref[:my_page_layout] || {} + # remove if already present in a group + %w(top left right).each {|f| (layout[f] ||= []).delete block } + # add it on top + layout['top'].unshift block + @user.pref[:my_page_layout] = layout + @user.pref.save + end + redirect_to my_page_layout_url + end + + # Remove a block to user's page + # params[:block] : id of the block to remove + def remove_block + block = params[:block].to_s.underscore + @user = User.current + # remove block in all groups + layout = @user.pref[:my_page_layout] || {} + %w(top left right).each {|f| (layout[f] ||= []).delete block } + @user.pref[:my_page_layout] = layout + @user.pref.save + redirect_to my_page_layout_url + end + + # Change blocks order on user's page + # params[:group] : group to order (top, left or right) + # params[:list-(top|left|right)] : array of block ids of the group + def order_blocks + group = params[:group] + @user = User.current + if group.is_a?(String) + group_items = (params["blocks"] || []).collect(&:underscore) + group_items.each {|s| s.sub!(/^block_/, '')} + if group_items and group_items.is_a? Array + layout = @user.pref[:my_page_layout] || {} + # remove group blocks if they are presents in other groups + %w(top left right).each {|f| + layout[f] = (layout[f] || []) - group_items + } + layout[group] = group_items + @user.pref[:my_page_layout] = layout + @user.pref.save + end + end + render :nothing => true + end +end diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 0c7e2ade1..5b6111187 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -56,12 +56,12 @@ class SoftapplicationsController < ApplicationController stars_status = stars_reates.select("stars, count(*) as scount"). group("stars") - @stars_status_map = Hash.new(0.0) + @stars_status_map = Hash.new(0) stars_status.each do |star_status| percent = percent_of(star_status.scount, stars_reates_count).to_f - percent_m = format("%.2f", percent) + people = star_status.scount.to_i @stars_status_map["star#{star_status.stars.to_i}".to_sym] = - percent_m.to_s + "%" + people.to_s end @jours = @softapplication.journals_for_messages.order('created_on DESC') @image_results = [] diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 1318e40a5..0a6f15020 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -38,24 +38,41 @@ class TagsController < ApplicationController @obj_id = params[:obj_id] @obj_flag = params[:object_flag] - @selected_tags = Array.new + @selected_tags = Array.new + @selected_tag_ids = Array.new + @selected_tag_objs = Array.new @related_tags = nil - - if params[:q] - @selected_tags << params[:q] + @related_tag_ids = Array.new + @related_tag_objs = Array.new + if params[:q] + @tag = ActsAsTaggableOn::Tag.find(params[:q]) + @selected_tags << @tag.name + @selected_tag_ids << @tag.id.to_s + @selected_tag_objs << @tag else @do_what = params[:do_what] - @tag = params[:tag] - @selected_tags = params[:current_selected_tags] - @selected_tags = @selected_tags.nil? ? Array.new : @selected_tags + @tag = ActsAsTaggableOn::Tag.find(params[:tag]) + #@selected_tags = params[:current_selected_tags] + @selected_tag_ids = params[:current_selected_tags] + @selected_tag_ids = @selected_tag_ids.nil? ? Array.new : @selected_tag_ids + @selected_tag_ids.each do |t| + ta = ActsAsTaggableOn::Tag.find(t) + @selected_tags << ta.name + @selected_tag_objs << ta + end + #@selected_tags = @selected_tags.nil? ? Array.new : @selected_tags case @do_what when '0' then - @selected_tags.delete @tag #数组中删除有多方式 可以改用shift,pop + @selected_tags.delete @tag.name #数组中删除有多方式 可以改用shift,pop + @selected_tag_ids.delete @tag.id.to_s + @selected_tag_objs.delete @tag when '1' then # 判断是否已存在该tag 主要用来处理分页的情况 - unless @selected_tags.include? @tag - @selected_tags << @tag + unless @selected_tags.include? @tag.name + @selected_tags << @tag.name + @selected_tag_ids << @tag.id.to_s + @selected_tag_objs << @tag end end end @@ -75,7 +92,7 @@ class TagsController < ApplicationController @attachments_results, @contests_results, @courses_results, - @open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags) + @open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags,@selected_tag_ids) # 这里是做tag推荐用的, 用来生产推荐的tags unless @obj.nil? @@ -85,6 +102,13 @@ class TagsController < ApplicationController # @tags.delete(i) # end @related_tags = @tags + @tag_objs = @obj.tags + @tag_objs.each do |t| + unless @selected_tags.include?(t.name) + @related_tag_ids << t.id.to_s + @related_tag_objs << t + end + end else return end @@ -162,8 +186,8 @@ class TagsController < ApplicationController if request.get? # 获取传过来的tag_id taggable_id 和 taggable_type,通过2者确定要删除tag的对象 - @tag_name = params[:tag_name] - @tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id + @tag_id = params[:tag_name] + @tag_name = (ActsAsTaggableOn::Tag.find(@tag_id)).name @taggable_id = params[:taggable_id] # 当做参数传时对象会变成字符串 @taggable_type = numbers_to_object_type(params[:taggable_type]) @@ -192,7 +216,7 @@ class TagsController < ApplicationController private # 这里用来刷新搜索结果的区域 # 函数的返回值 前2字段用来处理获取其他tag和分页 ,另外4个返回值为过滤结果 - def refresh_results(obj_id,obj_flag,selected_tags) + def refresh_results(obj_id,obj_flag,selected_tags,selected_tag_ids = nil) @users_results = nil @projects_results = nil @issues_results = nil @@ -210,36 +234,36 @@ class TagsController < ApplicationController case obj_flag when '1' then @obj = User.find_by_id(obj_id) - @obj_pages,@users_results,@results_count = for_pagination(get_users_by_tag(selected_tags)) + @obj_pages,@users_results,@results_count = for_pagination(get_users_by_tag(selected_tags,selected_tag_ids)) when '2' then @obj = Project.find_by_id(obj_id) - @obj_pages,@projects_results,@results_count = for_pagination(get_projects_by_tag(selected_tags)) + @obj_pages,@projects_results,@results_count = for_pagination(get_projects_by_tag(selected_tags,selected_tag_ids)) when '3' then @obj = Issue.find_by_id(obj_id) - @obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags)) + @obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags,selected_tag_ids)) when '4' then - @obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags)) + @obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags,selected_tag_ids)) @obj = Bid.find_by_id(obj_id) when '5' @obj = Forum.find_by_id(obj_id) - @obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags)) + @obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags,selected_tag_ids)) when '6' @obj = Attachment.find_by_id(obj_id) # modifed by Long Jun # this is used to find the attachments that came from the same project and tagged with the same tag. #@result = get_attachments_by_project_tag(selected_tags, @obj) - @result = get_attachments_by_tag(selected_tags) + @result = get_attachments_by_tag(selected_tags,selected_tag_ids) @obj_pages, @attachments_results, @results_count = for_pagination(@result) when '7' @obj = Contest.find_by_id(obj_id) - @obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags)) + @obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags,selected_tag_ids)) when '8' @obj = OpenSourceProject.find_by_id(obj_id) - @obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags)) + @obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags,selected_tag_ids)) when '9' then @obj = Course.find_by_id(obj_id) - @obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags)) + @obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags,selected_tag_ids)) else @obj = nil end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index e6ba74874..c6a5d2819 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -236,11 +236,10 @@ class WordsController < ApplicationController #modify by nwb #添加对课程留言的支持 referer = request.headers["Referer"] + #referer = "http://forge.trustie.net/words/create_reply" obj_id = referer.match(%r(/([0-9]{1,})(/|\?|$)))[1] if referer.match(/project/) obj = Project.find_by_id(obj_id) - elsif referer.match(/course/) - obj = Course.find_by_id(obj_id) elsif referer.match(/user/) obj = User.find_by_id(obj_id) elsif ( referer.match(/bids/) || referer.match(/calls/) ) @@ -251,6 +250,8 @@ class WordsController < ApplicationController obj = Softapplication.find_by_id(obj_id) elsif ( referer.match(/homework_attach/) || referer.match(/homework_attach/) ) #new added obj = HomeworkAttach.find_by_id(obj_id) + elsif referer.match(/course/) + obj = Course.find_by_id(obj_id) else raise "create reply obj unknow type.#{referer}" end diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index df834f13c..f8bf0d736 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -110,7 +110,7 @@ class ZipdownController < ApplicationController #length = attach.storage_path.length homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end - zipping("#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) + zipping("#{user.user_extensions.student_id}_#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) #user_attaches_paths #end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a577529cb..799316c47 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -460,6 +460,7 @@ module ApplicationHelper project_tree(projects) do |project, level| name_prefix = (level > 0 ? ' ' * 2 * level + '» ' : '').html_safe tag_options = {:value => project.id} + tag_options[:title] = project.name if project == options[:selected] || (options[:selected].respond_to?(:include?) && options[:selected].include?(project)) tag_options[:selected] = 'selected' else diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 7ea49dad2..70a2e40e7 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -75,8 +75,8 @@ module AttachmentsHelper # this method is used to get all projects that tagged one tag # added by william - def get_attachments_by_tag(tag_name) - Attachment.tagged_with(tag_name).order('created_on desc') + def get_attachments_by_tag(tag_name,selected_tag_ids = nil) + Attachment.tagged_with(tag_name,{},selected_tag_ids).order('created_on desc') end # this method is used to get all attachments that from one project and tagged one tag diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index a5c25ecb5..118e0ccb1 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -35,8 +35,8 @@ module BidsHelper # this method is used to get all projects that tagged one tag # added by william - def get_bids_by_tag(tag_name) - Bid.tagged_with(tag_name).order('updated_on desc') + def get_bids_by_tag(tag_name,selected_tag_ids = nil) + Bid.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end #added by huang diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index 0bc3e5e73..983cf68bd 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -35,8 +35,8 @@ module ContestsHelper # this method is used to get all projects that tagged one tag # added by william - def get_contests_by_tag(tag_name) - Contest.tagged_with(tag_name).order('updated_on desc') + def get_contests_by_tag(tag_name,selected_tag_ids = nil) + Contest.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end #added by huang diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 99b21d8cc..77445532b 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -219,7 +219,7 @@ module CoursesHelper def render_course_hierarchy(courses) render_course_nested_lists(courses) do |course| - s = link_to_course(course, {}, :class => "#{course.css_classes} #{User.current.member_of?(course) ? 'my-course' : nil}").html_safe + s = link_to_course(course, {}, :class => "#{course.css_classes} #{User.current.member_of_course?(course) ? 'my-course' : nil}").html_safe s end end @@ -449,8 +449,8 @@ module CoursesHelper return homework_users end - def get_courses_by_tag(tag_name) - Course.tagged_with(tag_name).order('updated_at desc') + def get_courses_by_tag(tag_name,selected_tag_ids = nil) + Course.tagged_with(tag_name,{},selected_tag_ids).order('updated_at desc') end #课程实践年份下拉框 diff --git a/app/helpers/forums_helper.rb b/app/helpers/forums_helper.rb index 47a059e04..2d7b4bbb8 100644 --- a/app/helpers/forums_helper.rb +++ b/app/helpers/forums_helper.rb @@ -22,7 +22,7 @@ module ForumsHelper # this method is used to get all projects that tagged one tag # added by william - def get_forums_by_tag(tag_name) - Forum.tagged_with(tag_name).order('updated_at desc') + def get_forums_by_tag(tag_name,selected_tag_ids = nil) + Forum.tagged_with(tag_name,{},selected_tag_ids).order('updated_at desc') end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 637c92db3..b5f49331f 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -382,8 +382,8 @@ module IssuesHelper # this method is used to get all projects that tagged one tag # added by william - def get_issues_by_tag(tag_name) - Issue.tagged_with(tag_name).order('updated_on desc') + def get_issues_by_tag(tag_name,selected_tag_ids = nil) + Issue.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end end diff --git a/app/helpers/open_source_projects_helper.rb b/app/helpers/open_source_projects_helper.rb index dfc7cc8d0..8f7d31e05 100644 --- a/app/helpers/open_source_projects_helper.rb +++ b/app/helpers/open_source_projects_helper.rb @@ -31,8 +31,8 @@ module OpenSourceProjectsHelper s = content_tag('div', s, :class => 'user_tags') end - def get_open_source_projects_by_tag(tag_name) - OpenSourceProject.tagged_with(tag_name).order('created_at desc') + def get_open_source_projects_by_tag(tag_name,selected_tag_ids = nil) + OpenSourceProject.tagged_with(tag_name,{},selected_tag_ids).order('created_at desc') end def show_origin(url) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 5df3644ad..3beed444d 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -232,8 +232,8 @@ module ProjectsHelper # this method is used to get all projects that tagged one tag # added by william - def get_projects_by_tag(tag_name) - Project.tagged_with(tag_name).order('updated_on desc') + def get_projects_by_tag(tag_name,selected_tag_ids = nil) + Project.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end # added by fq diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 58935dd11..ac3d5ad57 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -57,8 +57,8 @@ module UsersHelper # this method is used to get all projects that tagged one tag # added by william - def get_users_by_tag(tag_name) - User.tagged_with(tag_name).order('updated_on desc') + def get_users_by_tag(tag_name,selected_tag_ids = nil) + User.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end # added by fq diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 7e70d55c7..c55143ca8 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -137,6 +137,11 @@ class IssueQuery < Query :type => :list_optional, :values => role_values ) unless role_values.empty? + #done_values = [10,20,30,40,50,60,70,80,90,100] + #add_available_filter("done_ratio_111", + # :type => :list_optional, :values => done_values + #) + if versions.any? add_available_filter "fixed_version_id", :type => :list_optional, diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 20b0c5c04..1115ca80e 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -26,7 +26,11 @@ <%= back_url_hidden_field_tag %>
+ | + + | <%= text_field_tag 'username', params[:username], :tabindex => '1' , :value => "#{l(:label_login_prompt)}", :onfocus => "clearInfo('username','#{l(:label_login_prompt)}')", @@ -35,33 +39,48 @@ | |
- | <%= password_field_tag 'password', nil, :tabindex => '2' %> | ++ + | ++ <%= password_field_tag 'password', nil, :tabindex => '2' %> + |
- | <%= text_field_tag "openid_url", nil, :tabindex => '3' %> | ++ + | ++ <%= text_field_tag "openid_url", nil, :tabindex => '3' %> + |
<% if Setting.autologin? %> - + <% end %> | |||
- <% if Setting.lost_password? %> + + <% if Setting.lost_password? %> <%= link_to l(:label_password_lost), lost_password_path %> <% end %> - |
- <%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %> -
-- - <%= image_tag(url_to_avatar(e.event_author), :class => "avatar") %> - | -
-
|
-
- <% @activity.event_types.each do |t| %>
- <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
-
-
- <% end %>
-
- -
-<% end %> -<%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %> -- <%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %> -
-<% end %> -<% end %> - -<% html_title(l(:label_activity), @author) -%> ++ <%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %> +
++ + <%= image_tag(url_to_avatar(e.event_author), :class => "avatar") %> + | +
+
|
+
+ <% @activity.event_types.each do |t| %>
+ <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
+
+
+ <% end %>
+
+ +
+<% end %> +<%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %> ++ <%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %> +
+<% end %> +<% end %> + +<% html_title(l(:label_activity), @author) -%> diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 30e60190d..d5359185e 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -33,7 +33,7 @@ <% end %> <% end %> <% if options[:author] %> -