From e2c0237fcd8b75358242b1247806cb05a406bf62 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 30 Aug 2016 15:30:01 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=A9=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20160511055221_merge_two_homeworks.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/db/migrate/20160511055221_merge_two_homeworks.rb b/db/migrate/20160511055221_merge_two_homeworks.rb index a30bc983b..42aabbbd9 100644 --- a/db/migrate/20160511055221_merge_two_homeworks.rb +++ b/db/migrate/20160511055221_merge_two_homeworks.rb @@ -6,13 +6,17 @@ class MergeTwoHomeworks < ActiveRecord::Migration work.update_column('homework_common_id', 3463) end end - homework = HomeworkCommon.find 3387 - homework.destroy if homework - stu_works = StudentWork.where("homework_common_id = 3387") - stu_work_ids = stu_works.empty? ? "(-1)" : "(" + stu_works.map{|work| work.id}.join(',') + ")" - stu_work_tests = StudentWorkTest.where("student_work_id in #{stu_work_ids}") - stu_work_tests.destroy_all if stu_work_tests - stu_works.destroy_all if stu_works + begin + homework = HomeworkCommon.find 3387 + homework.destroy if homework + stu_works = StudentWork.where("homework_common_id = 3387") + stu_work_ids = stu_works.empty? ? "(-1)" : "(" + stu_works.map{|work| work.id}.join(',') + ")" + stu_work_tests = StudentWorkTest.where("student_work_id in #{stu_work_ids}") + stu_work_tests.destroy_all if stu_work_tests + stu_works.destroy_all if stu_works + rescue Exception => e + puts e + end end def down From 6d0f22fd60589771950e2413ff5fe9338ba87464 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 30 Aug 2016 16:03:28 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=A9=BA=E6=95=B0=E6=8D=AE=E5=BA=93--?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E5=88=A0=E9=99=A4issue?= =?UTF-8?q?=E6=A0=87=E7=AD=BE500=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/tracker.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/tracker.rb b/app/models/tracker.rb index af56d23bf..4ef18b7b0 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -34,7 +34,7 @@ class Tracker < ActiveRecord::Base end has_and_belongs_to_many :projects - has_and_belongs_to_many :courses + # has_and_belongs_to_many :courses has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id' acts_as_list From f4632c432fb6c85c22febe8041080a68e7aa96c3 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 30 Aug 2016 17:11:22 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=AD=E7=9A=84at=E6=B6=88=E6=81=AF=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 8 ++++---- .../20160830090214_delete_null_at_messages.rb | 17 +++++++++++++++++ db/schema.rb | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20160830090214_delete_null_at_messages.rb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index b0c83e869..caf0b4bda 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -521,10 +521,10 @@ class IssuesController < ApplicationController def delete_journal @issue = Issue.find(params[:id]) begin - forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id]).first - forge_acts.destroy unless forge_acts.nil? - at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id]).first - at_message.destroy unless at_message.nil? + forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id]) + forge_acts.destroy_all unless forge_acts.empty? + at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id]) + at_message.destroy_all unless at_message.empty? Journal.delete(params[:journal_id]) rescue Exception => e puts e diff --git a/db/migrate/20160830090214_delete_null_at_messages.rb b/db/migrate/20160830090214_delete_null_at_messages.rb new file mode 100644 index 000000000..304a6bc4e --- /dev/null +++ b/db/migrate/20160830090214_delete_null_at_messages.rb @@ -0,0 +1,17 @@ +class DeleteNullAtMessages < ActiveRecord::Migration + def up + count = AtMessage.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + AtMessage.page(i).per(30).each do |am| + if am.at_message.nil? + am.destroy + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 414f2d2be..b5bd5f778 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 => 20160824073554) do +ActiveRecord::Schema.define(:version => 20160830090214) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 936198a8bda1eb3b0e7274a7966d720f654fe2fc Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 31 Aug 2016 10:30:23 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=9A=90=E8=97=8F=E9=9D=9E=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 7 +++++++ app/views/layouts/_footer.html.erb | 4 +++- app/views/layouts/_logined_header.html.erb | 12 +++++++----- app/views/layouts/base_projects.html.erb | 5 +++-- app/views/layouts/base_users_new.html.erb | 1 + app/views/layouts/new_base.html.erb | 4 +++- app/views/layouts/new_base_user.html.erb | 8 ++++---- app/views/users/_selector_for_messages.html.erb | 3 ++- app/views/users/_user_resource_type_filter.html.erb | 10 ++++++---- app/views/users/show.html.erb | 4 +--- app/views/users/user_messages.html.erb | 4 +++- 11 files changed, 40 insertions(+), 22 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2d6e84762..72963c15c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -37,6 +37,13 @@ module ApplicationHelper # super # end + # 隐藏项目以外的信息 + # return: true 显示,false 不显示 + def hidden_unproject_infos + hidden_info = Setting.find_by_name("hidden_non_project") + (hidden_info && hidden_info.value == "1") ? true : false + end + # 通过系统外部邮箱查找用户,如果用户不存在则用邮箱替换 def get_user_by_mail mail user = User.find_by_mail(mail) diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index a639e1203..e549473e7 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -4,7 +4,9 @@
  • <%= l(:label_about_us)%>|
  • 服务协议|
  • -
  • <%= link_to l(:label_surpport_group), "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168", :class => "f_grey mw20", :target=>"_blank" %>|
  • + <% if hidden_unproject_infos %> +
  • <%= link_to l(:label_surpport_group), "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168", :class => "f_grey mw20", :target=>"_blank" %>|
  • + <% end %>
  • <%= l(:label_forums)%>
  • diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 753022d75..1f35c4728 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -10,12 +10,14 @@ - - + + + <% end %> +<% if hidden_unproject_infos %> + <%= render :partial => 'layouts/new_feedback' %> +<% end %> -
    123
    -<%= render :partial => 'layouts/new_feedback' %> diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb index c1f6a5644..976de8235 100644 --- a/app/views/layouts/base_users_new.html.erb +++ b/app/views/layouts/base_users_new.html.erb @@ -298,6 +298,7 @@
    + <%= render :partial => 'layouts/new_feedback' %> diff --git a/app/views/layouts/new_base.html.erb b/app/views/layouts/new_base.html.erb index e9703a943..d28171f5f 100644 --- a/app/views/layouts/new_base.html.erb +++ b/app/views/layouts/new_base.html.erb @@ -59,7 +59,9 @@
    <%= render :partial => 'layouts/footer' %>
    -<%= render :partial => 'layouts/new_feedback' %> +<% if hidden_unproject_infos %> + <%= render :partial => 'layouts/new_feedback' %> +<% end %> diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index d1084c794..20754b0ff 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -157,9 +157,7 @@
    - <% hidden_courses = Setting.find_by_name("hidden_courses") %> - <% unvisiable = hidden_courses && hidden_courses.value == "1"%> - <% if !unvisiable %> + <% if hidden_unproject_infos %>
    • <%= link_to '班级',{:controller => "users", :action => "user_courselist", :id => @user.id}, :id => "user_course_list" %> @@ -220,7 +218,9 @@ <%= yield %>
    - <%= render :partial => 'layouts/new_feedback' %> + <% if hidden_unproject_infos %> + <%= render :partial => 'layouts/new_feedback' %> + <% end %>
    <%= render :partial => 'layouts/footer' %> diff --git a/app/views/users/_selector_for_messages.html.erb b/app/views/users/_selector_for_messages.html.erb index 3727e4a1d..14609f4fc 100644 --- a/app/views/users/_selector_for_messages.html.erb +++ b/app/views/users/_selector_for_messages.html.erb @@ -3,6 +3,7 @@
      • + <% if hidden_unproject_infos %>
        • 课程消息
        • @@ -12,7 +13,7 @@
        • <%= link_to "班级问卷", user_message_path(User.current, :type => 'poll'), :class => "homepagePostTypeQuiz postTypeGrey" %>
      • - + <% end %>
        • 项目消息
        • diff --git a/app/views/users/_user_resource_type_filter.html.erb b/app/views/users/_user_resource_type_filter.html.erb index 633e52472..2322c87cb 100644 --- a/app/views/users/_user_resource_type_filter.html.erb +++ b/app/views/users/_user_resource_type_filter.html.erb @@ -4,10 +4,12 @@
        • 全部
        • -
        • - 班级资源 - <%#= link_to '课程资源' ,user_resource_user_path(:id => @user.id, :type => 2), id="resource_type_course", :remote => true, :method => 'get', :class=> 'homepagePostTypeAssignment postTypeGrey' %> -
        • + <% if hidden_unproject_infos %> +
        • + 班级资源 + <%#= link_to '课程资源' ,user_resource_user_path(:id => @user.id, :type => 2), id="resource_type_course", :remote => true, :method => 'get', :class=> 'homepagePostTypeAssignment postTypeGrey' %> +
        • + <% end %>
        • 项目资源 <%#= link_to '项目资源' ,user_resource_user_path(:id => @user.id, :type => 3), id="resource_type_project", :remote => true, :method => 'get', :class => 'homepagePostTypeQuiz postTypeGrey' %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 9acffce3d..e26113673 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -7,9 +7,7 @@
            • - <% hidden_courses = Setting.find_by_name("hidden_courses") %> - <% unvisiable = hidden_courses && hidden_courses.value == "1"%> - <% if !unvisiable %> + <% if hidden_unproject_infos %>
            • 课程动态
            • <%= link_to "作业动态", {:controller => "users", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%>
            • diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 2baa9f2f2..578e97b9a 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -21,7 +21,9 @@ <%= render :partial => 'users/user_at_message', :locals => {:ma => ma} %> <%# 课程消息 %> - <%= render :partial => 'users/user_message_course', :locals => {:ma => ma} %> + <% if hidden_unproject_infos %> + <%= render :partial => 'users/user_message_course', :locals => {:ma => ma} %> + <% end %> <%= render :partial => 'users/user_message_forge', :locals => {:ma => ma} %>