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 %> - + - - + + <% if Setting.openid? %> - - + + <% end %>
+ + <%= 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 %> -
diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb index ef52a164d..694af0a14 100644 --- a/app/views/activities/index.html.erb +++ b/app/views/activities/index.html.erb @@ -1,101 +1,101 @@ -

<%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %>

-

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

-
- <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%> -
- - - - - -
- - <%= image_tag(url_to_avatar(e.event_author), :class => "avatar") %> - - - - - - - - - - - - -
- - <%= h(e.project) if @project.nil? || @project != e.project %> - - - <%= l(:label_new_activity) %> - - <%= link_to format_activity_title(e.event_title), e.event_url %> -
-

- <%= format_activity_description(e.event_description) %> -

-
- - <%= format_activity_day(day) %> - <%= format_time(e.event_datetime, false) %> - - - <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %> -
-
-
- <% end -%> -
- <% end -%> -
- - -<%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %> - -<% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %> -<% end %> - -<% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %> -<% end %> - -<% content_for :sidebar do %> -<%= form_tag({}, :method => :get) do %> -

<%= l(:label_activity) %>

-

- <% @activity.event_types.each do |t| %> - <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %> - -
- <% end %> -

-<% if @project && @project.descendants.active.any? %> -<%= hidden_field_tag 'with_subprojects', 0 %> -

- -

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

<%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %>

+

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

+
+ <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%> +
+ + + + + +
+ + <%= image_tag(url_to_avatar(e.event_author), :class => "avatar") %> + + + + + + + + + + + + +
+ + <%= h(e.project) if @project.nil? || @project != e.project %> + + + <%= l(:label_new_activity) %> + + <%= link_to format_activity_title(e.event_title), e.event_url %> +
+

+ <%= format_activity_description(e.event_description) %> +

+
+ + <%= format_activity_day(day) %> + <%= format_time(e.event_datetime, false) %> + + + <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %> +
+
+
+ <% end -%> +
+ <% end -%> +
+ + +<%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %> + +<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %> +<% end %> + +<% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %> +<% end %> + +<% content_for :sidebar do %> +<%= form_tag({}, :method => :get) do %> +

<%= l(:label_activity) %>

+

+ <% @activity.event_types.each do |t| %> + <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %> + +
+ <% end %> +

+<% if @project && @project.descendants.active.any? %> +<%= hidden_field_tag 'with_subprojects', 0 %> +

+ +

+<% 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] %> - + <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author) %>, <%= format_time(attachment.created_on) %> diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb index 784fb7ff8..8273c4b04 100644 --- a/app/views/bids/_history.html.erb +++ b/app/views/bids/_history.html.erb @@ -1,6 +1,8 @@ <% reply_allow = JournalsForMessage.create_by_user? User.current %> <% tip1 = (@bid.reward_type == 3) ? l(:label_student_response) : l(:label_user_response) %> -

<%=tip1%>

+

+ <%=tip1%> +

<%= render :partial => 'new', :locals => {:bid => @bid, :sta => @state} %> @@ -22,24 +24,31 @@
- - - - -
-

- <%=l(:label_notification)%> -

- - -
- -
-

- <%=l(:label_issue_feedback_activities)%> - <%= link_to l(:label_my_question), newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> - <%= link_to l(:label_my_feedback), suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> -

- <%= link_to l(:label_more_information), forums_path %> -
-
    - <% find_new_forum_topics(9 - @contest_notifications.count).each do |topic|%> -
  • -
    -       - <%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %> - -
    - - <%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %> - - - <%=l(:label_question_sponsor)%>: <%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %> - - - <%=l(:label_final_reply)%>: <% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %><%=link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%><% end %> - - - <%=l(:label_reply)%>(<%= link_to topic.try(:replies_count), topic.event_url %>) - -
    -
    -
  • - <% end %> -
-
-
- - - -
-

<%=l(:label_current_attendingcontest_work)%>

