From f3f590a8341dd97e3b95eee2bd5973744a933072 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 10:27:21 +0800 Subject: [PATCH 01/24] =?UTF-8?q?=20#=20=E8=BF=99=E5=86=99=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E5=8F=91=E7=8E=B0=E6=B2=A1=E6=9C=89=E7=94=A8=E8=80=8C?= =?UTF-8?q?=E4=B8=94=E6=8B=96=E6=85=A2=E9=80=9F=E5=BA=A6=20=20=20=20=20#@t?= =?UTF-8?q?eachers=3D=20searchTeacherAndAssistant(@course)=20=20=20=20=20#?= =?UTF-8?q?@canShowRealName=20=3D=20isCourseTeacher(User.current.id,@cours?= =?UTF-8?q?e)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e81b57ad7..7653be94d 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -828,6 +828,7 @@ class CoursesController < ApplicationController end def show + # try to redirect to the requested menu item if params[:jump] && redirect_to_course_menu_item(@course, params[:jump]) return @@ -866,6 +867,7 @@ class CoursesController < ApplicationController @activity.scope_select {|t| has["show_#{t}"]} # modify by nwb # 添加私密性判断 + if User.current.member_of_course?(@course)|| User.current.admin? events = @activity.events(@days, @course.created_at) else @@ -890,14 +892,13 @@ class CoursesController < ApplicationController @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} # documents @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' - # - @teachers= searchTeacherAndAssistant(@course) - @canShowRealName = isCourseTeacher(User.current.id,@course) + # 这写变量发现没有用而且拖慢速度 + #@teachers= searchTeacherAndAssistant(@course) + #@canShowRealName = isCourseTeacher(User.current.id,@course) if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id))) @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id) end - respond_to do |format| format.html{render :layout => 'base_courses'} format.api From 078538481341394ce36096fcef1c4b812d62b03f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 10:28:31 +0800 Subject: [PATCH 02/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug=EF=BC=8C=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=8A=A8=E6=80=81=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/acts_as_activity_provider.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb index f4712fa3e..35d168732 100644 --- a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb +++ b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb @@ -98,20 +98,13 @@ module Redmine # Author lizanle # Description 删除 unless scope.all,因为这个执行查询,并且没有加入时间限制,与下边 scope.all(provider_options[:find_options].dup)重复 if options[:course] - if provider_options[:timestamp].include? "updated_on" - to = scope.scoped(:order => "#{provider_options[:timestamp]} desc").all(provider_options[:find_options].dup).first.updated_on - else - to = scope.scoped(:order => "#{provider_options[:timestamp]} desc").all(provider_options[:find_options].dup).first.created_on - end - from = (to - days.days) > created_time ? (to - days.days) : created_time.to_date + scope.all(provider_options[:find_options].dup) else - #from = to - Setting.activity_days_default.to_i - end - - if from && to - scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to]) + if from && to + scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to]) + scope.all(provider_options[:find_options].dup) + end end - scope.all(provider_options[:find_options].dup) end # 为了首页获取数据基本复制了上面的方法,改变了用户查看权限,增加了对讨论区的识别。 From a265556cfe38d3480df89a20a5886cd70a63004a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 11:00:18 +0800 Subject: [PATCH 03/24] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=97=B6=E5=A2=9E=E5=8A=A0js=E9=AA=8C=E8=AF=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_memos.html.erb | 42 ++++++++++++++--- app/views/projects/search.html.erb | 67 +++++++++++++++++++++------ 2 files changed, 88 insertions(+), 21 deletions(-) diff --git a/app/views/layouts/base_memos.html.erb b/app/views/layouts/base_memos.html.erb index 14944792d..a8b48804b 100644 --- a/app/views/layouts/base_memos.html.erb +++ b/app/views/layouts/base_memos.html.erb @@ -36,13 +36,41 @@ 软件项目托管社区 <%= l(:label_user_location) %> : - + diff --git a/app/views/projects/search.html.erb b/app/views/projects/search.html.erb index 7a91082ca..4af39e59a 100644 --- a/app/views/projects/search.html.erb +++ b/app/views/projects/search.html.erb @@ -4,7 +4,7 @@ <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> <% end %>
- <%= form_tag(projects_search_path, :method => :get) do %> + <%= form_tag(projects_search_path, :method => :get, :id => "project_search_form") do %> <% if params[:project_type] == "1" %> @@ -33,24 +33,63 @@ <% else %>
- - + + - - - + +
<%= l(:label_project_deposit) %><%= l(:label_user_location) %> : + <%= l(:label_project_deposit) %> + + <%= l(:label_user_location) %> : + - <% if User.current.logged? %> - <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> - <% end %> + <% if User.current.logged? %> + <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> + <% end %> - + + +
<%= link_to request.host()+"/projects", :controller => 'projects', :action => 'index', :project_type => 0 %> <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_project_deposit), :controller => 'projects', :action => 'index', :project_type => 0 %> + + <%= link_to request.host()+"/projects", :controller => 'projects', :action => 'index', :project_type => 0 %> + + + <%=link_to l(:field_homepage), home_path %> > + <%=link_to l(:label_project_deposit), :controller => 'projects', :action => 'index', :project_type => 0 %> +
<% end %> From 852bb940a2d0310d461c0ec6b0d32716d986357a Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 11:31:41 +0800 Subject: [PATCH 04/24] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=8E=89=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=B8=AD=E6=97=A5=E5=BF=97=E5=88=86=E6=9E=90=E7=9A=84?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/system_log_helper.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/helpers/system_log_helper.rb b/app/helpers/system_log_helper.rb index 918d6a608..12e02ca8f 100644 --- a/app/helpers/system_log_helper.rb +++ b/app/helpers/system_log_helper.rb @@ -25,11 +25,17 @@ module SystemLogHelper logs = Kaminari.paginate_array(logs).page(page).per(per).collect! { |log| parse(log) } #将分页后的记录的搜索结果添加样式,样式中的\0是给给r占位置的。 logs.collect! do |log| - keywords.each { |r| log.gsub!(r, '\0') } + keywords.each { |r| log.gsub!(r, '\0') && log = "" if log =~ Regexp.new("SystemLogController",'i') } log end + else logs = Kaminari.paginate_array(logs).page(page).per(per).collect! { |log| parse(log) } + # 过滤掉日志中日志分析请求 + logs.collect! do |log| + log = "" if log =~ Regexp.new("SystemLogController",'i') + log + end end logs end From 87fdd840ecb014257c1ea5b4d3967ffdc665f319 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 11:39:19 +0800 Subject: [PATCH 05/24] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=A2=9E=E5=8A=A0=E5=B7=B2=E6=98=AF=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E9=A1=B9=E7=9B=AE=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 17 +++++++++++------ .../applied_project/applied_join_project.js.erb | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index f5c42f7b4..f2c0eb056 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -6,13 +6,18 @@ class AppliedProjectController < ApplicationController @project = Project.find_by_id(params[:project_id]) if params[:project_join] if @project - @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) - if @applieds.count == 0 - appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) - Mailer.applied_project(appliedproject).deliver - @status = 2 + user = User.find @user_id + if user.member_of?(@project) + @status = 3 else - @status = 1 + @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) + if @applieds.count == 0 + appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) + Mailer.applied_project(appliedproject).deliver + @status = 2 + else + @status = 1 + end end else @status = 0 diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index deac2c9ce..3f4f6aff7 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -4,6 +4,8 @@ alert("请勿重复申请加入该项目"); <% elsif @status == 2%> alert("申请成功"); +<% elsif @status == 3%> + alert("您已加入该项目"); <%else%> alert("申请失败"); <%end%> \ No newline at end of file From e761cd5f221939e55708d9fe2b3db284cd40afe3 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 11:52:37 +0800 Subject: [PATCH 06/24] =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=BC=9A=E4=B8=A2=E5=A4=B1=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/system_log_helper.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/helpers/system_log_helper.rb b/app/helpers/system_log_helper.rb index 12e02ca8f..5412339de 100644 --- a/app/helpers/system_log_helper.rb +++ b/app/helpers/system_log_helper.rb @@ -25,7 +25,10 @@ module SystemLogHelper logs = Kaminari.paginate_array(logs).page(page).per(per).collect! { |log| parse(log) } #将分页后的记录的搜索结果添加样式,样式中的\0是给给r占位置的。 logs.collect! do |log| - keywords.each { |r| log.gsub!(r, '\0') && log = "" if log =~ Regexp.new("SystemLogController",'i') } + if log =~ Regexp.new("SystemLogController",'i') + log = "" + end + keywords.each { |r| log.gsub!(r, '\0') } log end From 0232826a6e2b1017596f626a567fc69c6cb3d2b2 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 12:04:33 +0800 Subject: [PATCH 07/24] =?UTF-8?q?=E4=B8=8A=E6=AC=A1=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=BC=95=E5=85=A5bug:=E5=85=B3=E9=94=AE=E5=AD=97=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=B8=8D=E5=88=B0=E4=BB=BB=E4=BD=95=E4=B8=9C=E8=A5=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/system_log_helper.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/helpers/system_log_helper.rb b/app/helpers/system_log_helper.rb index 5412339de..2ca5baaed 100644 --- a/app/helpers/system_log_helper.rb +++ b/app/helpers/system_log_helper.rb @@ -19,15 +19,12 @@ module SystemLogHelper keywords = keywords.strip.split(/\s+/).collect! { |w| Regexp.new(w, 'i') } # 一条记录应该匹配每个关键字 log =~ r 是对log记录进行判断是否符合r的正则表达式 logs = logs.find_all do |log| - keywords.all? { |r| log =~ r } + keywords.all? { |r| log =~ r && !(log =~ Regexp.new("SystemLogController#",'i')) } end #用Kaminari分页 logs = Kaminari.paginate_array(logs).page(page).per(per).collect! { |log| parse(log) } #将分页后的记录的搜索结果添加样式,样式中的\0是给给r占位置的。 logs.collect! do |log| - if log =~ Regexp.new("SystemLogController",'i') - log = "" - end keywords.each { |r| log.gsub!(r, '\0') } log end From abc5dd1c74645b0a3cd665860910a5d10bcb03da Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 12:07:07 +0800 Subject: [PATCH 08/24] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/system_log/access_analysis.html.erb | 15 ++++++++++++++- app/views/system_log/index.html.erb | 17 +++++++++++++++-- app/views/system_log/time_analysis.html.erb | 12 ++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/app/views/system_log/access_analysis.html.erb b/app/views/system_log/access_analysis.html.erb index 631530370..371c2bc33 100644 --- a/app/views/system_log/access_analysis.html.erb +++ b/app/views/system_log/access_analysis.html.erb @@ -4,7 +4,20 @@ @nav_dispaly_main_contest_label = 1 %> <% @nav_dispaly_forum_label = 1%> - +

