diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index ac25fbe9d..770c36a58 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -19,7 +19,7 @@ class CommentsController < ApplicationController default_search_scope :news include ApplicationHelper model_object News - before_filter :find_model_object + before_filter :find_model_object before_filter :find_project_from_association before_filter :authorize @@ -76,6 +76,6 @@ class CommentsController < ApplicationController @comment = nil @news end - - + + end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 9f4b5f171..c73e6bc93 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -66,14 +66,14 @@ class IssuesController < ApplicationController if @query.valid? case params[:format] - when 'csv', 'pdf' - @limit = 10#Setting.issues_export_limit.to_i - when 'atom' - @limit = 10#Setting.feeds_limit.to_i - when 'xml', 'json' - @offset, @limit = api_offset_and_limit({:limit => 10}) - else - @limit = 10#per_page_option + when 'csv', 'pdf' + @limit = 10#Setting.issues_export_limit.to_i + when 'atom' + @limit = 10#Setting.feeds_limit.to_i + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 10}) + else + @limit = 10#per_page_option end @assign_to_id = params[:assigned_to_id] @author_id = params[:author_id] @@ -84,9 +84,9 @@ class IssuesController < ApplicationController @issue_pages = Paginator.new @issue_count, @limit, params['page'] @offset ||= @issue_pages.offset @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], - :order => sort_clause, - :offset => @offset, - :limit => @limit) + :order => sort_clause, + :offset => @offset, + :limit => @limit) @issue_count_by_group = @query.issue_count_by_group respond_to do |format| format.js @@ -143,16 +143,16 @@ class IssuesController < ApplicationController @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq respond_to do |format|`` - format.html { - retrieve_previous_and_next_issue_ids - render :template => 'issues/show', :layout => @project_base_tag#by young - } - format.api - format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } - format.pdf { - pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") - } + format.html { + retrieve_previous_and_next_issue_ids + render :template => 'issues/show', :layout => @project_base_tag#by young + } + format.api + format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } + format.pdf { + pdf = issue_to_pdf(@issue, :journals => @journals) + send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") + } end end @@ -322,8 +322,8 @@ class IssuesController < ApplicationController issue.reload if @copy issue = issue.copy({}, - :attachments => params[:copy_attachments].present?, - :subtasks => params[:copy_subtasks].present? + :attachments => params[:copy_attachments].present?, + :subtasks => params[:copy_subtasks].present? ) end journal = issue.init_journal(User.current, params[:notes]) @@ -353,21 +353,21 @@ class IssuesController < ApplicationController @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f if @hours > 0 case params[:todo] - when 'destroy' - # nothing to do - when 'nullify' - TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) - when 'reassign' - reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) - if reassign_to.nil? - flash.now[:error] = l(:error_issue_not_found_in_project) - return + when 'destroy' + # nothing to do + when 'nullify' + TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) + when 'reassign' + reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) + if reassign_to.nil? + flash.now[:error] = l(:error_issue_not_found_in_project) + return + else + TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) + end else - TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) - end - else - # display the destroy form if it's a user request - return unless api_request? + # display the destroy form if it's a user request + return unless api_request? end end @issues.each do |issue| @@ -435,14 +435,14 @@ class IssuesController < ApplicationController issue_attributes = params[:issue] if issue_attributes && params[:conflict_resolution] case params[:conflict_resolution] - when 'overwrite' - issue_attributes = issue_attributes.dup - issue_attributes.delete(:lock_version) - when 'add_notes' - issue_attributes = issue_attributes.slice(:notes) - when 'cancel' - redirect_to issue_url(@issue) - return false + when 'overwrite' + issue_attributes = issue_attributes.dup + issue_attributes.delete(:lock_version) + when 'add_notes' + issue_attributes = issue_attributes.slice(:notes) + when 'cancel' + redirect_to issue_url(@issue) + return false end end @issue.safe_attributes = issue_attributes diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 37214621f..ea4dc25a3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -41,12 +41,12 @@ class UsersController < ApplicationController before_filter :can_show_course, :only => [:user_courses,:user_homeworks] #edit has been deleted by huang, 2013-9-23 before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, - :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, - :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, - :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, - :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, - :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, - :user_import_homeworks,:user_search_homeworks,:user_import_resource] + :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, + :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, + :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, + :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, + :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, + :user_import_homeworks,:user_search_homeworks,:user_import_resource] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -223,7 +223,7 @@ class UsersController < ApplicationController end # end - ##added by fq +##added by fq def watch_bids # cond = 'bids.reward_type <> 1' # @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang @@ -286,7 +286,7 @@ class UsersController < ApplicationController unless User.current.admin? if !@user.active? || (@user != User.current && @memberships.empty? && events.empty?) render_404 - return + return end end @@ -443,18 +443,18 @@ class UsersController < ApplicationController return end if(params[:type].blank? || params[:type] == "1") #全部 - user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ - "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") + user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") elsif params[:type] == "2" #课程资源 - user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) ").order("created_on desc") + user_course_ids = User.current.courses.map { |c| c.id} + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) ").order("created_on desc") elsif params[:type] == "3" #项目资源 - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") elsif params[:type] == "4" #附件 - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") elsif params[:type] == "5" #用户资源 - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc") end @type = params[:type] @limit = 7 @@ -474,18 +474,18 @@ class UsersController < ApplicationController def user_ref_resource_search search = params[:search].to_s.strip.downcase if(params[:type].blank? || params[:type] == "1") #全部 - user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 - @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ - " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc") + user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 + @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc") elsif params[:type] == "2" #课程资源 - user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc") + user_course_ids = User.current.courses.map { |c| c.id} + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc") elsif params[:type] == "3" #项目资源 - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc") elsif params[:type] == "4" #附件 - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") elsif params[:type] == "5" #用户资源 - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") end @type = params[:type] @limit = 7 @@ -503,20 +503,20 @@ class UsersController < ApplicationController #将资源批量引入 def import_resources_to_homework @attachments = [] - unless params[:checkbox1].nil? || params[:checkbox1].blank? - params[:checkbox1].each do |id| - atta = Attachment.find(id) - att_copy = atta.copy - att_copy.container_id = nil - att_copy.container_type = nil - att_copy.copy_from = atta.id - att_copy.save - @attachments << att_copy - end - end - respond_to do |format| - format.js + unless params[:checkbox1].nil? || params[:checkbox1].blank? + params[:checkbox1].each do |id| + atta = Attachment.find(id) + att_copy = atta.copy + att_copy.container_id = nil + att_copy.container_type = nil + att_copy.copy_from = atta.id + att_copy.save + @attachments << att_copy end + end + respond_to do |format| + format.js + end end @@ -566,16 +566,16 @@ class UsersController < ApplicationController sort_update %w(login firstname lastname mail admin created_on last_login_on) case params[:format] - when 'xml', 'json' - @offset, @limit = api_offset_and_limit({:limit => 15}) - else - @limit = 15 + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 15}) + else + @limit = 15 end # retrieve all users # 先内连一下statuses 保证排序之后数量一致 scope = User.visible. - joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id") + joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id") # unknow scope = scope.in_group(params[:group_id]) if params[:group_id].present? @@ -586,29 +586,29 @@ class UsersController < ApplicationController # users classify case params[:user_sort_type] - when '0' - # 创建时间排序 - @s_type = 0 - @users = scope.reorder('users.created_on DESC') - when '1' - # 活跃度排序, 就是所谓的得分情况 - @s_type = 1 - @users = scope. - joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). - reorder('option_numbers.total_score DESC') - when '2' - # 粉丝数排序 - @s_type = 2 - @users = scope. - #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id"). - reorder('user_statuses.watchers_count DESC') + when '0' + # 创建时间排序 + @s_type = 0 + @users = scope.reorder('users.created_on DESC') + when '1' + # 活跃度排序, 就是所谓的得分情况 + @s_type = 1 + @users = scope. + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') + when '2' + # 粉丝数排序 + @s_type = 2 + @users = scope. + #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id"). + reorder('user_statuses.watchers_count DESC') - else - # 默认活跃度排序 - @s_type = 1 - @users = scope. - joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). - reorder('option_numbers.total_score DESC') + else + # 默认活跃度排序 + @s_type = 1 + @users = scope. + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') end # limit and offset @@ -628,20 +628,20 @@ class UsersController < ApplicationController sort_init 'login', 'asc' sort_update %w(login firstname lastname mail admin created_on last_login_on) (redirect_to user_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? - case params[:format] + case params[:format] when 'xml', 'json' @offset, @limit = api_offset_and_limit({:limit => 15}) else @limit = 15#per_page_option - end - # - #@status = params[:status] || 1 - #has = { - # "show_changesets" => true - #} - # scope = User.logged.status(@status) - # @search_by = params[:search_by] ? params[:search_by][:id] : 0 - # scope = scope.like(params[:name],@search_by) if params[:name].present? + end + # + #@status = params[:status] || 1 + #has = { + # "show_changesets" => true + #} + # scope = User.logged.status(@status) + # @search_by = params[:search_by] ? params[:search_by][:id] : 0 + # scope = scope.like(params[:name],@search_by) if params[:name].present? @search_by = params[:search_by] ? params[:search_by] : 0 us = UsersService.new @@ -674,13 +674,13 @@ class UsersController < ApplicationController def user_courses4show @page = params[:page].to_i + 1 @courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) - end + end #显示更多用户项目 def user_projects4show @page = params[:page].to_i + 1 @projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5) - end + end def user_course_activities lastid = nil @@ -778,7 +778,7 @@ class UsersController < ApplicationController @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10) else @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) - end + end else @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) end @@ -796,124 +796,124 @@ class UsersController < ApplicationController # Author lizanle # Description type 1 :所有动态包括我关注的人 type 2:我的动态 type 3:关于我的回复 case params[:type] - when "1" - if @user == User.current - activity = Activity.where('user_id = ?', User.current.id).order('id desc') - @activity_count = activity.count - @activity_pages = Paginator.new @activity_count, pre_count, params['page'] - @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all - @state = 1 - end - when "2" - message = [] - if @user == User.current - message = JournalsForMessage.reference_message(@user.id) - message += Journal.reference_message(@user.id) - end - @activity_count = message.size - @info_pages = Paginator.new @activity_count, pre_count, params['page'] - messages = message.sort {|x,y| y.created_on <=> x.created_on } - @message = messages[@info_pages.offset, @info_pages.per_page] - @state = 2 + when "1" + if @user == User.current + activity = Activity.where('user_id = ?', User.current.id).order('id desc') + @activity_count = activity.count + @activity_pages = Paginator.new @activity_count, pre_count, params['page'] + @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all + @state = 1 + end + when "2" + message = [] + if @user == User.current + message = JournalsForMessage.reference_message(@user.id) + message += Journal.reference_message(@user.id) + end + @activity_count = message.size + @info_pages = Paginator.new @activity_count, pre_count, params['page'] + messages = message.sort {|x,y| y.created_on <=> x.created_on } + @message = messages[@info_pages.offset, @info_pages.per_page] + @state = 2 else - # Time 2015-02-04 10:50:49 - # Author lizanle - # Description 所有动态 - where_condition = nil; - # where_condition = "act_type <> 'JournalsForMessage'" - user_ids = [] - if @user == User.current - watcher = User.watched_by(@user) - watcher.push(User.current) - user_ids = watcher.map{|x| x.id} - else - user_ids << @user.id - end - activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc') - - permission = !User.current.admin? - if permission - #Issue - act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id} - project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) + # Time 2015-02-04 10:50:49 + # Author lizanle + # Description 所有动态 + where_condition = nil; + # where_condition = "act_type <> 'JournalsForMessage'" + user_ids = [] + if @user == User.current + watcher = User.watched_by(@user) + watcher.push(User.current) + user_ids = watcher.map{|x| x.id} + else + user_ids << @user.id end - ids = [] - ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id} + activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc') - #HomeworkCommon - act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id} - course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} - c_ids = [] - Course.where(id: course_ids).each do |x| - c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + permission = !User.current.admin? + if permission + #Issue + act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id} + project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids = [] + ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id} + + #HomeworkCommon + act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id} + course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: course_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id} + + #Journal + act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id} + project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id} + + #News + act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id} + project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id} + + project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: project_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id} + + #Message + act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id} + board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id} + project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id} + + project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: project_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id} + + logger.debug "filter ids #{ids}" + + activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty? end - ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id} - #Journal - act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id} - project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) - end - ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id} + # activity = activity.reject { |e| + # e.act.nil? || + # (!User.current.admin? && !e.act.nil? + # (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) || + # (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) || + # (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) || + # (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) || + # (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))) + # } + # - #News - act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id} - project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) - end - ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id} - - project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} - c_ids = [] - Course.where(id: project_ids).each do |x| - c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) - end - ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id} - - #Message - act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id} - board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id} - project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) - end - ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id} - - project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id} - c_ids = [] - Course.where(id: project_ids).each do |x| - c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) - end - ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id} - - logger.debug "filter ids #{ids}" - - activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty? - end - - # activity = activity.reject { |e| - # e.act.nil? || - # (!User.current.admin? && !e.act.nil? - # (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) || - # (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) || - # (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) || - # (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) || - # (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))) - # } - # - - @activity_count = activity.count - @activity_pages = Paginator.new @activity_count, pre_count, params['page'] - @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) - @state = 0 + @activity_count = activity.count + @activity_pages = Paginator.new @activity_count, pre_count, params['page'] + @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) + @state = 0 end if params[:user].present? @@ -941,7 +941,7 @@ class UsersController < ApplicationController if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) # redirect_to home_path render_404 - return + return end end @@ -973,7 +973,7 @@ class UsersController < ApplicationController unless User.current.admin? if !@user.active? render_404 - return + return end end @@ -1031,7 +1031,7 @@ class UsersController < ApplicationController unless @user.id.nil? #后台注册的用户默认权限为男性开发员 ue = UserExtensions.create(:identity => 3, - :gender => 0, + :gender => 0, :user_id => @user.id) ue.save end @@ -1101,7 +1101,7 @@ class UsersController < ApplicationController @user = User.find(params[:id]) #@user.save_attachments(params[:attachments],User.current) # Container_type为Principal - Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) + Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) if(params[:type].blank?|| params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 @@ -1157,10 +1157,10 @@ class UsersController < ApplicationController # 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源 def user_resource_delete if params[:resource_id].present? - Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) + Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) elsif params[:checkbox1].present? - params[:checkbox1].each do |id| - Attachment.where("author_id = #{User.current.id}").delete(id) + params[:checkbox1].each do |id| + Attachment.where("author_id = #{User.current.id}").delete(id) end end @@ -1211,17 +1211,17 @@ class UsersController < ApplicationController @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] @attachments = paginateHelper @attachments,25 - respond_to do |format| - format.js - end + respond_to do |format| + format.js + end end #根据id或者名称搜索教师或者助教为当前用户的课程 def search_user_course @user = User.current if !params[:search].nil? - @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'") - .select { |course| @user.allowed_to?(:as_teacher,course)} + @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'") + .select { |course| @user.allowed_to?(:as_teacher,course)} else @course = @user.courses .select { |course| @user.allowed_to?(:as_teacher,course)} @@ -1253,28 +1253,28 @@ class UsersController < ApplicationController # 将资源发送到对应的课程,分为发送单个,或者批量发送 def add_exist_file_to_course @flag = true - if params[:send_id].present? + if params[:send_id].present? send_id = params[:send_id] ori = Attachment.find_by_id(send_id) course_ids = params[:course_ids] if course_ids.nil? @flag = false end - unless course_ids.nil? - course_ids.each do |id| - next if ori.blank? - attach_copied_obj = ori.copy - attach_copied_obj.tag_list.add(ori.tag_list) # tag关联 - attach_copied_obj.container = Course.find(id) - attach_copied_obj.created_on = Time.now - attach_copied_obj.author_id = User.current.id - if attach_copied_obj.attachtype == nil - attach_copied_obj.attachtype = 4 - end - attach_copied_obj.save - @save_message = attach_copied_obj.errors.full_messages - end + unless course_ids.nil? + course_ids.each do |id| + next if ori.blank? + attach_copied_obj = ori.copy + attach_copied_obj.tag_list.add(ori.tag_list) # tag关联 + attach_copied_obj.container = Course.find(id) + attach_copied_obj.created_on = Time.now + attach_copied_obj.author_id = User.current.id + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end + attach_copied_obj.save + @save_message = attach_copied_obj.errors.full_messages end + end elsif params[:send_ids].present? send_ids = params[:send_ids].split(" ") course_ids = params[:course_ids] @@ -1301,7 +1301,7 @@ class UsersController < ApplicationController end end else - @flag = false + @flag = false end user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @@ -1390,15 +1390,15 @@ class UsersController < ApplicationController # 资源预览 def resource_preview - preview_id = params[:resource_id] - @file = Attachment.find(preview_id) - @preview_able = false; - if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)} - @preview_able = true; - end - respond_to do |format| - format.js - end + preview_id = params[:resource_id] + @file = Attachment.find(preview_id) + @preview_able = false; + if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)} + @preview_able = true; + end + respond_to do |format| + format.js + end end # 重命名资源 @@ -1438,7 +1438,7 @@ class UsersController < ApplicationController def destroy_membership @membership = Member.find(params[:membership_id]) if @membership.deletable? - @membership.destroy + @membership.destroy end respond_to do |format| format.html { redirect_to edit_user_url(@user, :tab => 'memberships') } @@ -1453,31 +1453,31 @@ class UsersController < ApplicationController @obj_flag = params[:tag_for_save][:object_flag] case @obj_flag - when '1' then - @obj = User.find_by_id(@obj_id) - when '2' then - @obj = Project.find_by_id(@obj_id) - when '3' then - @obj = Issue.find_by_id(@obj_id) - when '4' then - # @obj = Bid.find_by_id(@obj_id) - when '5' then - @obj = Forum.find_by_id(@obj_id) - when '6' - @obj = Attachment.find_by_id(@obj_id) - when '7' then - @obj = Contest.find_by_id(@obj_id) - when '8' - @obj = OpenSourceProject.find_by_id(@obj_id) - when '9' - @obj = Course.find_by_id(@obj_id) - else - @obj = nil + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + # @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + when '9' + @obj = Course.find_by_id(@obj_id) + else + @obj = nil end unless @obj.nil? @obj.tag_list.add(@tags.split(",")) else - return + return end if @obj.save logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}" @@ -1568,9 +1568,9 @@ class UsersController < ApplicationController def update_extensions(user_extensions) user_extensions = params[:user_extensions] unless user_extensions.nil? - user_extensions = UserExtensions.find_by_id(user_extensions.user_id) + user_extensions = UserExtensions.find_by_id(user_extensions.user_id) - # user_extensions. + # user_extensions. end end @@ -1661,9 +1661,9 @@ class UsersController < ApplicationController else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + - " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ - " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + - " and (filename like '%#{search}%') ").order("created_on desc") + " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ + " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + + " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i @@ -1672,7 +1672,7 @@ class UsersController < ApplicationController else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ - "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "3" #项目资源 diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index e7ab001da..b9f762f69 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -71,7 +71,7 @@ module UsersHelper def user_settings_tabs tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general}, {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural} - ] + ] if Group.all.any? tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural} end @@ -83,7 +83,7 @@ module UsersHelper def get_users_by_tag(tag_name) User.tagged_with(tag_name).order('updated_on desc') end - + # added by fq # - + # TODO: 待删 # def show_activity(state) # content = ''.html_safe @@ -114,19 +114,19 @@ module UsersHelper # end # content_tag('div', content, :class => "pagination") # end - + #TODO: 待删 def watch_projects(state) content = ''.html_safe case state - when 0 - s = content_tag('span', l(:label_project_take), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) - when 1 - s = content_tag('span', l(:label_has_watched_project), :class => "current-page") - content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) - content << content_tag('li', s, :class => "current-page") + when 0 + s = content_tag('span', l(:label_project_take), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) + when 1 + s = content_tag('span', l(:label_has_watched_project), :class => "current-page") + content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) + content << content_tag('li', s, :class => "current-page") end content_tag('div', content, :class => "pagination") end @@ -134,59 +134,59 @@ module UsersHelper def user_course(state) content = ''.html_safe if @user != User.current - if @user.user_extensions.identity == 0 + if @user.user_extensions.identity == 0 case state - when 0 - s = content_tag('span', '他执教的课程', :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '他发布的作业', :class => "current-page") - content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', '他执教的课程', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '他发布的作业', :class => "current-page") + content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end - else + else case state - when 0 - s = content_tag('span', '他的课程', :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '他的作业', :class => "current-page") - content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', '他的课程', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '他的作业', :class => "current-page") + content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end end else - if @user.user_extensions.identity == 0 + if @user.user_extensions.identity == 0 case state - when 0 - s = content_tag('span', l(:label_teaching_course), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', l(:label_release_homework), :class => "current-page") - content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', l(:label_teaching_course), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', l(:label_release_homework), :class => "current-page") + content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end - else + else case state - when 0 - s = content_tag('span', l(:label_my_course), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '我的作业', :class => "current-page") - content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', l(:label_my_course), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '我的作业', :class => "current-page") + content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end end end @@ -196,42 +196,42 @@ module UsersHelper def sort_user(state, project_type) content = ''.html_safe case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") ) - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") ) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") ) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") ) + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") ) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") ) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) end content = content_tag('ul', content) content_tag('div', content, :class => "tabs") - end - + end + def sort_user_enterprise(state, project_type) content = ''.html_safe case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) end content = content_tag('ul', content) content_tag('div', content, :class => "tabs_enterprise") - end + end def gender_avatar_uri user img_uri = '/images/sidebar/female.png' @@ -256,7 +256,7 @@ module UsersHelper # people_ids += (members_to_user_ids(tmp)) unless tmp.nil? # end # people_ids.include?(login_user.id) or (login_user == user) or login_user.admin? - + false end @@ -290,7 +290,7 @@ module UsersHelper membership.collect { |e| memberships.push(e) } - ## 判断课程是否过期 [需封装] + ## 判断课程是否过期 [需封装] memberships_doing = [] memberships_done = [] memberships.map { |e| @@ -546,7 +546,7 @@ module UsersHelper type = [] user.courses.select{|c| user.allowed_to?(:as_teacher,c)}.each do |course| option = [] - option << course.name + option << course.name+"("+course.time.to_s+course.term+")" option << course.id type << option end diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 3513c5c86..ae8fd774e 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -101,9 +101,9 @@ 课程 <% if is_current_user%> <% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> - <%=link_to "", new_course_path, :class => "homepageMenuSetting fr"%> + <%=link_to "", new_course_path, :class => "homepageMenuSetting fr", :title => "新建课程"%> <% else%> - <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:remote => true%> + <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:remote => true, :title => "加入课程"%> <% end%> <% end%> @@ -117,7 +117,7 @@ 项目 <% if is_current_user%> - <%=link_to "", new_project_path, :class => "homepageMenuSetting fr"%> + <%=link_to "", new_project_path, :class => "homepageMenuSetting fr", :title => "新建项目"%> <% end%>
diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index f27d6cae5..85e958253 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -1,108 +1,108 @@ -
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> -
-
-
- <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> - TO - <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course), :class => "newsBlue ml15 mr5"%> -
-
- <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey"%> - <% end %> -
-
- 发帖时间:<%= format_date(activity.created_on) %> -
- - -
帖子描述: - <% if activity.parent_id.nil? %> - <%= activity.content.to_s.html_safe%> - <% else %> - <%= activity.parent.content.to_s.html_safe%> - <% end %> -
- -
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course), :class => "newsBlue ml15 mr5"%> +
+
+ <% if activity.parent_id.nil? %> + <%= link_to activity.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey"%> + <% end %> +
+
+ 发帖时间:<%= format_date(activity.created_on) %>
-
-
- <% count=0 %> -
回复( - <% if activity.parent_id.nil? %> - <% count=activity.replies_count%> - <%=count %> - <% else %> - <% count=activity.parent.replies_count%> - <%=count %> - <% end %> - )
-
<%#=format_date(activity.updated_on)%>
- <%if count>2 %> - - <% end %> -
-
-
- <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> - - - -