- <%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index'}, :target => "_blank" %> -
- <% 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 %> - -
    - <% else %> -

    <%= l(:label_no_ftapplication) %>

    - - <% end %> -
    -
    - - - -
    -<%= render partial: 'link_to_another' %> - - - +<% + @nav_dispaly_contest_label = 1 + @nav_dispaly_store_all_label = 1 +%> +<%= stylesheet_link_tag 'welcome' %> + + + + + +
    + <%#= render partial: 'wei_xin' %> +
    + +
    + <% 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;'%> +   + <%= hidden_field_tag 'project_type', params[:project_type] %> + <%= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %> + <% end %> + +
    +
    +
    +
    + +
    + +
    +

    <%=l(:label_current_hot_contest)%>

    + + <% if User.current.logged? %> + <% unless User.current.user_extensions.identity == 1 %> + <%= link_to(l(:label_newtype_contest), new_contest_contests_path, :class => 'icon icon-add') %> + <% end %> + <% end %> +    + <%= link_to l(:label_more), {:controller => 'contests', :action => 'index'}, :target => "_blank" %> + +
    +
    + <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %> +
  • +
    + <%= image_tag('/images/contest1.png')%> +
    +
    + <%= link_to(contest.name.truncate(50, omission: '...'), contest_contestnotifications_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> + <% if contest.id == 2 or contest.id == 3 or contest.id == 6 %> + (<%= link_to("#{contest.projects.where('is_public=1').count}"+l(:label_work_quantity), show_attendingcontest_contest_path(contest), :target => "_blank") %>) + <% else %> + (<%= 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 %> +
    +
    +
    + + +
    +

    + <%=l(:label_notification)%> +

    + + +
    + +
    +

    + <%=l(:label_issue_feedback_activities)%> + <%= link_to l(:label_my_question), newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> + <%= link_to l(:label_my_feedback), suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> +

    + <%= link_to l(:label_more_information), forums_path %> +
    +
      + <% find_new_forum_topics(9 - @contest_notifications.count).each do |topic|%> +
    • +
      +       + <%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %> + +
      + + <%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %> + + + <%=l(:label_question_sponsor)%>: <%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %> + + + <%=l(:label_final_reply)%>: <% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %><%=link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%><% end %> + + + <%=l(:label_reply)%>(<%= link_to topic.try(:replies_count), topic.event_url %>) + +
      +
      +
    • + <% end %> +
    +
    +
    + + + +
    +

    <%=l(:label_current_attendingcontest_work)%>

    + <%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index'}, :target => "_blank" %> +
    + <% 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 %> + +
    + <% else %> +

    <%= l(:label_no_ftapplication) %>

    + + <% end %> +
    +
    + + + +
    +<%= render partial: 'link_to_another' %> + + + diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index b76b14e1d..171b2b764 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -1,193 +1,205 @@ -<% @nav_dispaly_project_label = 1 - @nav_dispaly_forum_label = 1 %> -<%= stylesheet_link_tag 'welcome' %> -<%= javascript_include_tag 'welcome' %> - - -
    - <%#= render partial: 'wei_xin' %> -
    -
    - - <% if get_avatar?(@first_page) %> - <%= image_tag(url_to_avatar(@first_page), width:@first_page.image_width,height: @first_page.image_height) %> - <% else %> - <%= image_tag '/images/transparent.png', width:@first_page.image_width,height: @first_page.image_height %> - <% end %> - -
    -
    - <% unless @first_page.nil? %> - <%= @first_page.description.html_safe %> - <% end %> -
    - -
    -
    -
    - -
    - -
    -

    - <%= l(:lable_hot_projects)%> -

    - - <% if User.current.logged? %> - <%= link_to(l(:label_project_new), {:controller => 'projects', - :action => 'new', - :course => 0, - :project_type =>( @project_type||=0)}, - :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> - <% end %> -    - <%= link_to l(:label_more), { :controller => 'projects', - :action => 'index', - :project_type => 0, - :host => Setting.project_domain}, - :target => "_blank" %> - -
    -
      - <% @projects.map do |project| %> -
    • -
      - <%= image_tag(get_project_avatar(project), :class => "avatar-4") %> -
      - -
      - <% unless project.is_public %> - <%= l(:label_private) %> - <% end %> - <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> - (<%= link_to "#{projectCount(project)}人", project_member_path(project) ,:course =>'0' %>) -
      -
      - - <%=project.description.truncate(100, omission: '...')%> - -
      -
      - <%= content_tag "span", l(:label_project_score)+ ":" + red_project_scores(project).to_i.to_s, - :style => "cursor: pointer; display: inline-block; float: right; color: #ec6300;", - :title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度", - :class => "tooltip", - :id => "tooltip-#{project.id}" %> -
      -
    • - - <% end; reset_cycle %> -
    -
    -
    - -
    - -
    - -
    - -
    - -
    +<% @nav_dispaly_project_label = 1 + @nav_dispaly_forum_label = 1 %> +<%= stylesheet_link_tag 'welcome' %> +<%= javascript_include_tag 'welcome' %> + + +
    + <%#= render partial: 'wei_xin' %> +
    +
    + + <% if get_avatar?(@first_page) %> + <%= image_tag(url_to_avatar(@first_page), width:@first_page.image_width,height: @first_page.image_height) %> + <% else %> + <%= image_tag '/images/transparent.png', width:@first_page.image_width,height: @first_page.image_height %> + <% end %> + +
    +
    + <% unless @first_page.nil? %> + <%= @first_page.description.html_safe %> + <% end %> +
    + +
    +
    +
    + +
    + +
    +

    + + <%= l(:lable_hot_projects)%> + +

    + + <% if User.current.logged? %> + <%= link_to(l(:label_project_new), {:controller => 'projects', + :action => 'new', + :course => 0, + :project_type =>( @project_type||=0)}, + :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> + <% end %> +    + <%= link_to l(:label_more), { :controller => 'projects', + :action => 'index', + :project_type => 0, + :host => Setting.project_domain}, + :target => "_blank" %> + +
    +
      + <% @projects.map do |project| %> +
    • +
      + <%= image_tag(get_project_avatar(project), :class => "avatar-4") %> +
      + +
      + <% unless project.is_public %> + + <%= l(:label_private) %> + + <% end %> + <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> + (<%= link_to "#{projectCount(project)}人", project_member_path(project) ,:course =>'0' %>) +
      +
      + + <%=project.description.truncate(90, omission: '...')%> + +
      +
      + <%= content_tag "span", l(:label_project_score)+ ":" + red_project_scores(project).to_i.to_s, + :style => "cursor: pointer; display: inline-block; float: right; color: #ec6300;", + :title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度", + :class => "tooltip", + :id => "tooltip-#{project.id}" %> +
      +
    • + + <% end; reset_cycle %> +
    +
    +
    + +
    + +
    + +
    + +
    + +
    <%= render partial: 'link_to_another' %> \ No newline at end of file diff --git a/app/views/wiki/diff.html.erb b/app/views/wiki/diff.html.erb index 0bdbc88dc..adeaa7cab 100644 --- a/app/views/wiki/diff.html.erb +++ b/app/views/wiki/diff.html.erb @@ -1,33 +1,33 @@ -
    - <%= link_to(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history') %> -
    - -<%= wiki_page_breadcrumb(@page) %> - -

    - <%= h(@page.pretty_title) %> -

    - -

    - <%= l(:label_version) %> - <%= link_to @diff.content_from.version, :action => 'show', :id => @page.title, :project_id => @page.project, :version => @diff.content_from.version %> - - (<%= @diff.content_from.author ? @diff.content_from.author.name : l(:label_user_anonymous)%>, - <%= format_time(@diff.content_from.updated_on) %>) - -→ - <%= l(:label_version) %> - <%= link_to @diff.content_to.version, :action => 'show', - :id => @page.title, :project_id => @page.project, - :version => @diff.content_to.version %> - / - <%= @page.content.version %> - - (<%= @diff.content_to.author ? link_to_user(@diff.content_to.author.name) : l(:label_user_anonymous)%>, - <%= format_time(@diff.content_to.updated_on) %>) - -

    - -
    - <%= simple_format_without_paragraph @diff.to_html %> -
    +
    + <%= link_to(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history') %> +
    + +<%= wiki_page_breadcrumb(@page) %> + +

    + <%= h(@page.pretty_title) %> +

    + +

    + <%= l(:label_version) %> + <%= link_to @diff.content_from.version, :action => 'show', :id => @page.title, :project_id => @page.project, :version => @diff.content_from.version %> + + (<%= @diff.content_from.author ? @diff.content_from.author.name : l(:label_user_anonymous)%>, + <%= format_time(@diff.content_from.updated_on) %>) + +→ + <%= l(:label_version) %> + <%= link_to @diff.content_to.version, :action => 'show', + :id => @page.title, :project_id => @page.project, + :version => @diff.content_to.version %> + / + <%= @page.content.version %> + + (<%= @diff.content_to.author ? link_to_user(@diff.content_to.author.name) : l(:label_user_anonymous)%>, + <%= format_time(@diff.content_to.updated_on) %>) + +

    + +
    + <%= simple_format_without_paragraph @diff.to_html %> +
    diff --git a/app/views/wiki/edit.html.erb b/app/views/wiki/edit.html.erb index 6154ca22d..88c280608 100644 --- a/app/views/wiki/edit.html.erb +++ b/app/views/wiki/edit.html.erb @@ -1,62 +1,62 @@ -<%= wiki_page_breadcrumb(@page) %> - - -

    - <%= h @page.pretty_title %> -

    - -<%= form_for @content, :as => :content, - :url => {:action => 'update', :id => @page.title}, - :html => {:method => :put, :multipart => true, :id => 'wiki_form'} do |f| %> - <%= f.hidden_field :version %> - <% if @section %> - <%= hidden_field_tag 'section', @section %> - <%= hidden_field_tag 'section_hash', @section_hash %> - <% end %> - <%= error_messages_for 'content' %> - -
    -

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

    - -
    - -
    - <% if @page.safe_attribute_names.include?('parent_id') && @wiki.pages.any? %> - <%= fields_for @page do |fp| %> -

    - - <%= fp.select :parent_id,content_tag('option', '', :value => '') + wiki_page_options_for_select(@wiki.pages.all(:include => :parent) - @page.self_and_descendants, @page.parent) %> -

    - <% end %> - <% end %> - -

    - - <%= f.text_field :comments, :style => "width:75%;" %> -

    -

    - - <%= render :partial => 'attachments/form' %> -

    -
    - -

    - <%= submit_tag l(:button_save) %> -

    - <%= wikitoolbar_for 'content_text' %> -<% end %> -
    -<% content_for :header_tags do %> - <%= robot_exclusion_tag %> -<% end %> -<% html_title @page.pretty_title %> +<%= wiki_page_breadcrumb(@page) %> + + +

    + <%= h @page.pretty_title %> +

    + +<%= form_for @content, :as => :content, + :url => {:action => 'update', :id => @page.title}, + :html => {:method => :put, :multipart => true, :id => 'wiki_form'} do |f| %> + <%= f.hidden_field :version %> + <% if @section %> + <%= hidden_field_tag 'section', @section %> + <%= hidden_field_tag 'section_hash', @section_hash %> + <% end %> + <%= error_messages_for 'content' %> + +
    +

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

    + +
    + +
    + <% if @page.safe_attribute_names.include?('parent_id') && @wiki.pages.any? %> + <%= fields_for @page do |fp| %> +

    + + <%= fp.select :parent_id,content_tag('option', '', :value => '') + wiki_page_options_for_select(@wiki.pages.all(:include => :parent) - @page.self_and_descendants, @page.parent) %> +

    + <% end %> + <% end %> + +

    + + <%= f.text_field :comments, :style => "width:75%;" %> +

    +

    + + <%= render :partial => 'attachments/form',:locals => {:container => @page} %> +

    +
    + +

    + <%= submit_tag l(:button_save) %> +

    + <%= wikitoolbar_for 'content_text' %> +<% end %> +
    +<% content_for :header_tags do %> + <%= robot_exclusion_tag %> +<% end %> +<% html_title @page.pretty_title %> diff --git a/app/views/words/_journal_reply.html.erb b/app/views/words/_journal_reply.html.erb index 6f87443c4..d9b9b4587 100644 --- a/app/views/words/_journal_reply.html.erb +++ b/app/views/words/_journal_reply.html.erb @@ -1,7 +1,7 @@ <% id = "journal_reply_ul_" + journal.id.to_s%> diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 0c33bedd3..030a0cdcd 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -2,33 +2,39 @@ <% ids_r = 'reply_respond_form_'+ reply.id.to_s %>
  • - <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> + <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %>
    - <% id = 'project_respond_form_'+ reply.id.to_s %> + <% id = 'project_respond_form_'+ reply.id.to_s %>

    - <%= link_to reply.user.name, user_path(reply.user) %>:  - <%= reply.notes %> + + <%= link_to reply.user.name, user_path(reply.user) %> + :  + + + <%= reply.notes %> +

    - <%= format_time reply.created_on %> - + + <%= format_time reply.created_on %> + +

    - <% if reply_allow %> + <% if reply_allow %> <%= render :partial => "words/new_respond", :locals => {:journal => journal, :m_reply_id => m_reply_id} %> - <% end %> + <% end %>
  • \ No newline at end of file diff --git a/app/views/words/_new_respond.html.erb b/app/views/words/_new_respond.html.erb index 64b83d777..5671bcfa5 100644 --- a/app/views/words/_new_respond.html.erb +++ b/app/views/words/_new_respond.html.erb @@ -1,5 +1,5 @@ -<%= form_tag({:controller => 'words', :action => 'create_reply'}, :remote => true) do %> +<%= form_tag(words_create_reply_path, :remote => true) do %> <%= text_area_tag 'user_notes', "", :class => 'noline', :style => "resize: none;", :rows => 4, :placeholder => l(:label_projects_feedback_respond_content), diff --git a/app/views/words/create_reply.js.erb b/app/views/words/create_reply.js.erb index 6af90ef02..b24f46641 100644 --- a/app/views/words/create_reply.js.erb +++ b/app/views/words/create_reply.js.erb @@ -5,15 +5,12 @@ ) %>').hide(); $('#journal_reply_ul_<%=@jfm.m_parent_id%>').append(pre_append); pre_append.fadeIn(600); - -var textarea = $('#project_respond_form_<%=@jfm.m_reply_id.to_s%> textarea'); -textarea.val(''); -$('#project_respond_form_<%=@jfm.m_reply_id.to_s%>').hide(); - -var textarea1 = $('#course_respond_form_<%=@jfm.m_reply_id.to_s%> textarea'); -textarea1.val(''); -$('#course_respond_form_<%=@jfm.m_reply_id.to_s%>').hide(); - + var textarea = $('#project_respond_form_<%=@jfm.m_reply_id.to_s%> textarea'); + textarea.val(''); + $('#project_respond_form_<%=@jfm.m_reply_id.to_s%>').hide(); + var textarea1 = $('#course_respond_form_<%=@jfm.m_reply_id.to_s%> textarea'); + textarea1.val(''); + $('#course_respond_form_<%=@jfm.m_reply_id.to_s%>').hide(); setMaxLengthItem(pre_append.find('textarea')[0]); <% else %> alert("<%= l(:label_feedback_fail) %>"); diff --git a/config/configuration.yml b/config/configuration.yml index 833b19083..21337e3b4 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -204,6 +204,8 @@ default: # specific configuration options for production environment # that overrides the default ones production: + # CJK support + rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf # specific configuration options for development environment # that overrides the default ones diff --git a/config/locales/en.yml b/config/locales/en.yml index e7cf73511..e886683f0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1840,4 +1840,6 @@ en: label_my_school: My school label_all_schol: All school label_select_province: Please select the provinces - label_search_conditions_not_null: The search conditions can not be empty \ No newline at end of file + label_search_conditions_not_null: The search conditions can not be empty + lable_school_list: List of schools + button_delete_file: delete \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index e37e6a370..c330b8b90 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2006,7 +2006,7 @@ zh: label_work_scores: 作品得分 label_work_rating: 评分 label_work_tishi: 您可以重新打分,打分结果以最后一次打分为主! - label_work_scores_proportion: 得分比例 + label_work_scores_people: 得分人数 label_softapplication_type: 应用分类 label_work_type: 作品分类 label_work_photo: 作品截图 @@ -2168,3 +2168,5 @@ zh: label_contest_news_condition: 竞赛描述超过5000个汉字 label_no_contest_news_title: 竞赛标题不能为空 label_contest_news_title_condition: 竞赛标题超过255个汉字 + label_subject_empty: 主题不能为空 + label_course_organizers: 开设单位 diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index f0f06ee26..609b35415 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -1,170 +1,170 @@ -# 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. - -module Redmine - module Acts - module Attachable - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - def acts_as_attachable(options = {}) - cattr_accessor :attachable_options - self.attachable_options = {} - attachable_options[:view_permission] = options.delete(:view_permission) || "view_#{self.name.pluralize.underscore}".to_sym - attachable_options[:delete_permission] = options.delete(:delete_permission) || "edit_#{self.name.pluralize.underscore}".to_sym - - has_many :attachments, options.merge(:as => :container, - :order => "#{Attachment.table_name}.created_on ASC, #{Attachment.table_name}.id ASC", - :dependent => :destroy) - send :include, Redmine::Acts::Attachable::InstanceMethods - before_save :attach_saved_attachments - end - end - - module InstanceMethods - def self.included(base) - base.extend ClassMethods - end - - def attachments_visible?(user=User.current) - if self.respond_to?(:project) - (respond_to?(:visible?) ? visible?(user) : true) && - user.allowed_to?(self.class.attachable_options[:view_permission], self.project) - else - return true - end - - end - - def attachments_deletable?(user=User.current) - if (self.has_attribute?(:course) ||self.has_attribute?(:course_id)) && self.course - #默认给予删除自己上传的附件的权限 - (respond_to?(:visible?) ? visible?(user) : true) && - (user.allowed_to?(self.class.attachable_options[:delete_permission], self.course) || (self.has_attribute?(:author_id) && self.author == user)) - else - #默认给予删除自己上传的附件的权限 - (respond_to?(:visible?) ? visible?(user) : true) && - (user.allowed_to?(self.class.attachable_options[:delete_permission], self.project) || (self.has_attribute?(:author_id) && self.author == user)) - end - end - - def saved_attachments - @saved_attachments ||= [] - end - - def unsaved_attachments - @unsaved_attachments ||= [] - end - - # 设置资源文件的公开属性 - # add by nwb - def set_attachment_public(res) - # 公开的资源判断他的父级的公开属性 - if res.is_public - if( (self.class.to_s=="Project" && self.is_public == false) || - (self.has_attribute?(:project) && self.project && self.project.is_public == false) || - (self.has_attribute?(:board) && self.board.project && self.board.project.is_public == false) || - (self.class.to_s=="HomeworkAttach" && self.bid.reward_type == 3) || - (self.class.to_s=="Course" && self.is_public == false) || - (self.has_attribute?(:course) && self.course && self.course.is_public == false) || - (self.has_attribute?(:board) && self.board.course && self.board.course.is_public == false) - ) - res.is_public = false - end - end - end - - def save_attachmentsex(attachments, author=User.current,attachment_type) - @curattachment_type = attachment_type - result = save_attachments(attachments,author) - result - end - - def save_attachments(attachments, author=User.current) - # 清除临时文件 - if attachments - tempAttach = attachments[:dummy] - if tempAttach && tempAttach[:file] - attachments.delete(:dummy) - end - end - - if attachments.is_a?(Hash) - attachments = attachments.stringify_keys - attachments = attachments.to_a.sort {|a, b| - if a.first.to_i > 0 && b.first.to_i > 0 - a.first.to_i <=> b.first.to_i - elsif a.first.to_i > 0 - 1 - elsif b.first.to_i > 0 - -1 - else - a.first <=> b.first - end - } - attachments = attachments.map(&:last) - end - if attachments.is_a?(Array) - attachments.each do |attachment| - if attachment.is_a?(Hash) - a = nil - file = attachment['file'] - token = attachment['token'] - t = file && file.size > 0 - if file && file.size > 0 - a = Attachment.create(:file => file, :author => author) - elsif token - a = Attachment.find_by_token_only(token) - if a - a.filename = attachment['filename'] unless attachment['filename'].blank? - a.content_type = attachment['content_type'] - end - end - end - if a && !attachment['is_public_checkbox'] - a.is_public = false - elsif a && attachment['is_public_checkbox'] - a.is_public = true - end - set_attachment_public(a) if a - next unless a - a.description = attachment['description'].to_s.strip - a.attachtype = @curattachment_type - if a.new_record? - unsaved_attachments << a - else - saved_attachments << a - end - end - end - {:files => saved_attachments, :unsaved => unsaved_attachments} - end - - def attach_saved_attachments - saved_attachments.each do |attachment| - self.attachments << attachment - end - end - - module ClassMethods - end - end - end - 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. + +module Redmine + module Acts + module Attachable + def self.included(base) + base.extend ClassMethods + end + + module ClassMethods + def acts_as_attachable(options = {}) + cattr_accessor :attachable_options + self.attachable_options = {} + attachable_options[:view_permission] = options.delete(:view_permission) || "view_#{self.name.pluralize.underscore}".to_sym + attachable_options[:delete_permission] = options.delete(:delete_permission) || "edit_#{self.name.pluralize.underscore}".to_sym + + has_many :attachments, options.merge(:as => :container, + :order => "#{Attachment.table_name}.created_on ASC, #{Attachment.table_name}.id ASC", + :dependent => :destroy) + send :include, Redmine::Acts::Attachable::InstanceMethods + before_save :attach_saved_attachments + end + end + + module InstanceMethods + def self.included(base) + base.extend ClassMethods + end + + def attachments_visible?(user=User.current) + if self.respond_to?(:project) + (respond_to?(:visible?) ? visible?(user) : true) && + user.allowed_to?(self.class.attachable_options[:view_permission], self.project) + else + return true + end + + end + + def attachments_deletable?(user=User.current) + if (self.has_attribute?(:course) ||self.has_attribute?(:course_id)) && self.course + #默认给予删除自己上传的附件的权限 + (respond_to?(:visible?) ? visible?(user) : true) && + (user.allowed_to?(self.class.attachable_options[:delete_permission], self.course) || (self.has_attribute?(:author_id) && self.author == user)) + else + #默认给予删除自己上传的附件的权限 + (respond_to?(:visible?) ? visible?(user) : true) && + (user.allowed_to?(self.class.attachable_options[:delete_permission], self.project) || (self.has_attribute?(:author_id) && self.author == user)) + end + end + + def saved_attachments + @saved_attachments ||= [] + end + + def unsaved_attachments + @unsaved_attachments ||= [] + end + + # 设置资源文件的公开属性 + # add by nwb + def set_attachment_public(res) + # 公开的资源判断他的父级的公开属性 + if res.is_public + if( (self.class.to_s=="Project" && self.is_public == false) || + (self.has_attribute?(:project) && self.project && self.project.is_public == false) || + (self.has_attribute?(:board) && self.board.project && self.board.project.is_public == false) || + (self.class.to_s=="HomeworkAttach" && self.bid.reward_type == 3) || + (self.class.to_s=="Course" && self.is_public == false) || + (self.has_attribute?(:course) && self.course && self.course.is_public == false) || + (self.has_attribute?(:board) && self.board.course && self.board.course.is_public == false) + ) + res.is_public = false + end + end + end + + def save_attachmentsex(attachments, author=User.current,attachment_type) + @curattachment_type = attachment_type + result = save_attachments(attachments,author) + result + end + + def save_attachments(attachments, author=User.current) + # 清除临时文件 + if attachments + tempAttach = attachments[:dummy] + if tempAttach && tempAttach[:file] + attachments.delete(:dummy) + end + end + + if attachments.is_a?(Hash) + attachments = attachments.stringify_keys + attachments = attachments.to_a.sort {|a, b| + if a.first.to_i > 0 && b.first.to_i > 0 + a.first.to_i <=> b.first.to_i + elsif a.first.to_i > 0 + 1 + elsif b.first.to_i > 0 + -1 + else + a.first <=> b.first + end + } + attachments = attachments.map(&:last) + end + if attachments.is_a?(Array) + attachments.each do |attachment| + if attachment.is_a?(Hash) + a = nil + file = attachment['file'] + token = attachment['token'] + t = file && file.size > 0 + if file && file.size > 0 + a = Attachment.create(:file => file, :author => author) + elsif token + a = Attachment.find_by_token_only(token) + if a + a.filename = attachment['filename'] unless attachment['filename'].blank? + a.content_type = attachment['content_type'] + end + end + end + if a && !attachment['is_public_checkbox'] + a.is_public = false + elsif a && attachment['is_public_checkbox'] + a.is_public = true + end + set_attachment_public(a) if a + next unless a + a.description = attachment['description'].to_s.strip + a.attachtype = @curattachment_type + if a.new_record? + unsaved_attachments << a + else + saved_attachments << a + end + end + end + {:files => saved_attachments, :unsaved => unsaved_attachments} + end + + def attach_saved_attachments + saved_attachments.each do |attachment| + self.attachments << attachment + end + end + + module ClassMethods + end + end + end + end +end diff --git a/plugins/redmine_code_review/app/views/code_review/_show.html.erb b/plugins/redmine_code_review/app/views/code_review/_show.html.erb index a626b6281..f83306ffa 100644 --- a/plugins/redmine_code_review/app/views/code_review/_show.html.erb +++ b/plugins/redmine_code_review/app/views/code_review/_show.html.erb @@ -24,10 +24,14 @@ <%= error_messages_for 'review' -%> <%= error_messages_for 'reply' -%> <% if @notice -%> -
    <%= @notice -%>
    +
    + <%= @notice -%> +
    <% end -%> <% if @error -%> -
    <%= @error -%>
    +
    + <%= @error -%> +
    <% end -%> @@ -77,9 +81,7 @@ - diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 1504019d7..8ea71909b 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -1,233 +1,233 @@ -/* Redmine - project management software - Copyright (C) 2006-2013 Jean-Philippe Lang */ - -function postUpMsg(attachmentId) -{ - $.ajax({ - url: '/attachments/renderTag', - type: "GET", - data: { - attachmentId: attachmentId - } - - }) -} -function addFile(inputEl, file, eagerUpload) { - - if ($('#attachments_fields').children().length < 10) { - - var attachmentId = addFile.nextAttachmentId++; - - var fileSpan = $('', { 'id': 'attachments_' + attachmentId, 'class':'attachment' }); - - fileSpan.append( - $('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), - $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), - $('公开:').attr({ 'class': 'ispublic-label' }) , - $('', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload), - $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload), - $('
    ', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} ) - ).appendTo('#attachments_fields'); - - if(eagerUpload) { - ajaxUpload(file, attachmentId, fileSpan, inputEl); - - } - return attachmentId; - } - return null; -} - -addFile.nextAttachmentId = 1; - -function ajaxUpload(file, attachmentId, fileSpan, inputEl) { - - function onLoadstart(e) { - fileSpan.removeClass('ajax-waiting'); - fileSpan.addClass('ajax-loading'); - $('input:submit', $(this).parents('form')).attr('disabled', 'disabled'); - } - - function onProgress(e) { - if(e.lengthComputable) { - this.progressbar( 'value', e.loaded * 100 / e.total ); - } - } - - function actualUpload(file, attachmentId, fileSpan, inputEl) { - - ajaxUpload.uploading++; - - uploadBlob(file, $(inputEl).data('upload-path'), attachmentId, { - loadstartEventHandler: onLoadstart.bind(progressSpan), - progressEventHandler: onProgress.bind(progressSpan) - }) - .done(function(result) { - progressSpan.progressbar( 'value', 100 ).remove(); - fileSpan.find('input.description, a').css('display', 'inline-block'); - fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block'); - }) - .fail(function(result) { - progressSpan.text(result.statusText); - if($("#network_issue")) - { - $("#network_issue").show(); - } - }).always(function() { - ajaxUpload.uploading--; - fileSpan.removeClass('ajax-loading'); - var form = fileSpan.parents('form'); - if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) { - $('input:submit', form).removeAttr('disabled'); - } - form.dequeue('upload'); - }); - - //gcm files count and add delete_all link - - var count=$('#attachments_fields>span').length; - $('#upload_file_count').html("已上传"+""+count+""+"个文件"); - - if(count>=1){ - var add_attachs=$('.add_attachment'); - var delete_all=$('.remove_all'); - if(delete_all.length<1){ - add_attachs.append($(" ").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"})); - } - } - - //gcm - - } - - var progressSpan = $('
    ').insertAfter(fileSpan.find('input.filename')); - progressSpan.progressbar(); - fileSpan.addClass('ajax-waiting'); - - var maxSyncUpload = $(inputEl).data('max-concurrent-uploads'); - - if(maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload) - actualUpload(file, attachmentId, fileSpan, inputEl); - else - $(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl)); -} - -ajaxUpload.uploading = 0; - -function removeFile() { - $(this).parent('span').remove(); - return false; -} - -//gcm delete all file -function removeAll(){ - if(confirm("您确定要删除所有文件吗?")){ - $(".remove-upload").removeAttr("data-confirm"); - $(".remove-upload").click(); - } -// return false; -} -//gcm - -function uploadBlob(blob, uploadUrl, attachmentId, options) { - - var actualOptions = $.extend({ - loadstartEventHandler: $.noop, - progressEventHandler: $.noop - }, options); - - uploadUrl = uploadUrl + '?attachment_id=' + attachmentId; - if (blob instanceof window.File) { - uploadUrl += '&filename=' + encodeURIComponent(blob.name); - } - - return $.ajax(uploadUrl, { - type: 'POST', - contentType: 'application/octet-stream', - beforeSend: function(jqXhr) { - jqXhr.setRequestHeader('Accept', 'application/js'); - }, - xhr: function() { - var xhr = $.ajaxSettings.xhr(); - xhr.upload.onloadstart = actualOptions.loadstartEventHandler; - xhr.upload.onprogress = actualOptions.progressEventHandler; - return xhr; - }, - data: blob, - cache: false, - processData: false - }); -} - -function addInputFiles(inputEl) { - // var clearedFileInput = $(inputEl).clone().val(''); - - if (inputEl.files) { - // upload files using ajax - uploadAndAttachFiles(inputEl.files, inputEl); - // $(inputEl).remove(); - } else { - // browser not supporting the file API, upload on form submission - var attachmentId; - var aFilename = inputEl.value.split(/\/|\\/); - attachmentId = addFile(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false); - if (attachmentId) { - $(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]', style: 'display:none;' }).appendTo('#attachments_' + attachmentId); - } - } - - //clearedFileInput.insertAfter('#attachments_fields'); -} - -function uploadAndAttachFiles(files, inputEl) { - - var maxFileSize = $(inputEl).data('max-file-size'); - var maxFileSizeExceeded = $(inputEl).data('max-file-size-message'); - - var sizeExceeded = false; - $.each(files, function() { - if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;} - }); - if (sizeExceeded) { - window.alert(maxFileSizeExceeded); - } else { - $.each(files, function() {addFile(inputEl, this, true);}); - } -} - -function handleFileDropEvent(e) { - - $(this).removeClass('fileover'); - blockEventPropagation(e); - - if ($.inArray('Files', e.dataTransfer.types) > -1) { - uploadAndAttachFiles(e.dataTransfer.files, $('input:file.file_selector')); - } -} - -function dragOverHandler(e) { - $(this).addClass('fileover'); - blockEventPropagation(e); -} - -function dragOutHandler(e) { - $(this).removeClass('fileover'); - blockEventPropagation(e); -} - -function setupFileDrop() { - if (window.File && window.FileList && window.ProgressEvent && window.FormData) { - - $.event.fixHooks.drop = { props: [ 'dataTransfer' ] }; - - $('form div.box').has('input:file').each(function() { - $(this).on({ - dragover: dragOverHandler, - dragleave: dragOutHandler, - drop: handleFileDropEvent - }); - }); - } -} - -$(document).ready(setupFileDrop); +/* Redmine - project management software + Copyright (C) 2006-2013 Jean-Philippe Lang */ + +function postUpMsg(attachmentId) +{ + $.ajax({ + url: '/attachments/renderTag', + type: "GET", + data: { + attachmentId: attachmentId + } + + }) +} +function addFile(inputEl, file, eagerUpload) { + + if ($('#attachments_fields').children().length < 10) { + + var attachmentId = addFile.nextAttachmentId++; + + var fileSpan = $('', { 'id': 'attachments_' + attachmentId, 'class':'attachment' }); + + fileSpan.append( + $('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), + $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), + $('公开:').attr({ 'class': 'ispublic-label' }) , + $('', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload), + $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload), + $('
    ', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} ) + ).appendTo('#attachments_fields'); + + if(eagerUpload) { + ajaxUpload(file, attachmentId, fileSpan, inputEl); + + } + return attachmentId; + } + return null; +} + +addFile.nextAttachmentId = 1; + +function ajaxUpload(file, attachmentId, fileSpan, inputEl) { + + function onLoadstart(e) { + fileSpan.removeClass('ajax-waiting'); + fileSpan.addClass('ajax-loading'); + $('input:submit', $(this).parents('form')).attr('disabled', 'disabled'); + } + + function onProgress(e) { + if(e.lengthComputable) { + this.progressbar( 'value', e.loaded * 100 / e.total ); + } + } + + function actualUpload(file, attachmentId, fileSpan, inputEl) { + + ajaxUpload.uploading++; + + uploadBlob(file, $(inputEl).data('upload-path'), attachmentId, { + loadstartEventHandler: onLoadstart.bind(progressSpan), + progressEventHandler: onProgress.bind(progressSpan) + }) + .done(function(result) { + progressSpan.progressbar( 'value', 100 ).remove(); + fileSpan.find('input.description, a').css('display', 'inline-block'); + fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block'); + }) + .fail(function(result) { + progressSpan.text(result.statusText); + if($("#network_issue")) + { + $("#network_issue").show(); + } + }).always(function() { + ajaxUpload.uploading--; + fileSpan.removeClass('ajax-loading'); + var form = fileSpan.parents('form'); + if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) { + $('input:submit', form).removeAttr('disabled'); + } + form.dequeue('upload'); + }); + + //gcm files count and add delete_all link + + var count=$('#attachments_fields>span').length; + $('#upload_file_count').html("已上传"+""+count+""+"个文件"); + + if(count>=1){ + var add_attachs=$('.add_attachment'); + var delete_all=$('.remove_all'); + if(delete_all.length<1){ + add_attachs.append($(" ").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"})); + } + } + + //gcm + + } + + var progressSpan = $('
    ').insertAfter(fileSpan.find('input.filename')); + progressSpan.progressbar(); + fileSpan.addClass('ajax-waiting'); + + var maxSyncUpload = $(inputEl).data('max-concurrent-uploads'); + + if(maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload) + actualUpload(file, attachmentId, fileSpan, inputEl); + else + $(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl)); +} + +ajaxUpload.uploading = 0; + +function removeFile() { + $(this).parent('span').remove(); + return false; +} + +//gcm delete all file +function removeAll(){ + if(confirm("您确定要删除所有文件吗?")){ + $(".remove-upload").removeAttr("data-confirm"); + $(".remove-upload").click(); + } +// return false; +} +//gcm + +function uploadBlob(blob, uploadUrl, attachmentId, options) { + + var actualOptions = $.extend({ + loadstartEventHandler: $.noop, + progressEventHandler: $.noop + }, options); + + uploadUrl = uploadUrl + '?attachment_id=' + attachmentId; + if (blob instanceof window.File) { + uploadUrl += '&filename=' + encodeURIComponent(blob.name); + } + + return $.ajax(uploadUrl, { + type: 'POST', + contentType: 'application/octet-stream', + beforeSend: function(jqXhr) { + jqXhr.setRequestHeader('Accept', 'application/js'); + }, + xhr: function() { + var xhr = $.ajaxSettings.xhr(); + xhr.upload.onloadstart = actualOptions.loadstartEventHandler; + xhr.upload.onprogress = actualOptions.progressEventHandler; + return xhr; + }, + data: blob, + cache: false, + processData: false + }); +} + +function addInputFiles(inputEl) { + // var clearedFileInput = $(inputEl).clone().val(''); + + if (inputEl.files) { + // upload files using ajax + uploadAndAttachFiles(inputEl.files, inputEl); + // $(inputEl).remove(); + } else { + // browser not supporting the file API, upload on form submission + var attachmentId; + var aFilename = inputEl.value.split(/\/|\\/); + attachmentId = addFile(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false); + if (attachmentId) { + $(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]', style: 'display:none;' }).appendTo('#attachments_' + attachmentId); + } + } + + //clearedFileInput.insertAfter('#attachments_fields'); +} + +function uploadAndAttachFiles(files, inputEl) { + + var maxFileSize = $(inputEl).data('max-file-size'); + var maxFileSizeExceeded = $(inputEl).data('max-file-size-message'); + + var sizeExceeded = false; + $.each(files, function() { + if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;} + }); + if (sizeExceeded) { + window.alert(maxFileSizeExceeded); + } else { + $.each(files, function() {addFile(inputEl, this, true);}); + } +} + +function handleFileDropEvent(e) { + + $(this).removeClass('fileover'); + blockEventPropagation(e); + + if ($.inArray('Files', e.dataTransfer.types) > -1) { + uploadAndAttachFiles(e.dataTransfer.files, $('input:file.file_selector')); + } +} + +function dragOverHandler(e) { + $(this).addClass('fileover'); + blockEventPropagation(e); +} + +function dragOutHandler(e) { + $(this).removeClass('fileover'); + blockEventPropagation(e); +} + +function setupFileDrop() { + if (window.File && window.FileList && window.ProgressEvent && window.FormData) { + + $.event.fixHooks.drop = { props: [ 'dataTransfer' ] }; + + $('form div.box').has('input:file').each(function() { + $(this).on({ + dragover: dragOverHandler, + dragleave: dragOutHandler, + drop: handleFileDropEvent + }); + }); + } +} + +$(document).ready(setupFileDrop); diff --git a/public/javascripts/ckeditor/contents.css b/public/javascripts/ckeditor/contents.css index 81e76d564..92a1b7ba1 100644 --- a/public/javascripts/ckeditor/contents.css +++ b/public/javascripts/ckeditor/contents.css @@ -22,6 +22,7 @@ body { font-size: 13px; line-height: 1.6em; + word-wrap: break-word; } blockquote diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index aed928ebe..8f0ed1ca7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1356,7 +1356,7 @@ tr.message.locked td.subject { background: url(../images/locked.png) no-repeat 0 tr.message.sticky td.subject { background: url(../images/bullet_go.png) no-repeat 0 1px; font-weight: bold; } tr.version.closed, tr.version.closed a { color: #999; } -tr.version td.name { padding-left: 20px;word-break: break-all; } +tr.version td.name { padding-left: 20px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap; } tr.version td.description{word-break: break-all} tr.version.shared td.name { background: url(../images/link.png) no-repeat 0% 70%; } tr.version td.date, tr.version td.status, tr.version td.sharing { text-align: center; white-space:nowrap; } @@ -2834,4 +2834,8 @@ div.repos_explain{ .list .tableth{background-color:#EEEEEE; padding: 4px; white-space:pre;} .projects-index{min-height: 350px} -.school-index{min-height: 400px} \ No newline at end of file +.school-index{min-height: 400px} +#membership_project_id option +{ + width: 190px; +} \ No newline at end of file