diff --git a/app/views/system_log/index.html.erb b/app/views/system_log/index.html.erb index 668d79a6e..041fecb0c 100644 --- a/app/views/system_log/index.html.erb +++ b/app/views/system_log/index.html.erb @@ -3,7 +3,20 @@ @nav_dispaly_main_project_label = 1 @nav_dispaly_main_contest_label = 1 %> <% @nav_dispaly_forum_label = 1%> - +
@@ -32,7 +45,7 @@ <%= paginate @logs unless @logs.empty? %>
<% unless @logs.empty? %> - +
<% @logs.each do |log| %> <% unless log.blank? %> diff --git a/app/views/system_log/time_analysis.html.erb b/app/views/system_log/time_analysis.html.erb index bdf01ca27..96c207b07 100644 --- a/app/views/system_log/time_analysis.html.erb +++ b/app/views/system_log/time_analysis.html.erb @@ -3,6 +3,18 @@ @nav_dispaly_main_project_label = 1 @nav_dispaly_main_contest_label = 1 %> <% @nav_dispaly_forum_label = 1%> +

From 90649209cab357b28f5e926ab61239a6fd805c52 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 13:29:25 +0800 Subject: [PATCH 09/24] =?UTF-8?q?=E5=B0=81=E8=A3=85=EF=BC=8C=E7=AE=80?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E9=87=8D=E6=96=B0=E7=BC=96=E6=8E=92=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=EF=BC=8C=E5=B9=B6=E5=88=A0=E6=8E=89?= =?UTF-8?q?=E4=BA=86=E4=B8=80=E4=BA=9B=E6=97=A0=E7=94=A8=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 556 +++---------------------- 1 file changed, 51 insertions(+), 505 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 899997456..1f78836ae 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -14,39 +14,29 @@ # 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. +# Time 2015-01-28 16:34:21 +# Author lizanle +# Description 封装代码,简化代码,格式化代码, class ProjectsController < ApplicationController layout :select_project_layout menu_item :overview menu_item :roadmap, :only => :roadmap menu_item :settings, :only => :settings - - menu_item l(:label_sort_by_time), :only => :index - menu_item l(:label_sort_by_active), :only => :index - menu_item l(:label_sort_by_influence), :only => :index - - # menu_item l(:label_homework), :only => :homework - # menu_item l(:label_course_feedback), :only => :feedback menu_item :homework, :only => [:homework, :new_homework] menu_item :feedback, :only => :feedback - menu_item l(:label_course_file), :only => :index - menu_item l(:label_course_news), :only => :index - - before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches] - # before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, - # :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share, - # :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index] - #此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member - before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] + before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, + :course, :enterprise_course, :course_enterprise,:view_homework_attaches] + before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, + :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] before_filter :file, :statistics, :watcherlist - #before_filter :find_project_repository, :only => [:show] # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 before_filter :memberAccess, only: :member - accept_rss_auth :index + # accept_rss_auth :index accept_api_auth :index, :show, :create, :update, :destroy after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller| @@ -80,369 +70,66 @@ class ProjectsController < ApplicationController ### added by william include ActsAsTaggableOn::TagsHelper - def find_project_repository - unless @project.repositories.nil? - @project.repositories.each do |repository| - repository.fetch_changesets if Setting.autofetch_changesets? - end - end - end - - def enterprise_course - session[:enterprise_college] = 2 - respond_to do |format| - format.html { redirect_to :back } - #format.api { render_api_ok } - end - end - - def course_enterprise - session[:enterprise_college] = 1 - respond_to do |format| - format.html { redirect_to :back } - #format.api { render_api_ok } - end - end - def index render_404 - #调用存储过程更新提交次数 - #ActiveRecord::Base.connection.execute("CALL sp_project_status_cursor();") - #Modified by nie - @project_type = params[:project_type].to_i - per_page_option = 10 - - @projects_all = Project.active.visible. - joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").joins("LEFT JOIN #{ProjectScore.table_name} ON #{Project.table_name}.id = #{ProjectScore.table_name}.project_id"). - where("#{Project.table_name}.project_type = ? ", Project::ProjectType_project) - - @project_count = @projects_all.count - @project_pages = Paginator.new @project_count, per_page_option, params['page'] - -#gcm activity count - - @project_activity_count=Hash.new - - @projects_all.each do |project| - @project_activity_count[project.id]=0 - end - - @project_activity_count=get_project_activity @projects_all,@project_activity_count - -#gcm end - - case params[:project_sort_type] - when '0' - @projects = @projects_all.order("created_on desc") - @s_type = 0 - when '1' - @projects = @projects_all.order("score desc") - @s_type = 1 - when '2' - @projects = @projects_all.order("watchers_count desc") - @s_type = 2 - - #gcm - when '3' - #@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array) - @projects=handle_project @projects_all,@project_activity_count - @s_type = 3 - @projects = @projects[@project_pages.offset, @project_pages.per_page] - - else - @projects = @projects = @projects_all.order("score desc") - @s_type = 1 - end - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) - - - respond_to do |format| - format.html { - # render :layout => 'base' - # scope = Project - # unless params[:closed] - # scope = scope.active - # end - } - format.api { - # @offset, @limit = api_offset_and_limit - # @project_count = Project.visible.count - # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all - } - format.atom { - projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all - render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") - } - end end def course - @project_type = params[:project_type] - @school_id = params[:school_id] - per_page_option = 10 - if @school_id == "0" or @school_id.nil? - @projects_all = Project.active.visible. - joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id"). - where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course) - else - @projects_all = Project.active.visible. - joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id"). - joins(:course_extra). - where("#{Project.table_name}.project_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id) - end - - @project_count = @projects_all.count - @project_pages = Paginator.new @project_count, per_page_option, params['page'] - - #gcm activity count - - @project_activity_count=Hash.new - #count initialize - @projects_all.each do |project| - @project_activity_count[project.id]=0 - end - - #@project_activity_count=get_project_activity @projects_all,@project_activity_count - #gcm end - - - case params[:project_sort_type] - when '0' - @projects = @projects_all.order("created_on desc") - @s_type = 0 - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) - - #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count - #gcmend - - when '1' - @projects = @projects_all.order("course_ac_para desc") - @s_type = 1 - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) - - #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count - #gcmend - - when '2' - @projects = @projects_all.order("watchers_count desc") - @s_type = 2 - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) - - #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count - #gcmend - - #gcm - when '3' - - #gcm - @project_activity_count=get_project_activity @projects_all,@project_activity_count - #gcmend - - @projects=handle_project @projects_all,@project_activity_count - @s_type = 3 - @projects = @projects[@project_pages.offset, @project_pages.per_page] - else - @s_type = 0 - @projects = @projects_all.order("created_on desc") - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) - - #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count - #gcmend - - end - - respond_to do |format| - format.html { - render :layout => 'base' - } - format.api { - # @offset, @limit = api_offset_and_limit - # @project_count = Project.visible.count - # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all - } - format.atom { - projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all - render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") - } - end + render_404 end -#gcm + # Time 2015-01-29 11:19:11 + # Author lizanle + # Description 项目搜索方法 def search - #modified by nie - project_type = params[:project_type].to_i - projects_all = (project_type.eql? Project::ProjectType_course) ? Project.course_entities : Project.project_entities - @projects = projects_all.visible - #@projects_all = @projects.visible.like(params[:name]) if params[:name].present? + # 如果有名字,就按名字搜索,如果没有,就展示所有,用Karminari分页 if params[:name].present? - @projects_all = @projects.visible.like(params[:name]) - else - @projects_all = @projects; - end - @project_count = @projects_all.count - @project_pages = Paginator.new @project_count, per_page_option, params['page'] - - #gcm activity count - - @project_activity_count=Hash.new - # count initialize - @projects_all.each do |project| - @project_activity_count[project.id]=0 - end - - #@project_activity_count=get_project_activity @projects_all,@project_activity_count - - #gcm end - - - case params[:project_sort_type] - when '0' - @projects = @projects_all.order("created_on desc") - @s_type = 0 - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) - - #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count - #gcmend - - when '1' - @projects = @projects_all.order("course_ac_para desc") - @s_type = 1 - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) - - #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count - #gcmend - - when '2' - @projects = @projects_all.order("watchers_count desc") - @s_type = 2 - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) - - #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count - #gcmend - - when '3' - #@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array) - @project_activity_count=get_project_activity @projects_all,@project_activity_count_array #gcm - @projects=handle_project @projects_all,@project_activity_count - @s_type = 3 - @projects = @projects[@project_pages.offset, @project_pages.per_page] - + @project_pages = Project.project_entities.visible.like(params[:name]).page(params[:page]).per(10) else - @s_type = 0 - @projects = @projects_all.order("created_on desc") - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) - - #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count - #gcmend - + @project_pages = Project.project_entities.visible.page(params[:page] ).per(10) end - + @projects = @project_pages.order("created_on desc") respond_to do |format| format.html { render :layout => 'base' scope = Project unless params[:closed] - scope = scope.active + scope = scope.active end } - format.api { - # @offset, @limit = api_offset_and_limit - # @project_count = Project.visible.count - # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all - } + # 需要到处atom使用的格式 (redmine自带) format.atom { projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") } end end -#gcmend - - - #Added by young - def homework - @offset, @limit = api_offset_and_limit({:limit => 10}) - @bids = @project.homeworks.order('deadline') - @bids = @bids.like(params[:name]) if params[:name].present? - - @bids = paginateHelper @bids - render :layout => 'base_courses' - - end - - def new_homework - # Dear maintainer: - # once you are done trying to 'optimize' this Magic routine, - # well, it's on you, I'll leave it to you. - if (User.current.logged? && - (User.current.admin? || - ( - !Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && - ( - Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles && - ( Role.where(id: [3, 4, 7, 9]).size > 0 ) - ) - ) - ) - ) - @homework = Bid.new - @homework.safe_attributes = params[:bid] - render :layout => 'base_courses' - else - render_404 - end - - end - #Ended by young + # Time 2015-01-29 16:13:20 + # Author lizanle + # Description 项目首页中用户反馈 方法 def feedback - @page = params[:page] - @page = @page.to_i + @page = params[:page].to_i # Find the page of the requested reply @jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - @limit = 10 + limit = 10 offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i]) - page = 1 + offset / @limit + page = 1 + offset / limit if params[:r] && @page.nil? - @page = page - end - - puts @page - if @page < 0 - @page = 1 + @page = @page < 0 ? 1 : @page end - if @page > page - @page = page - end - - - #@feedback_count = @jours.count - #@feedback_pages = Paginator.new @feedback_count, @limit, @page - #@offset ||= @feedback_pages.offset + @page = @page > page ? page : @page @jour = paginateHelper @jours,10 @state = false - @base_courses_tag = @project.project_type - - respond_to do |format| - format.html{render :layout => 'base_courses' if @base_courses_tag==1} + format.html format.api end end def project_respond - # will_reply = JournalsForMessage.find(params[:reference_id]) if params[:reference_id] project_id = request.headers["Referer"].match((%r|/([0-9]{1,})/|))[1] - # @project = Project.find_by_id(project_id) parent_id = params[:reference_id] author_id = User.current.id reply_user_id = params[:reference_user_id] @@ -458,12 +145,8 @@ class ProjectsController < ApplicationController @jfm = Project.add_new_jour(nil, nil, project_id, options) @save_succ = @jfm.errors.empty? - # flash[:notice]=l(:label_projects_feedback_respond_success) - respond_to do |format| - # format.html { redirect_to :back } format.js - #format.api { render_api_ok } end end @@ -554,38 +237,16 @@ class ProjectsController < ApplicationController render_404 end - # Show @project + # Time 2015-01-29 10:42:00 + # Author lizanle + # Description 项目动态展示方法,删除了不必要的代码 def show - @project_type = params[:project_type] - - # try to redirect to the requested menu item + # 试图跳转到请求的按钮 if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) - return + return end - @users_by_role = @project.users_by_role - @subprojects = @project.children.visible.all - @news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").all - @trackers = @project.rolled_up_trackers - if(User.find_by_id(ProjectInfo.find_by_project_id(@project.id).try(:user_id))) - @user = User.find_by_id(ProjectInfo.find_by_project_id(@project.id).user_id) - end cond = @project.project_condition(Setting.display_subprojects_issues?) - @open_issues_by_tracker = Issue.visible.open.where(cond).count(:group => :tracker) - @total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker) - - if User.current.allowed_to?(:view_time_entries, @project) - @total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f - end - - @key = User.current.rss_key - #新增内容 - @days = Setting.activity_days_default.to_i - - if params[:from] - begin; @date_to = params[:from].to_date + 1; rescue; end - end - has = { "show_issues" => true , "show_files" => true, @@ -597,59 +258,40 @@ class ProjectsController < ApplicationController "show_wiki_edits"=>true, "show_journals_for_messages" => true } + # 读取项目默认展示的动态时间天数 + @days = Setting.activity_days_default.to_i @date_to ||= Date.today + 1 - @date_from = @date_to - @days#-1.years #modified by lizanle 去掉這個1年的時間跨度 + # 时间跨度不能太大,不然很慢,所以删掉了-1.years + @date_from = @date_to - @days @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') - @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) + @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id]) # 决定显示所用用户或单个用户活动 - @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, - :with_subprojects => @with_subprojects, - :author => @author) + @activity = Redmine::Activity::Fetcher.new(User.current, + :project => @project, + :with_subprojects => @with_subprojects, + :author => @author) @activity.scope_select {|t| !has["show_#{t}"].nil?} - # logger.debug "=========================================#{@activity.scope}" - # @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? - # modify by nwb - # 添加私密性判断 - if User.current.member_of?(@project)|| User.current.admin? + # 根据私密性,取出符合条件的所有数据 + if User.current.member_of?(@project) || User.current.admin? events = @activity.events(@date_from, @date_to) else events = @activity.events(@date_from, @date_to, :is_public => 1) end + @offset, @limit = api_offset_and_limit({:limit => 10}) @events_count = events.count @events_pages = Paginator.new @events_count, @limit, params['page'] @offset ||= @events_pages.offset + # 总的数据中取出某一页 events = events.slice(@offset,@limit) - #Ended by young + # 按天分组 @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} - # documents - @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' - documents = @project.documents.includes(:attachments, :category).all - case @sort_by - when 'date' - @grouped = documents.group_by {|d| d.updated_on.to_date } - when 'title' - @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} - else - @grouped = documents.group_by(&:category) - end - @document = @project.documents.build - # - @base_courses_tag = @project.project_type - #判断能否显示真名(当前用户为课程的教师时显示真名) - if @project.project_type == Project::ProjectType_course - @teachers= searchTeacherAndAssistant(@project) - @canShowRealName = isCourseTeacher(User.current.id) - end - # real_name action为虚拟的该方法并不存在,用来辅助判断真名权限 - # @canShowRealName = User.current.allowed_to?({:controller => "projects", :action => "real_name"}, @project || @projects, :global => false) + # 根据对应的请求,返回对应的数据 respond_to do |format| - format.html{render :layout => 'base_courses' if @base_courses_tag==1} + format.html format.api end end @@ -660,23 +302,13 @@ class ProjectsController < ApplicationController @member ||= @project.members.new @trackers = Tracker.sorted.all @wiki ||= @project.wiki - #Added by young - # @course_tag = params[:course] - # if @course_tag == '1' - #@course = Course.find_by_extra(@project.identifier) - # if @project.project_type == 1 - # render :layout => 'base_courses' - # else - # render :layout => 'base_projects' - # end - #Ended by young end def edit end - #by young - include CoursesHelper + # by young + # include CoursesHelper def member ## 有角色参数的才是课程,没有的就是项目 @render_file = 'member_list' @@ -695,11 +327,10 @@ class ProjectsController < ApplicationController @subPage_title = '' @members = @project.member_principals.includes(:roles, :principal).all.sort end - else # @project.project_type == Project::ProjectType_project + else roles = Role.find_all_givable @subPage_title = l :label_member_list @members = @project.member_principals.includes(:roles, :principal).joins("LEFT JOIN #{OptionNumber.table_name} ON #{OptionNumber.table_name}.user_id = #{Member.table_name}.user_id and #{OptionNumber.table_name}.score_type = 2 AND #{Member.table_name}.project_id = #{OptionNumber.table_name}.project_id").order("#{OptionNumber.table_name}.total_score DESC").all - #@members = sort_project_members(@project, @members) @applied_members = appied_project_members(@project, @members) end @members = paginateHelper @members @@ -956,91 +587,6 @@ class ProjectsController < ApplicationController end end - - - #gcm - def get_project_activity projects,activities - @project_ids=activities.keys() - - days = Setting.activity_days_default.to_i - date_to ||= Date.today + 1 - date_from = date_to - days-1.years - - #issue_count - Issue.where(project_id: @project_ids).where("updated_on>?",date_from).each do |issue| -# activities[issue.project_id.to_s]+=1 - activities[issue.project_id]+=issue.journals.where("created_on>?",date_from).count - end - - #repository_count - Repository.where(project_id: @project_ids).each do |repository| -# activities[repository.project_id.to_s]+=1 - activities[repository.project_id]+=repository.changesets.where("committed_on>?",date_from).count - end - - - #news_count - News.where(project_id: @project_ids).where("created_on>?",date_from).each do |news| - activities[news.project_id]+=1 - end - - #document_count - Document.where(project_id: @project_ids).where("created_on>?",date_from).each do |document| - activities[document.project_id]+=1 - end - - #file_count - Attachment.where(container_id: @project_ids, container_type: Project).where("created_on>?",date_from).each do |attachment| - activities[attachment.container_id]+=1 - end - - #message_count - Board.where(project_id: @project_ids).each do |board| -# activities[board.project_id]+=1 - activities[board.project_id]+=board.messages.where("updated_on>?",date_from).count - end - - #time_entry_count - TimeEntry.where(project_id: @project_ids).where("updated_on>?",date_from).each do |timeentry| - activities[timeentry.project_id]+=1 - end - - #feedbackc_count - JournalsForMessage.where(jour_id: @project_ids, jour_type: Project).each do |jourformess| - activities[jourformess.jour_id]+=1 - end - - #activities!=0 - i=0; - projects.each do |project| - id=project.id - if activities[id]==0 - activities[id]=1 - end - end - - return activities - end - #gcmend - - #gcm - def handle_project projects,activities - project_activity_count_array=activities.values() - - project_array=[] - i=0; - projects.each do |project| - project_array[i]=project - i=i+1 - end - - projects=desc_sort_course_by_avtivity(project_activity_count_array,project_array) - - return projects - end - #gcmend - - #gcm def desc_sort_course_by_avtivity(activity_count,projects) return projects if activity_count.size<2 From b453d162285fc7381b61d2e6ccfd11db271726e7 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 13:30:06 +0800 Subject: [PATCH 10/24] =?UTF-8?q?=E5=B0=86controller=E9=87=8C=E7=9A=84?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E6=96=B9=E6=B3=95=E6=8C=AA=E5=88=B0helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/projects_helper.rb | 166 ++++++++++++++++----------------- 1 file changed, 81 insertions(+), 85 deletions(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 5df3644ad..fe6714186 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -36,67 +36,8 @@ module ProjectsHelper {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} ] tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} - end - # added bu huang - def sort_project_enterprise(state, project_type) - content = ''.html_safe - case state - when 0 - - content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - when 1 - - content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type))) - end - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs_enterprise") - end - - def sort_course(state, project_type, school_id) - content = ''.html_safe - case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :school_id => school_id, :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) - - when 1 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id), :class=>"selected"), :class=>"selected") - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) - - when 2 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) - - #gcm - when 3 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id), :class=>"selected"), :class=>"selected") - end - #gcmend - - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs") - end - # end - def sort_project(state, project_type) content = ''.html_safe case state @@ -118,30 +59,7 @@ module ProjectsHelper content = content_tag('ul', content) content_tag('div', content, :class => "tabs") end - - # def sort_course(state, project_type) - # content = ''.html_safe - # case state - # when 0 -# - # content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - # content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - # when 1 -# - # content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - # content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) - # when 2 - # content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") - # content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) - # end - # content = content_tag('ul', content) - # content_tag('div', content, :class => "tabs") - # end - # Added by young def course_settings_tabs tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, @@ -153,9 +71,6 @@ module ProjectsHelper end # Ended by young - - - def parent_project_select_tag(project) selected = project.parent # retrieve the requested parent project @@ -375,4 +290,85 @@ module ProjectsHelper end end end + + # Time 2015-01-29 11:39:02 + # Author lizanle + # Description 计算projects + def get_project_activity projects,activities + @project_ids=activities.keys() + + days = Setting.activity_days_default.to_i + date_to ||= Date.today + 1 + date_from = date_to - days-1.years + + #issue_count + Issue.where(project_id: @project_ids).where("updated_on>?",date_from).each do |issue| +# activities[issue.project_id.to_s]+=1 + activities[issue.project_id]+=issue.journals.where("created_on>?",date_from).count + end + + #repository_count + Repository.where(project_id: @project_ids).each do |repository| +# activities[repository.project_id.to_s]+=1 + activities[repository.project_id]+=repository.changesets.where("committed_on>?",date_from).count + end + + + #news_count + News.where(project_id: @project_ids).where("created_on>?",date_from).each do |news| + activities[news.project_id]+=1 + end + + #document_count + Document.where(project_id: @project_ids).where("created_on>?",date_from).each do |document| + activities[document.project_id]+=1 + end + + #file_count + Attachment.where(container_id: @project_ids, container_type: Project).where("created_on>?",date_from).each do |attachment| + activities[attachment.container_id]+=1 + end + + #message_count + Board.where(project_id: @project_ids).each do |board| +# activities[board.project_id]+=1 + activities[board.project_id]+=board.messages.where("updated_on>?",date_from).count + end + + #time_entry_count + TimeEntry.where(project_id: @project_ids).where("updated_on>?",date_from).each do |timeentry| + activities[timeentry.project_id]+=1 + end + + #feedbackc_count + JournalsForMessage.where(jour_id: @project_ids, jour_type: Project).each do |jourformess| + activities[jourformess.jour_id]+=1 + end + + #activities!=0 + i=0; + projects.each do |project| + id=project.id + if activities[id]==0 + activities[id]=1 + end + end + + return activities + end + + def handle_project projects,activities + project_activity_count_array=activities.values() + + project_array=[] + i=0; + projects.each do |project| + project_array[i]=project + i=i+1 + end + + projects=desc_sort_course_by_avtivity(project_activity_count_array,project_array) + + return projects + end end From 22dd4981c01457bdfa429f7895b7225d2fd6564c Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 13:35:10 +0800 Subject: [PATCH 11/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/search.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/search.html.erb b/app/views/projects/search.html.erb index 7a91082ca..0f6fa695e 100644 --- a/app/views/projects/search.html.erb +++ b/app/views/projects/search.html.erb @@ -67,7 +67,7 @@