-
- 取消 - 发送 - <% end%> + +
帖子描述: + <% if activity.parent_id.nil? %> + <%= activity.content.to_s.html_safe%> + <% else %> + <%= activity.parent.content.to_s.html_safe%> + <% end %> +
+ +
+
+
+
+
+ <% count=0 %> +
回复( + <% if activity.parent_id.nil? %> + <% count=activity.replies_count%> + <%=count %> + <% else %> + <% count=activity.parent.replies_count%> + <%=count %> + <% end %> + )
+
<%#=format_date(activity.updated_on)%>
+ <%if count>2 %> + -
-
+ <% end %> +
- <% activity= activity.parent_id.nil? ? activity:activity.parent%> - <% replies_all_i = 0 %> - <% unless activity.children.empty? %> -
-
    - <% activity.children.reorder("created_on desc").each do |reply|%> - <% replies_all_i=replies_all_i+1 %> -
  • -
    - <%= link_to image_tag(url_to_avatar(reply.author), :width => "45", :height => "45"), user_path(reply.author_id), :alt => "用户头像" %> -
    -
    -
    - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> - <% end %> - <%= format_date(reply.created_on) %> - <%#= link_to( +
    +
    + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + + +

    +
    + 取消 + 发送 + <% end%> +
    +
    +
    + + <% activity= activity.parent_id.nil? ? activity:activity.parent%> + <% replies_all_i = 0 %> + <% unless activity.children.empty? %> +
    +
      + <% activity.children.reorder("created_on desc").each do |reply|%> + <% replies_all_i=replies_all_i+1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(reply.author), :width => "45", :height => "45"), user_path(reply.author_id), :alt => "用户头像" %> +
      +
      +
      + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_date(reply.created_on) %> + <%#= link_to( l(:button_delete), {:controller => 'messages', :action => 'destroy', :id => reply.id, :board_id => reply.board_id, :is_board => 'false'}, :method => :post, @@ -110,15 +110,15 @@ :title => l(:button_delete), :class => 'replyGrey fr ml10' ) if reply.course_destroyable_by?(User.current) %> - -
      -
      <%= reply.content.html_safe %>
      -
      -
      -
    • - <% end %> -
    -
    - <% end %> -
    -
    + +