From d0a675f2b8a489d8048a2898676743301d63a8a3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 30 Jan 2015 14:11:35 +0800 Subject: [PATCH 12/24] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E7=89=88=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/enterprises.js.coffee | 3 + app/assets/stylesheets/enterprises.css.scss | 3 + app/controllers/enterprises_controller.rb | 6 + app/controllers/welcome_controller.rb | 11 + app/helpers/enterprises_helper.rb | 2 + app/helpers/projects_helper.rb | 6 +- app/models/course.rb | 2 +- app/models/project.rb | 4 +- app/views/enterprises/index.html.erb | 25 ++ app/views/projects/_form.html.erb | 2 +- app/views/welcome/_hot_projects_list.html.erb | 23 ++ app/views/welcome/_no_course_title.html.erb | 2 +- app/views/welcome/index.html.erb | 297 ++++++++---------- config/locales/zh.yml | 10 + config/routes.rb | 5 +- ...8032421_add_enterprise_name_to_projects.rb | 5 + db/schema.rb | 41 ++- public/stylesheets/application.css | 3 + .../enterprises_controller_spec.rb | 12 + 19 files changed, 294 insertions(+), 168 deletions(-) create mode 100644 app/assets/javascripts/enterprises.js.coffee create mode 100644 app/assets/stylesheets/enterprises.css.scss create mode 100644 app/controllers/enterprises_controller.rb create mode 100644 app/helpers/enterprises_helper.rb create mode 100644 app/views/enterprises/index.html.erb create mode 100644 app/views/welcome/_hot_projects_list.html.erb create mode 100644 db/migrate/20150128032421_add_enterprise_name_to_projects.rb create mode 100644 spec/controllers/enterprises_controller_spec.rb diff --git a/app/assets/javascripts/enterprises.js.coffee b/app/assets/javascripts/enterprises.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/enterprises.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/enterprises.css.scss b/app/assets/stylesheets/enterprises.css.scss new file mode 100644 index 000000000..174f3a2ec --- /dev/null +++ b/app/assets/stylesheets/enterprises.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Enterprises controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb new file mode 100644 index 000000000..c15b6dc8f --- /dev/null +++ b/app/controllers/enterprises_controller.rb @@ -0,0 +1,6 @@ +class EnterprisesController < ApplicationController + layout 'project_base' + def index + @enterprises = Project.find_by_sql("select enterprise_name from projects") + end +end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 8e11bceb5..6c28ec502 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -25,6 +25,17 @@ class WelcomeController < ApplicationController before_filter :entry_select, :only => [:index] def index + unless params[:enterprise].nil? + @enterprise = params[:enterprise] + @enterprise_projects = Project.find_by_sql(["select * from projects where enterprise_name =? ", @enterprise]) + @e_count = @enterprise_projects.count + if @e_count < 10 + part_count = 10 -@e_count + # @part_projects = find_all_hot_project part_count, order + @part_projects = find_miracle_project(part_count, 3,"score desc") + limit = 10 - @e_count + end + end if @first_page.nil? || @first_page.sort_type.nil? @projects = find_miracle_project(10, 3,"score desc") else diff --git a/app/helpers/enterprises_helper.rb b/app/helpers/enterprises_helper.rb new file mode 100644 index 000000000..10321ba16 --- /dev/null +++ b/app/helpers/enterprises_helper.rb @@ -0,0 +1,2 @@ +module EnterprisesHelper +end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 5df3644ad..6b6127979 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -367,7 +367,7 @@ module ProjectsHelper return true end end - + def find_project_repository project unless project.repositories.nil? project.repositories.each do |repository| @@ -375,4 +375,8 @@ module ProjectsHelper end end end + + def get_part_projects e_count, t_count + + end end diff --git a/app/models/course.rb b/app/models/course.rb index a5de93cf7..c986597b3 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -6,7 +6,7 @@ class Course < ActiveRecord::Base STATUS_CLOSED = 5 STATUS_ARCHIVED = 9 - attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student + attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 diff --git a/app/models/project.rb b/app/models/project.rb index 14763347f..d5f3e381e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -116,6 +116,7 @@ class Project < ActiveRecord::Base validates_associated :repository, :wiki # validates_length_of :description, :maximum => 255 validates_length_of :name, :maximum => 255 + validates_length_of :enterprise_name, :maximum => 255 validates_length_of :homepage, :maximum => 255 validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH # donwcase letters, digits, dashes but not digits only @@ -760,7 +761,8 @@ class Project < ActiveRecord::Base 'issue_custom_field_ids', 'project_type', 'dts_test', - 'attachmenttype' + 'attachmenttype', + 'enterprise_name' diff --git a/app/views/enterprises/index.html.erb b/app/views/enterprises/index.html.erb new file mode 100644 index 000000000..9db8d99ab --- /dev/null +++ b/app/views/enterprises/index.html.erb @@ -0,0 +1,25 @@ +
+