+
<%= reply.content.html_safe %>
+
+
+ + <% end %> + +
+ <% end %> +
+
diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index 442ad5e59..669c67ded 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -84,6 +84,6 @@ <% end %>
- <% end %> + <% end %>
\ No newline at end of file diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index f23bdb74c..97c647111 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -11,7 +11,7 @@ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO <%= link_to activity.project.name.to_s+" | 项目缺陷", project_issues_path(activity.project), :class => "newsBlue ml15"%> - +
<%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> <%= get_issue_priority(activity.priority_id)[1] %> @@ -19,11 +19,11 @@
指派给   <% unless activity.assigned_to_id.nil? %> - <% if activity.try(:assigned_to).try(:realname) == ' ' %> - <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> - <% end %> + <% if activity.try(:assigned_to).try(:realname) == ' ' %> + <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% end %> <% end %>
时间:<%=format_date(activity.created_on) %>
@@ -37,21 +37,21 @@
<% if activity.attachments.any? %> <% activity.attachments.each do |attachment| %> -
+
<%= link_to_short_attachment attachment,:length=> 58, :class => 'homepagePostFileAtt newsBlue', :download => true -%> - <% if attachment.is_text? %> - <%= link_to image_tag('magnifier.png'), - :controller => 'attachments', - :action => 'show', - :id => attachment, - :filename => attachment.filename %> - <% end %> - ( + <% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', + :action => 'show', + :id => attachment, + :filename => attachment.filename %> + <% end %> + ( <%= number_to_human_size attachment.filesize %>) -
+
<% end %> <% end %>
@@ -110,7 +110,7 @@
<% if reply.try(:user).try(:realname) == ' ' %> <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> - <% else %> + <% else %> <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_date(reply.created_on) %> diff --git a/app/views/users/_resource_share_for_project_popup.html.erb b/app/views/users/_resource_share_for_project_popup.html.erb index e5d1732e4..482569297 100644 --- a/app/views/users/_resource_share_for_project_popup.html.erb +++ b/app/views/users/_resource_share_for_project_popup.html.erb @@ -34,7 +34,7 @@
  • -
  • <%= truncate( project.name,:length=>18)%>
  • +
  • <%= project.name%>
  • <% end %>
    diff --git a/app/views/users/_resource_share_popup.html.erb b/app/views/users/_resource_share_popup.html.erb index 2fc515b4a..219402cbf 100644 --- a/app/views/users/_resource_share_popup.html.erb +++ b/app/views/users/_resource_share_popup.html.erb @@ -34,7 +34,7 @@
  • -
  • <%= truncate(course.name,:length=>18)%>
  • +
  • <%= course.name%>
  • <% end %>
    diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index ab86fc21d..ab49fd9d6 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -1,25 +1,25 @@ <% if attachments.nil? || attachments.empty? %> - - - + + + <% else %> <% attachments.each do |attach| %> - - <% end %> + + <% end %> <% end %> diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 7a9e55205..c6c17edf9 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -74,7 +74,11 @@
    - + --> diff --git a/config/routes.rb b/config/routes.rb index 3a99ed027..8454a1c47 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -172,7 +172,7 @@ RedmineApp::Application.routes.draw do resources :contests, only: [:index] do resources :contestnotifications do # get 'preview', on: :collection - resources :notificationcomments + resources :notificationcomments end collection do @@ -233,7 +233,7 @@ RedmineApp::Application.routes.draw do end end end - + resources :shares @@ -373,7 +373,7 @@ RedmineApp::Application.routes.draw do get 'user_resource_type' get 'user_ref_resource_search' post 'import_resources_to_homework' - # end + # end end end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" @@ -487,7 +487,7 @@ RedmineApp::Application.routes.draw do collection do match "getattachtype" , :via => [:get, :post] match "search_project",:via => [:post,:get] - #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] + #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] end end @@ -517,7 +517,7 @@ RedmineApp::Application.routes.draw do resources :repositories, :except => [:index, :show] do member do get 'newrepo', :via => [:get, :post] - # get 'create', :via=>[:get, :post] + # get 'create', :via=>[:get, :post] end end match 'wiki/index', :via => :get @@ -607,8 +607,8 @@ RedmineApp::Application.routes.draw do :controller => 'repositories', :format => false, :constraints => { - :action => /(browse|show|entry|raw|annotate|diff)/, - :rev => /[a-z0-9\.\-_]+/ + :action => /(browse|show|entry|raw|annotate|diff)/, + :rev => /[a-z0-9\.\-_]+/ } get 'projects/:id/repository/statistics', :to => 'repositories#stats' @@ -625,8 +625,8 @@ RedmineApp::Application.routes.draw do :controller => 'repositories', :format => false, :constraints => { - :action => /(browse|show|entry|raw|annotate|diff)/, - :rev => /[a-z0-9\.\-_]+/ + :action => /(browse|show|entry|raw|annotate|diff)/, + :rev => /[a-z0-9\.\-_]+/ } get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', :controller => 'repositories', @@ -729,7 +729,7 @@ RedmineApp::Application.routes.draw do get 'test_connection', :as => 'try_connection' end collection do - get 'autocomplete_for_new_user' + get 'autocomplete_for_new_user' end end @@ -791,7 +791,7 @@ RedmineApp::Application.routes.draw do collection do match 'chang_read_flag', :via => :get end - end + end end # end of resources :courses match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback' diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 8639d7834..4c2c3584c 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -675,7 +675,7 @@ a.referenceTypeBlock {color:#888888; display:inline-block; padding:0px 20px;} /*底部*/ #Footer{background-color:#ffffff; padding-bottom:15px; color:#666666;} /*margin-bottom:10px;*/ .footerAboutContainer {width:auto; border-bottom:1px solid #efefef;} -.footerAbout{ width:455px; margin:0 auto;height:35px; line-height:35px; padding-top: 10px; } +.footerAbout{ width:365px; margin:0 auto;height:35px; line-height:35px; padding-top: 10px; } .languageBox {width:55px; height:20px; margin-left:5px; outline:none; color:#666666; border:1px solid #d9d9d9;} .departments{ width:890px; margin:5px auto 0 auto;height:30px;line-height:30px;} .copyright{ width:375px; margin:0 auto;height:20px;line-height:20px;}