+ <%= link_to l(:label_all_enterprises) %> +

+

+ <% if @enterprises.count == 0 %> +

<%= l(:label_enterprise_nil) %>

+ <% else %> + <% @enterprises.each do |enterprise| %> + <% unless enterprise.enterprise_name.blank? %> +
    +
  • + <%= link_to enterprise.enterprise_name, home_path(:enterprise => enterprise.enterprise_name) %> +
  • +
+ <% end %> + <% end %> + <% end %> +

+
+
+
+
    +
    +<% html_title(l(:label_school_all)) -%> diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index 512c2df82..636aadf43 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -8,7 +8,7 @@

    <%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>

    - +

    <%= f.text_field :enterprise_name, :size => 60, :style => "width:490px;" %>

    <%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH, value:"#{User.current.id.to_s + '_' +Time.now.to_s.gsub(' ','_').gsub(':','').gsub('+','')}" %> <% unless @project.identifier_frozen? %> diff --git a/app/views/welcome/_hot_projects_list.html.erb b/app/views/welcome/_hot_projects_list.html.erb new file mode 100644 index 000000000..9b941f420 --- /dev/null +++ b/app/views/welcome/_hot_projects_list.html.erb @@ -0,0 +1,23 @@ +

  • +
    + <%= 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}" %> +
    +
  • \ No newline at end of file diff --git a/app/views/welcome/_no_course_title.html.erb b/app/views/welcome/_no_course_title.html.erb index f16b91dba..3b3849e4e 100644 --- a/app/views/welcome/_no_course_title.html.erb +++ b/app/views/welcome/_no_course_title.html.erb @@ -1,5 +1,5 @@

    - <%= course_title%> + <%= course_title %>

    \ No newline at end of file diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 3e341bd27..5dd8c2f86 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -2,197 +2,172 @@ <%= stylesheet_link_tag 'welcome' %> <%= javascript_include_tag 'welcome' %>
    - <%#= render partial: 'wei_xin' %> + <%#= 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 %> - + + <% if @enterprise.nil? %> + <% 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 %> + <% else %> + <%= image_tag '/images/avatars/Project/0', width:@first_page.image_width,height: @first_page.image_height %> + <% end %>
    -
    - <% unless @first_page.nil? %> - <%= @first_page.description.html_safe %> - <% end %> -
    - -
    +
    + <% if @enterprise.nil? %> + <% unless @first_page.nil? %> + <%= @first_page.description.html_safe %> + <% end %> + <% else %> + + <%= link_to @enterprise, options={:action => 'index', :enterprise => @enterprise}, html_options={ :method => 'get', :style => "color: #E8770D"} %> +
    + <%= @first_page.title %> + <% 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) %> -      - <%= link_to l(:label_join_project), join_project_projects_path ,:remote => true, :class => 'icon icon-add' %> -      - <% 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) %> +      + <%= link_to l(:label_join_project), join_project_projects_path ,:remote => true, :class => 'icon icon-add' %> +      + <% end %>
      - <% @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 %> + + <% if @enterprise.nil? %> + <% @projects.map do |project| %> + <%= render :partial => 'hot_projects_list', :locals => {:project => project} %> + <% end; reset_cycle %> + + <% else %> + <% if @e_count == 0 %> +

      <%= l(:label_enterprise_tips) %>

      + <% @projects.map do |project| %> + <%= render :partial => 'hot_projects_list', :locals => {:project => project} %> + <% end; reset_cycle %> + <% elsif @e_count < 10 %> + <% @enterprise_projects.map do |project| %> + <%= render :partial => 'hot_projects_list', :locals => {:project => project} %> + <% end %> +

      <%= l(:label_part_enterprise_tips) %>

      + <% @part_projects.map do |project| %> + <%= render :partial => 'hot_projects_list', :locals => {:project => project} %> + <% end %> + <% else %> + <% @part_projects.map do |project| %> + <%= render :partial => 'hot_projects_list', :locals => {:project => project} %> + <% end %> + <% end; reset_cycle %> + <% end; reset_cycle %>
    -
      -

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

      -
      - <%activities = find_all_activities%> - <% activities.each do |event| %> -
    • -
      - <%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %> -
      -
      - - <%= link_to event.event_author, (user_path(event.event_author) if event.event_author), - :style => "color:green;", :target => "_blank" %> - - <%= show_user_content event %> -

      - - <%= l(:field_updated_on) %> - <%= time_tag_welcome event.event_datetime %>前 - -       - - <%= show_event_reply event %> - -

      -
      -
    • - <% end %> -
      -
    -
    +
      +

      <%= l(:lable_user_active)%>

      +
      + <% activities = find_all_activities%> + <% activities.each do |event| %> +
    • +
      + <%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %> +
      +
      + <%= link_to event.event_author, (user_path(event.event_author) if event.event_author), + :style => "color:green;", :target => "_blank" %> + <%= show_user_content event %> +

      + <%= l(:field_updated_on) %> + <%= time_tag_welcome event.event_datetime %>前 +       + <%= show_event_reply event %> +

      +
      +
    • + <% end %> +
      +
    +
    -
    +
      - +
      -

      - - <%= l(:lable_bar_active)%> - - <%= 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), forums_path %> - +

      <%= l(:lable_bar_active)%> <%= 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), forums_path %>
      <% topics = find_new_forum_topics(6) %> - <% topics.includes(:forum, :last_reply, :author).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,title: topic.subject %> -
      -
      - - <%= "#{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 %> - - - <% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %> - <%= l(:label_final_reply)%>: - <%=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 %> + <% topics.includes(:forum, :last_reply, :author).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,title: topic.subject %> +
      +
      + <%= "#{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 %> + <% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %> + <%= l(:label_final_reply)%>: + <%= 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 %>
    -
    +
    <%= render partial: 'link_to_another' %> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d058a6c1b..d6ecec369 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -275,6 +275,7 @@ zh: label_course_closed_tips: "确定要%{desc}课程?" # end field_name: 名称 + field_enterprise_name: 企业名 #added by huang field_tea_name: 教师 field_couurse_time: 学时 @@ -2313,3 +2314,12 @@ zh: label_technical_support: 技术支持: label_feedback: 意见反馈 + + # 项目企业模块 + label_all_enterprises: 所有企业 + label_my_enterprise: 我的企业 + label_enterprise_tips: 暂时还没有该企业对应的项目,系统的其它项目您可能会感兴趣! + label_part_enterprise_tips: 系统的其它项目您可能也会感兴趣! + label_enterprise_nil: 改模块为最新上线模块,目前还未有项目关联到企业! + label_enterprises: 名企 + diff --git a/config/routes.rb b/config/routes.rb index 122481d38..6fc78fd49 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,6 +26,8 @@ # Example: :via => :get ====> :via => :get RedmineApp::Application.routes.draw do + get "enterprises/index" + #match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index' mount Mobile::API => '/api' @@ -388,7 +390,8 @@ RedmineApp::Application.routes.draw do match '/statistics', :to => 'projects#statistics', :as => 'statistics', :via => :get # match '/investor', :controller => 'projects', :action => 'investor', :as => 'investor', :via => :get match '/homework', :to => 'projects#homework', :as => 'homework', :via => :get - + match 'enterprise', :to => 'enterprises#index', :as => 'index', :via => :get + # match '/activity', :controller => 'activities', :action => 'index', :as => 'activity', :via => :get # match '/repository', :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil, :as => 'repository', :via => :get # match '/', :controller => 'projects', :action => 'show', :as => 'project_show', :via => :get diff --git a/db/migrate/20150128032421_add_enterprise_name_to_projects.rb b/db/migrate/20150128032421_add_enterprise_name_to_projects.rb new file mode 100644 index 000000000..8ec2b25a3 --- /dev/null +++ b/db/migrate/20150128032421_add_enterprise_name_to_projects.rb @@ -0,0 +1,5 @@ +class AddEnterpriseNameToProjects < ActiveRecord::Migration + def change + add_column :projects, :enterprise_name, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 98476f9dd..7c9e6d556 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150123020615) do +ActiveRecord::Schema.define(:version => 20150128032421) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -925,6 +925,7 @@ ActiveRecord::Schema.define(:version => 20150123020615) do t.integer "attachmenttype", :default => 1 t.integer "user_id" t.integer "dts_test", :default => 0 + t.string "enterprise_name" end add_index "projects", ["lft"], :name => "index_projects_on_lft" @@ -1069,6 +1070,14 @@ ActiveRecord::Schema.define(:version => 20150123020615) do t.string "description" end + create_table "social_groups", :force => true do |t| + t.string "name" + t.text "description" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1284,6 +1293,36 @@ ActiveRecord::Schema.define(:version => 20150123020615) do add_index "versions", ["project_id"], :name => "versions_project_id" add_index "versions", ["sharing"], :name => "index_versions_on_sharing" + create_table "voting_choices", :force => true do |t| + t.integer "poll_id", :null => false + t.string "text", :null => false + t.datetime "created_on", :null => false + t.integer "position", :default => 1 + end + + add_index "voting_choices", ["poll_id"], :name => "choices_poll_id" + + create_table "voting_polls", :force => true do |t| + t.integer "project_id", :null => false + t.string "question", :null => false + t.datetime "created_on", :null => false + t.boolean "revote" + end + + add_index "voting_polls", ["project_id"], :name => "polls_project_id" + + create_table "voting_votes", :force => true do |t| + t.integer "user_id", :null => false + t.integer "poll_id", :null => false + t.integer "choice_id", :null => false + t.datetime "created_on", :null => false + end + + add_index "voting_votes", ["choice_id"], :name => "votes_choice_id" + add_index "voting_votes", ["poll_id"], :name => "votes_poll_id" + add_index "voting_votes", ["user_id", "poll_id"], :name => "votes_user_poll_unique", :unique => true + add_index "voting_votes", ["user_id"], :name => "votes_user_id" + create_table "watchers", :force => true do |t| t.string "watchable_type", :default => "", :null => false t.integer "watchable_id", :default => 0, :null => false diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index db57596bc..9c8471315 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -9,6 +9,9 @@ h4, .wiki h3 {font-size: 13px;} h4 {border-bottom: 1px dotted #bbb;} /*huang*/ /*current position*/ +.enterprise_all{ + padding-left: 20px; +} .course_ad{ position:absolute; visibility:visible; diff --git a/spec/controllers/enterprises_controller_spec.rb b/spec/controllers/enterprises_controller_spec.rb new file mode 100644 index 000000000..49ca325bf --- /dev/null +++ b/spec/controllers/enterprises_controller_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe EnterprisesController do + + describe "GET 'index'" do + it "returns http success" do + get 'index' + response.should be_success + end + end + +end From 36c07f96642ef7bfbd1b1b3046d30897c290838e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 14:16:32 +0800 Subject: [PATCH 13/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=92=E7=BB=9D?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=88=90=E5=91=98=E5=8A=A0=E5=85=A5=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E9=A1=B5=E9=9D=A2=E4=B8=8D=E4=BC=9A=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 4 +- app/views/members/create.js.erb | 8 +- app/views/projects/settings/_members.html.erb | 80 ++++++++++++------- 3 files changed, 60 insertions(+), 32 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index ca80d90f8..668e243c9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -114,8 +114,8 @@ class Project < ActiveRecord::Base validates_presence_of :name, :identifier validates_uniqueness_of :identifier validates_uniqueness_of :name - validates_associated :repository, :wiki - # validates_length_of :description, :maximum => 255 + validates_associated :wiki#, :repository + # validates_length_of :description, :maximum => 255 validates_length_of :name, :maximum => 255 validates_length_of :homepage, :maximum => 255 validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH diff --git a/app/views/members/create.js.erb b/app/views/members/create.js.erb index 3b01980ad..35280b7a4 100644 --- a/app/views/members/create.js.erb +++ b/app/views/members/create.js.erb @@ -12,7 +12,11 @@ hideOnLoad(); $("#member-<%= member.id %>").effect("highlight"); <% end %> <% else %> - <% errors = @members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ') %> - alert('<%= raw(escape_javascript(l(:notice_failed_to_save_members, :errors => errors))) %>'); + <% if @members %> + <% errors = @members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ')%> + alert('<%= raw(escape_javascript(l(:notice_failed_to_save_members, :errors => errors || ''))) %>'); + <% else%> +// alert(''); + <% end%> <% end %> <% end %> diff --git a/app/views/projects/settings/_members.html.erb b/app/views/projects/settings/_members.html.erb index 25f02da0d..9c9c64bd1 100644 --- a/app/views/projects/settings/_members.html.erb +++ b/app/views/projects/settings/_members.html.erb @@ -14,8 +14,12 @@
    <%=l(:label_log_detail)%>
    - - + + <%= call_hook(:view_projects_settings_members_table_header, :project => @project) %> @@ -24,26 +28,30 @@ <% members.each do |member| %> <% next if member.new_record? %> - + @@ -77,7 +85,9 @@
    <%= l(:label_user) %><%= l(:label_role_plural) %> + <%= l(:label_user) %> + + <%= l(:label_role_plural) %> +
    <%= link_to_user member.principal %> + <%= link_to_user member.principal %> + - - <%= h member.roles.sort.collect(&:to_s).join(', ') %> - + + <%= h member.roles.sort.collect(&:to_s).join(', ') %> + <%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member), :method => :put, :html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}} ) do |f| %> -

    <% roles.each do |role| %>
    - <% end %>

    + <% end %> +

    <%= hidden_field_tag 'membership[role_ids][]', '' %> -

    <%= submit_tag l(:button_change), :class => "small" %> +

    + <%= submit_tag l(:button_change), :class => "small" %> <%= link_to_function l(:button_cancel), "$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;" - %>

    + %> +

    <% end %>
    <% else %> -

    <%= l(:label_no_data) %>

    +

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

    <% end %>
    @@ -87,20 +97,25 @@
    <%= form_for(@applied_members, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
    - <%= l(:label_apply_project) %> - + + <%= l(:label_apply_project) %> +
    <%= render_principals_for_applied_members(@project) %>

    -

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

    + <%= l(:label_role_plural) %>: <% roles.each do |role| %> - - - <% end %>

    - -

    <%= submit_tag l(:label_approve), :id => 'member-add-submit' %> + + <% end %> +

    +

    + <%= submit_tag l(:label_approve), :id => 'member-add-submit' %> <%= submit_tag l(:label_refusal), :name => "refusal_button", :id => 'member-refusal-submit' %>

    @@ -110,9 +125,13 @@ <%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
    - <%= l(:label_member_new) %> - -

    <%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %>

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

    + <%= label_tag "principal_search", l(:label_principal_search) %> + <%= text_field_tag 'principal_search', nil %> +

    <%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js') }')" %>
    @@ -120,13 +139,18 @@

    -

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

    + <%= l(:label_role_plural) %>: <% roles.each do |role| %> - - - <% end %>

    - -

    <%= submit_tag l(:button_add), :id => 'member-add-submit' %>

    + + <% end %> +

    +

    + <%= submit_tag l(:button_add), :id => 'member-add-submit' %> +

    <% end %> <% end %> From 31c78279eafbeacb44b00e282c3a0e25e6f8505b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 14:31:15 +0800 Subject: [PATCH 14/24] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=B8=AAend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/index.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index db6980dc9..96bcd2ab3 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -102,7 +102,6 @@ <% end %> <% end; reset_cycle %> <% end; reset_cycle %> - <% end %>
    From 9e470fa25ccdca05ce47b1ba20b0e6ee702ec979 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 30 Jan 2015 14:45:33 +0800 Subject: [PATCH 15/24] meigia --- app/views/welcome/index.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index db6980dc9..0a8b5ed79 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -192,6 +192,7 @@ <%end %> <% end %> <% end %> +
    From 864ed349e4d5e06e70bcd26bb46d14d50c7f44d3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 30 Jan 2015 14:48:24 +0800 Subject: [PATCH 16/24] =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 7331f06ae..343ad2432 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2447,3 +2447,12 @@ zh: next: "下一页 »" truncate: "..." + + + # 项目企业模块 + label_all_enterprises: 所有企业 + label_my_enterprise: 我的企业 + label_enterprise_tips: 暂时还没有该企业对应的项目,系统的其它项目您可能会感兴趣! + label_part_enterprise_tips: 系统的其它项目您可能也会感兴趣! + label_enterprise_nil: 改模块为最新上线模块,目前还未有项目关联到企业! + label_enterprises: 名企 From a467736a5ef031b17bda1ee7ec2ce005aaf8b483 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 30 Jan 2015 14:52:36 +0800 Subject: [PATCH 17/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8A=E5=A4=9A?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=94=AF=E4=B8=80=E6=80=A7=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E3=80=8B=20Signed-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_group.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/models/course_group.rb b/app/models/course_group.rb index c7fc81df4..680fa6497 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -12,8 +12,7 @@ class CourseGroup < ActiveRecord::Base before_destroy :set_member_nil attr_accessible :name - validates :name, :presence => true, :length => {:maximum => 20} - validate :unique_name_and_course + validates :name, :presence => true, :length => {:maximum => 20}, :uniqueness => { :scope => :course_id} @@ -22,10 +21,5 @@ class CourseGroup < ActiveRecord::Base self.members.update_all("course_group_id = 0") end end - private - def unique_name_and_course - if CourseGroup.where("name=? and course_id=?", name, course_id).first - errors.add(:name, :groupname_repeat) - end - end + end From a0debe77bb2923e91929a3d416f4b35a481fb687 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 15:27:16 +0800 Subject: [PATCH 18/24] 111 --- db/schema.rb | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 7c9e6d556..d7a1b18bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1070,14 +1070,6 @@ ActiveRecord::Schema.define(:version => 20150128032421) do t.string "description" end - create_table "social_groups", :force => true do |t| - t.string "name" - t.text "description" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1293,36 +1285,6 @@ ActiveRecord::Schema.define(:version => 20150128032421) do add_index "versions", ["project_id"], :name => "versions_project_id" add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - create_table "voting_choices", :force => true do |t| - t.integer "poll_id", :null => false - t.string "text", :null => false - t.datetime "created_on", :null => false - t.integer "position", :default => 1 - end - - add_index "voting_choices", ["poll_id"], :name => "choices_poll_id" - - create_table "voting_polls", :force => true do |t| - t.integer "project_id", :null => false - t.string "question", :null => false - t.datetime "created_on", :null => false - t.boolean "revote" - end - - add_index "voting_polls", ["project_id"], :name => "polls_project_id" - - create_table "voting_votes", :force => true do |t| - t.integer "user_id", :null => false - t.integer "poll_id", :null => false - t.integer "choice_id", :null => false - t.datetime "created_on", :null => false - end - - add_index "voting_votes", ["choice_id"], :name => "votes_choice_id" - add_index "voting_votes", ["poll_id"], :name => "votes_poll_id" - add_index "voting_votes", ["user_id", "poll_id"], :name => "votes_user_poll_unique", :unique => true - add_index "voting_votes", ["user_id"], :name => "votes_user_id" - create_table "watchers", :force => true do |t| t.string "watchable_type", :default => "", :null => false t.integer "watchable_id", :default => 0, :null => false From f2a3ce0ecee59315cb3617cbb36b554490290814 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 30 Jan 2015 16:05:36 +0800 Subject: [PATCH 19/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8A=E7=BD=91?= =?UTF-8?q?=E9=A1=B5=E6=A0=87=E9=A2=98=E6=98=BE=E7=A4=BA=E4=B8=BA=E2=80=9C?= =?UTF-8?q?=E4=B8=AD=E5=9B=BD=E9=AB=98=E6=A0=A1=E2=80=9D=E4=B8=8D=E5=90=88?= =?UTF-8?q?=E9=80=82=E3=80=8Bbug=20Signed-off-by:=20alan=20<547533434@qq.c?= =?UTF-8?q?om>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_group.rb | 2 +- app/views/enterprises/index.html.erb | 2 +- config/locales/zh.yml | 3 ++- config/routes.rb | 2 +- db/schema.rb | 38 ---------------------------- 5 files changed, 5 insertions(+), 42 deletions(-) diff --git a/app/models/course_group.rb b/app/models/course_group.rb index 680fa6497..c6aa1299d 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -21,5 +21,5 @@ class CourseGroup < ActiveRecord::Base self.members.update_all("course_group_id = 0") end end - + end diff --git a/app/views/enterprises/index.html.erb b/app/views/enterprises/index.html.erb index 9db8d99ab..6124f5c7f 100644 --- a/app/views/enterprises/index.html.erb +++ b/app/views/enterprises/index.html.erb @@ -22,4 +22,4 @@
    -<% html_title(l(:label_school_all)) -%> +<% html_title(l(:label_enterprise_all)) -%> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 343ad2432..524494f45 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2204,7 +2204,8 @@ zh: label_project_deposit: 项目托管 label_course_practice: 课程实践 label_forum_all: 公共贴吧 - label_school_all: 中国高校 + label_school_all: 中国高校 + :label_enterprise_all: 名企 label_contest_innovate: 创新竞赛 label_software_user: 软件创客 label_requirement_enterprise: 软件众包 diff --git a/config/routes.rb b/config/routes.rb index aad7adcb3..0692103bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -731,7 +731,7 @@ RedmineApp::Application.routes.draw do match 'delete_avatar', :to => 'avatar#delete_image',:via => :post # Endof Tao's code get 'robots.txt', :to => 'welcome#robots' - match 'welcome/course', :to => 'welcome#course' + #match 'welcome/course', :to => 'welcome#course' ##############测试留言功能 fq post 'words/new', :to => 'words#new' post 'words/create', :to => 'words#create' diff --git a/db/schema.rb b/db/schema.rb index 7c9e6d556..d7a1b18bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1070,14 +1070,6 @@ ActiveRecord::Schema.define(:version => 20150128032421) do t.string "description" end - create_table "social_groups", :force => true do |t| - t.string "name" - t.text "description" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1293,36 +1285,6 @@ ActiveRecord::Schema.define(:version => 20150128032421) do add_index "versions", ["project_id"], :name => "versions_project_id" add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - create_table "voting_choices", :force => true do |t| - t.integer "poll_id", :null => false - t.string "text", :null => false - t.datetime "created_on", :null => false - t.integer "position", :default => 1 - end - - add_index "voting_choices", ["poll_id"], :name => "choices_poll_id" - - create_table "voting_polls", :force => true do |t| - t.integer "project_id", :null => false - t.string "question", :null => false - t.datetime "created_on", :null => false - t.boolean "revote" - end - - add_index "voting_polls", ["project_id"], :name => "polls_project_id" - - create_table "voting_votes", :force => true do |t| - t.integer "user_id", :null => false - t.integer "poll_id", :null => false - t.integer "choice_id", :null => false - t.datetime "created_on", :null => false - end - - add_index "voting_votes", ["choice_id"], :name => "votes_choice_id" - add_index "voting_votes", ["poll_id"], :name => "votes_poll_id" - add_index "voting_votes", ["user_id", "poll_id"], :name => "votes_user_poll_unique", :unique => true - add_index "voting_votes", ["user_id"], :name => "votes_user_id" - create_table "watchers", :force => true do |t| t.string "watchable_type", :default => "", :null => false t.integer "watchable_id", :default => 0, :null => false From 36488560119da0dc33492442300e249abc691553 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 16:05:52 +0800 Subject: [PATCH 20/24] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2show=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=202=E3=80=81=E4=BF=AE=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E6=98=9F=E6=98=9F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/css.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/stylesheets/css.css b/public/stylesheets/css.css index d53b6ec02..ffb9da644 100644 --- a/public/stylesheets/css.css +++ b/public/stylesheets/css.css @@ -1,5 +1,6 @@ /* CSS Document */ #content{ font-size:12px !important; font-family:"微软雅黑","宋体" !important; line-height:1.9; background:#fff; font-style:normal;} +#popbox{ font-size:12px !important; font-family:"微软雅黑","宋体" !important; line-height:1.9; background:#fff; font-style:normal;} div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,span,textarea{ margin:0; padding:0;} div,img,tr,td,textarea{ border:0;} table,tr,td{border:0; cellspacing:0; cellpadding:0;} @@ -79,7 +80,7 @@ a.wzan_visited{background:url(images/pic_zan.png) 0 0 no-repeat;} .ping_con h2{ font-size:14px; color:#444443; margin-bottom:10px; } .ping_con p{ color:#777777; font-size:12px; border-bottom:1px dashed #CCC; padding-bottom:5px;} .ping_con p span a{ color:#777777;} -.ping_star{ width:160px; color:#333; font-weight:bold; margin-bottom:5px;} +.ping_star{ width:165px; color:#333; font-weight:bold; margin-bottom:5px;} .ping_star span a{ float:right; width:20px; height:20px; background:url(images/star.png);background-repeat: no-repeat; margin-right:3px;} .ping_con textarea{ height:76px; border:1px solid #15bccf; margin-bottom:5px; color:#666; font-size:12px;} a.ping_sub{ float:right; height:22px; width:60px; margin-right:20px; background:#15bccf; color:#fff; text-align:center;} From 34c68a59fc5d6c386d9e8a7806f2b1e065446eef Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 16:19:05 +0800 Subject: [PATCH 21/24] =?UTF-8?q?=E5=85=B3=E9=97=AD=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E8=80=81=E5=B8=88=E5=AE=B9=E8=AE=B8=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E7=BB=9F=E8=AE=A1=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_poll.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index fdf534405..644b678b8 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -22,9 +22,9 @@ <% end %> <%if @is_teacher%> - <% if poll.polls_status == 1 || poll.polls_status == 3 %> + <% if poll.polls_status == 1%>
  • 统计结果
  • - <% elsif poll.polls_status == 2%> + <% elsif poll.polls_status == 2 || poll.polls_status == 3 %>
  • <%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%>
  • From 6bd202e80a1c29bc4b9c69cc0290af2ef8095cdb Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 30 Jan 2015 16:58:05 +0800 Subject: [PATCH 22/24] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=BD=93=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=BA=E8=AF=BE=E7=A8=8B=E5=AD=A6=E7=94=9F=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=88=86=E9=85=8D=E7=BB=99=E6=94=B9=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E5=8C=BF=E8=AF=84=E7=9A=84=E4=BD=9C=E4=B8=9A=E9=9B=86?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/homework.rb | 5 ++++ app/controllers/homework_attach_controller.rb | 8 +----- app/helpers/homework_attach_helper.rb | 11 ++++++++ app/services/courses_service.rb | 28 +++++++++++++++---- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index ae3637106..9be9bc53e 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -35,6 +35,11 @@ module Mobile #作业状态 0:新建,1:已开启匿评,2:已关闭匿评 #只有作业启用了匿评功能且当前用户是课程老师且已提交的作品数量大于或等于2才能开启匿评 homework_expose :homework_state + + expose :homework_for_anonymous_comments,using: Mobile::Entities::HomeworkAttach do |f, opt| + f[:homework_for_anonymous_comments] if f.is_a?(Hash) && f.key?(:homework_for_anonymous_comments) + end + end end end \ No newline at end of file diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 8e69d1d72..2c943e778 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -101,13 +101,7 @@ class HomeworkAttachController < ApplicationController #获取学生匿评列表 def get_student_batch_homework @is_student_batch_homework = true - all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = 0) AS m_score - FROM homework_attaches - INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id - WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY m_score DESC") + all_homework_list = get_student_batch_homework_list @bid,User.current @cur_page = params[:page] || 1 @cur_type = 4 @homework_list = paginateHelper all_homework_list,10 diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index 4744df624..c41ba54ee 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -119,4 +119,15 @@ module HomeworkAttachHelper #end ary end + + def get_student_batch_homework_list bid,user + student_batch_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = 0) AS m_score + FROM homework_attaches + INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id + WHERE homework_attaches.bid_id = #{bid.id} AND homework_evaluations.user_id = #{user.id} ORDER BY m_score DESC") + student_batch_homework_list + end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 7e3b2a545..41b6f2c68 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -1,6 +1,7 @@ class CoursesService include ApplicationHelper include CoursesHelper + include HomeworkAttachHelper #TODO:尚未整合权限系统 #参数school_id为0或不传时返回所有课程,否则返回对应学校的课程 #参数per_page_count分页功能,每页显示的课程数 @@ -306,10 +307,8 @@ class CoursesService bids = course.homeworks.order('deadline DESC') bids = bids.like(params[:name]) if params[:name].present? homeworks = [] - if is_course_teacher(current_user,course) - bids.each do |bid| - homeworks << show_homework_info(course,bid) - end + bids.each do |bid| + homeworks << show_homework_info(course,bid,current_user,is_course_teacher(current_user,course)) end homeworks else @@ -318,7 +317,7 @@ class CoursesService end private - def show_homework_info course,bid + def show_homework_info course,bid,current_user,is_course_teacher author = bid.author.lastname + bid.author.firstname many_times = course.homeworks.index(bid) + 1 name = bid.name @@ -327,8 +326,27 @@ class CoursesService description = bid.description #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 state = bid.comment_status + unless is_course_teacher + homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user + end #end open_anonymous_evaluation = bid.open_anonymous_evaluation + {:course_name => course.name,:id => bid.id, :course_teacher => author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments} + end + + #显示作业列表的同时显示分配给当前学生匿评的作业 + def show_homework_info_with_batch course,bid + author = bid.author.lastname + bid.author.firstname + many_times = course.homeworks.index(bid) + 1 + name = bid.name + homework_count = bid.homeworks.count #已提交的作业数量 + student_questions_count = bid.commit.nil? ? 0 : bid.commit + description = bid.description + #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 + state = bid.comment_status + #end + open_anonymous_evaluation = bid.open_anonymous_evaluation {:course_name => course.name,:id => bid.id, :course_teacher => author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation} end From 2f168dd4d70c8749430ada789ab7f8d7a1bfbfde Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 30 Jan 2015 17:47:57 +0800 Subject: [PATCH 23/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8A=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=8A=A8=E6=80=81=E3=80=8B=E6=A0=B7=E5=BC=8F=20Signed?= =?UTF-8?q?-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- app/views/courses/show.html.erb | 2 +- config/application.rb | 3 ++- lib/email_verifier | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) create mode 160000 lib/email_verifier diff --git a/Gemfile b/Gemfile index afd6a667a..037c606c8 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem "builder", "3.0.0" gem 'acts-as-taggable-on', '2.4.1' gem 'spreadsheet' gem 'ruby-ole' -#gem 'email_verifier' +#gem 'email_verifier', path: 'lib/email_verifier' group :development do gem 'grape-swagger' diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 9f0084019..9c91908d2 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -90,7 +90,7 @@ - + <%= l :label_create_time %>: <%= format_time(@course.created_at) %> diff --git a/config/application.rb b/config/application.rb index 311bf457b..c7f2f3ea5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -16,7 +16,7 @@ module RedmineApp # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - # verifier if email is real + #verifier if email is real # EmailVerifier.config do |config| # config.verifier_email = "lizanle521@126.com" # end @@ -74,5 +74,6 @@ module RedmineApp if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb')) instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb')) end + end end diff --git a/lib/email_verifier b/lib/email_verifier new file mode 160000 index 000000000..3cabcc643 --- /dev/null +++ b/lib/email_verifier @@ -0,0 +1 @@ +Subproject commit 3cabcc643f36939939685e6f55273dfbf89da545 From be9ff9b4bbe273e72009d480d1b02561b10af081 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 30 Jan 2015 17:58:41 +0800 Subject: [PATCH 24/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8=E5=90=8D=20=E8=A7=A3=E5=86=B3=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=AD=E4=BC=81=E4=B8=9A=E9=87=8D=E5=90=8D=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/enterprises_controller.rb | 6 ------ app/controllers/originizations_controller.rb | 6 ++++++ app/controllers/welcome_controller.rb | 8 ++++---- ...{enterprises_helper.rb => originizations_helper.rb} | 0 .../{enterprises => originizations}/index.html.erb | 2 +- app/views/welcome/index.html.erb | 10 +++++----- config/routes.rb | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 app/controllers/enterprises_controller.rb create mode 100644 app/controllers/originizations_controller.rb rename app/helpers/{enterprises_helper.rb => originizations_helper.rb} (100%) rename app/views/{enterprises => originizations}/index.html.erb (83%) diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb deleted file mode 100644 index c15b6dc8f..000000000 --- a/app/controllers/enterprises_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class EnterprisesController < ApplicationController - layout 'project_base' - def index - @enterprises = Project.find_by_sql("select enterprise_name from projects") - end -end diff --git a/app/controllers/originizations_controller.rb b/app/controllers/originizations_controller.rb new file mode 100644 index 000000000..033f9d8ec --- /dev/null +++ b/app/controllers/originizations_controller.rb @@ -0,0 +1,6 @@ +class OriginizationsController < ApplicationController + layout 'project_base' + def index + @enterprises = Project.find_by_sql("select distinct(enterprise_name) from projects") + end +end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 6c28ec502..b1138f964 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -25,10 +25,10 @@ class WelcomeController < ApplicationController before_filter :entry_select, :only => [:index] def index - unless params[:enterprise].nil? - @enterprise = params[:enterprise] - @enterprise_projects = Project.find_by_sql(["select * from projects where enterprise_name =? ", @enterprise]) - @e_count = @enterprise_projects.count + unless params[:originization].nil? + @originization = params[:originization] + @originization_projects = Project.find_by_sql(["select * from projects where enterprise_name =? ", @originization]) + @e_count = @originization_projects.count if @e_count < 10 part_count = 10 -@e_count # @part_projects = find_all_hot_project part_count, order diff --git a/app/helpers/enterprises_helper.rb b/app/helpers/originizations_helper.rb similarity index 100% rename from app/helpers/enterprises_helper.rb rename to app/helpers/originizations_helper.rb diff --git a/app/views/enterprises/index.html.erb b/app/views/originizations/index.html.erb similarity index 83% rename from app/views/enterprises/index.html.erb rename to app/views/originizations/index.html.erb index 9db8d99ab..002ea84f8 100644 --- a/app/views/enterprises/index.html.erb +++ b/app/views/originizations/index.html.erb @@ -10,7 +10,7 @@ <% unless enterprise.enterprise_name.blank? %>
    • - <%= link_to enterprise.enterprise_name, home_path(:enterprise => enterprise.enterprise_name) %> + <%= link_to enterprise.enterprise_name, home_path(:originization => enterprise.enterprise_name) %>
    <% end %> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index f29f588b0..c53377134 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -77,7 +77,7 @@
      - <% if @enterprise.nil? %> + <% if @originization.nil? %> <% @projects.map do |project| %> <%= render :partial => 'hot_projects_list', :locals => {:project => project} %> <% end; reset_cycle %> @@ -87,9 +87,9 @@

      <%= l(:label_enterprise_tips) %>

      <% @projects.map do |project| %> <%= render :partial => 'hot_projects_list', :locals => {:project => project} %> - <% end; reset_cycle %> + <% end %> <% elsif @e_count < 10 %> - <% @enterprise_projects.map do |project| %> + <% @originization_projects.map do |project| %> <%= render :partial => 'hot_projects_list', :locals => {:project => project} %> <% end %>

      <%= l(:label_part_enterprise_tips) %>

      @@ -100,8 +100,8 @@ <% @part_projects.map do |project| %> <%= render :partial => 'hot_projects_list', :locals => {:project => project} %> <% end %> - <% end; reset_cycle %> - <% end; reset_cycle %> + <% end %> + <% end %>
    diff --git a/config/routes.rb b/config/routes.rb index aad7adcb3..1b79a737d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,7 +26,7 @@ # Example: :via => :get ====> :via => :get RedmineApp::Application.routes.draw do - get "enterprises/index" + get "originizations/index" #match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index' @@ -390,7 +390,7 @@ RedmineApp::Application.routes.draw do match '/statistics', :to => 'projects#statistics', :as => 'statistics', :via => :get # match '/investor', :controller => 'projects', :action => 'investor', :as => 'investor', :via => :get match '/homework', :to => 'projects#homework', :as => 'homework', :via => :get - match 'enterprise', :to => 'enterprises#index', :as => 'index', :via => :get + match 'originizations', :to => 'originizations#index', :as => 'index', :via => :get # match '/activity', :controller => 'activities', :action => 'index', :as => 'activity', :via => :get # match '/repository', :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil, :as => 'repository', :via => :get