From 617649129e9443fec65649caece21e9bb1404330 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 May 2016 11:20:14 +0800 Subject: [PATCH 1/8] Gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index da3b3b4d7..a599613ba 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end -#gem 'certified' +gem 'certified' gem 'wechat',path: 'lib/wechat' gem 'grack', path:'lib/grack' From 3b3cafbc81e0daba276025233336a58d87f9f4f1 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 May 2016 14:49:49 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9A=84=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 6 +++--- app/controllers/student_work_controller.rb | 2 +- app/models/homework_common.rb | 16 ++++++++-------- app/models/message.rb | 4 ++-- app/models/news.rb | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 689ef2bd7..0566d3d98 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -291,9 +291,9 @@ class HomeworkCommonController < ApplicationController def open_student_works if @homework.is_open == 0 - @homework.update_attribute(:is_open, 1) + @homework.update_column('is_open', 1) else - @homework.update_attribute(:is_open, 0) + @homework.update_column('is_open', 0) end @user_activity_id = params[:user_activity_id] @is_in_course = params[:is_in_course] if params[:is_in_course] @@ -440,7 +440,7 @@ class HomeworkCommonController < ApplicationController puts time s_time = time if format_time(time) > format_time(h.updated_at) - h.update_attribute(:updated_at, s_time) + h.update_column('updated_at', s_time) end end end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index deab2feb6..c3d7dbbc6 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -814,7 +814,7 @@ class StudentWorkController < ApplicationController stu_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a") @work.student_score = stu_score.first.score.try(:round, 2).to_f end - @homework.update_attributes(:updated_at => Time.now) + @homework.update_column('updated_at', Time.now) update_course_activity(@homework.class,@homework.id) update_user_activity(@homework.class,@homework.id) update_org_activity(@homework.class,@homework.id) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index f11a48a80..e4426e78f 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -29,8 +29,8 @@ class HomeworkCommon < ActiveRecord::Base :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} - after_create :act_as_activity, :send_mail - after_update :update_activity + after_create :act_as_activity, :send_mail,:act_as_course_message + after_update :update_activity, :wechat_message after_save :act_as_course_activity after_destroy :delete_kindeditor_assets @@ -59,12 +59,12 @@ class HomeworkCommon < ActiveRecord::Base else self.course.members.each do |m| # if m.user_id != self.user_id - self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) - #count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count - #if count == 0 - # ws = WechatService.new - # ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") - #end + #self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count + if count == 0 + ws = WechatService.new + ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + end # end end end diff --git a/app/models/message.rb b/app/models/message.rb index 7bfb9d80e..fdc3c6bdc 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -274,7 +274,7 @@ class Message < ActiveRecord::Base else # 回帖 parent_author_id = Message.find(self.parent_id).author_id if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 - #self.course_messages << CourseMessage.new(:user_id => parent_author_id, :course_id => self.board.course_id, :viewed => false) + self.course_messages << CourseMessage.new(:user_id => parent_author_id, :course_id => self.board.course_id, :viewed => false) count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count if count == 0 content = strip_html self.content.html_safe, 200 @@ -297,7 +297,7 @@ class Message < ActiveRecord::Base else # 回帖 parent_author_id = Message.find(self.parent_id).author_id if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 - #self.forge_messages << ForgeMessage.new(:user_id => parent_author_id, :project_id => self.board.project_id, :viewed => false) + self.forge_messages << ForgeMessage.new(:user_id => parent_author_id, :project_id => self.board.project_id, :viewed => false) count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count if count == 0 content = strip_html self.content.html_safe, 200 diff --git a/app/models/news.rb b/app/models/news.rb index f0457dc81..1544faf61 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -62,7 +62,7 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score + after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score, :act_as_system_message after_update :update_activity after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score @@ -169,7 +169,7 @@ class News < ActiveRecord::Base if self.course self.course.members.each do |m| if m.user_id != self.author_id - self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + #self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count if count == 0 ws = WechatService.new From 670b2c48c7fc9e90344476dab512d82e58f6cf35 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 May 2016 16:08:40 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E7=9A=84=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=B6=88=E6=81=AF=E8=A6=81=E7=BB=86=E5=8C=96=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/issue.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index d5d148117..b5e87feea 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -164,7 +164,20 @@ class Issue < ActiveRecord::Base count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count if m.user_id != self.author_id && count == 0 ws = WechatService.new - content = strip_html self.project.name + " 有新缺陷了:" + self.subject.html_safe, 200 + str = " 有新缺陷了: " + case self.tracker_id + when 1 + str = " 有新缺陷了: " + when 2 + str = " 有新功能了: " + when 3 + str = " 有新支持了: " + when 4 + str = " 有新任务了: " + when 5 + str = " 有新周报了: " + end + content = strip_html self.project.name + str + self.subject.html_safe, 200 ws.message_update_template m.user_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) end end From 31d94dc0528fab9d66497b019ddf0218fd43b710 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 May 2016 16:28:43 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=8F=AF=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E4=BD=9C=E4=B8=9A=E8=87=B3=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=EF=BC=8C=E4=BD=9C=E4=B8=9A=E7=9A=84=E5=8E=9F=E4=BD=9C=E8=80=85?= =?UTF-8?q?=E4=B8=8D=E5=BA=94=E6=94=B6=E5=88=B0=E5=BE=AE=E4=BF=A1=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a81ade3fa..373801963 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -589,7 +589,7 @@ class UsersController < ApplicationController new_homework.homework_detail_programing.save if new_homework.homework_detail_programing new_homework.homework_detail_group.save if new_homework.homework_detail_group end - homework.update_attribute(:quotes, homework.quotes+1) + homework.update_column(:quotes, homework.quotes+1) end @homework = homework respond_to do |format| @@ -862,7 +862,7 @@ class UsersController < ApplicationController student_work.save send_message_to_teacher(student_work) - homework.update_attributes(:updated_at => Time.now) + homework.update_column(:updated_at, Time.now) update_course_activity(homework.class,homework.id) update_user_activity(homework.class,homework.id) update_org_activity(homework.class,homework.id) @@ -950,7 +950,7 @@ class UsersController < ApplicationController homework_detail_group.save if homework_detail_group if params[:quotes] && !params[:quotes].blank? quotes_homework = HomeworkCommon.find params[:quotes].to_i - quotes_homework.update_attribute(:quotes, quotes_homework.quotes+1) + quotes_homework.update_column(:quotes, quotes_homework.quotes+1) end if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => homework.course_id) From 0f2f4717b6f6aa40792ab5e1bce3fdbadfa76e75 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 May 2016 13:50:45 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=8F=E5=8F=B7=E5=92=8C=E7=BF=BB=E9=A1=B5?= =?UTF-8?q?=E3=80=81=E6=8C=89=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E5=80=92?= =?UTF-8?q?=E6=8E=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 5 +++-- app/helpers/application_helper.rb | 11 +++++++++++ app/views/homework_common/index.html.erb | 6 ++++++ app/views/users/_user_homework_detail.html.erb | 7 ++++++- app/views/users/_user_homework_list.html.erb | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 0566d3d98..9da4b90b9 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -20,15 +20,16 @@ class HomeworkCommonController < ApplicationController @page = params[:page] ? params[:page].to_i + 1 : 0 @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) if @is_teacher - @homeworks = @course.homework_commons.order("updated_at desc").limit(10).offset(@page * 10) + #@homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10) @homework_commons = @course.homework_commons.order("created_at desc") else - @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("updated_at desc").limit(10).offset(@page * 10) + #@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10) @homework_commons = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc") end @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) @is_new = params[:is_new] + @homeworks = paginateHelper @homework_commons,10 #设置at已读 @homeworks.each do |homework| homework.journals_for_messages.each do |j| diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 229aceb1c..7d970c762 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3248,3 +3248,14 @@ def strip_html(text,len=0,endss="...") end return ss end + +def get_hw_index(hw,is_teacher) + if is_teacher + homeworks = hw.course.homework_commons.order("created_at asc") + else + homeworks = hw.course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc") + end + hw_ids = homeworks.map{|hw| hw.id} if !homeworks.empty? + index = hw_ids.index(hw.id) + return index +end diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index e34cf0736..29cff8933 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -73,6 +73,12 @@ <% end%> <%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homeworks,:page => 0,:is_in_course => 1,:course_id => @course.id} %> +
+
    + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
+
+
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index decaba88c..c0578c042 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -11,7 +11,12 @@ <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%> <% if homework_common.homework_detail_manual%> diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index e42c5d8b2..f7669047c 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -31,7 +31,7 @@ <% if homework_commons.count == 10%> <% if is_in_course == 1%> - <%= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> + <%#= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> <% else%> <%= link_to "点击展开更多",student_homeworks_user_path(User.current.id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> From 05a475e47ea8bdeeb070b2a04a61411e9a922a74 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 May 2016 14:35:40 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=B8=AD=E4=B8=8D=E5=BA=94=E5=87=BA=E7=8E=B0=E5=B7=B2=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=9A=84=E9=A1=B9=E7=9B=AE=E5=92=8C=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 94ee14a56..ae60d548a 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -33,8 +33,8 @@ module Mobile shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) page = params[:page] ? params[:page] : 0 - user_project_ids = (user.projects.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")" - user_course_ids = (user.courses.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")" + user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course')" project_types = "('Message','Issue','ProjectCreateInfo')" principal_types = "JournalsForMessage" From 6517f23f03e727599ee39aeacc3e64df182b0ba1 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 May 2016 15:26:23 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=A1=B9=E7=9B=AE=E7=9A=84=E5=88=9B=E5=BB=BA=E5=8A=A8?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 2 +- app/api/mobile/entities/activity.rb | 6 +++--- app/controllers/organizations_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/controllers/wechats_controller.rb | 2 +- app/models/course_activity.rb | 3 +-- app/models/forge_activity.rb | 2 +- app/views/organizations/_org_activities.html.erb | 2 +- app/views/organizations/_org_project_activities.html.erb | 2 +- app/views/users/_user_activities.html.erb | 4 ++-- db/migrate/20160519070718_change_user_activities_data.rb | 9 +++++++++ db/schema.rb | 3 ++- 12 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20160519070718_change_user_activities_data.rb diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index ae60d548a..cbd43bb79 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -36,7 +36,7 @@ module Mobile user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")" user_course_ids = (user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course')" - project_types = "('Message','Issue','ProjectCreateInfo')" + project_types = "('Message','Issue','Project')" principal_types = "JournalsForMessage" watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(',')) user_ids = "(" + user.id.to_s + watched_user_ids + ")" diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 20876bf69..3eab332a7 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -14,7 +14,7 @@ module Mobile else case f when :user_act - if ac.act_type == "ProjectCreateInfo" + if ac.act_type == "Project" ac unless ac.nil? else ac.act unless ac.nil? || ac.act.nil? @@ -87,7 +87,7 @@ module Mobile "项目缺陷" when "Message" "项目讨论区" - when "ProjectCreateInfo" + when "Project" "项目" end end @@ -101,7 +101,7 @@ module Mobile expose :container_type #课程/项目/博客/个人 expose :author, using: Mobile::Entities::User do |a, opt| #用户信息 if a.is_a? ::UserActivity - if a.act_type == "ProjectCreateInfo" + if a.act_type == "Project" get_user(get_project(a.act_id).user_id) elsif !a.act.nil? if a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment' diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index c94f734e1..1946378ef 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -127,7 +127,7 @@ class OrganizationsController < ApplicationController case params[:type] when nil @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + - "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ + "or (container_type ='Project' and org_act_type in ('Issue','Message','Project') and container_id in (#{project_ids.join(',')})) "+ "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) when 'project_issue' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 373801963..6f3aa6b18 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1373,7 +1373,7 @@ class UsersController < ApplicationController user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" user_course_ids = (@user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course','JournalsForMessage')" - project_types = "('Message','Issue','ProjectCreateInfo')" + project_types = "('Message','Issue','Project')" principal_types = "JournalsForMessage" if params[:type].present? case params[:type] diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 0d75636f7..a9e4771e8 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -211,7 +211,7 @@ class WechatsController < ActionController::Base user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course')" - project_types = "('Message','Issue','ProjectCreateInfo')" + project_types = "('Message','Issue','Project')" principal_types = "JournalsForMessage" blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 96ec6e355..2aae45d0a 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -5,8 +5,7 @@ class CourseActivity < ActiveRecord::Base belongs_to :course belongs_to :user has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity, :add_org_activity - after_create :add_course_lead + after_create :add_course_lead,:add_user_activity, :add_org_activity before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index c044392a0..44b13b315 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -20,7 +20,7 @@ class ForgeActivity < ActiveRecord::Base validates :forge_act_id,presence: true validates :forge_act_type, presence: true has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity, :add_org_activity + after_create :add_user_activity, :add_org_activity before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index a3e62fd16..c00cc6161 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -56,7 +56,7 @@ <%= render :partial => 'organizations/org_project_issue', :locals => {:activity => Issue.find(act.org_act_id),:user_activity_id =>act.id} %> <% when 'Message' %> <%= render :partial => 'organizations/project_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %> - <% when 'ProjectCreateInfo'%> + <% when 'Project'%> <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> <% end %> <% end %> diff --git a/app/views/organizations/_org_project_activities.html.erb b/app/views/organizations/_org_project_activities.html.erb index b46996661..d27e690c6 100644 --- a/app/views/organizations/_org_project_activities.html.erb +++ b/app/views/organizations/_org_project_activities.html.erb @@ -6,7 +6,7 @@ <%= render :partial => 'organizations/org_project_issue', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> <% when 'Message' %> <%= render :partial => 'organizations/project_message', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> - <% when 'ProjectCreateInfo'%> + <% when 'Project'%> <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> <% end %> <% end %> diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index b7df824a4..2fe7315d5 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -54,7 +54,7 @@ sd_create_editor_from_data(<%= user_activity.id %>, null, "100%", "<%= user_activity.class.to_s %>"); }); - <% if user_activity.act_type == "ProjectCreateInfo" %> + <% if user_activity.act_type == "Project" %> <%= render :partial => 'project_create', :locals => {:activity => user_activity,:user_activity_id =>user_activity.id} %> <% else %> <% act= user_activity.act %> @@ -94,7 +94,7 @@ <%# end %> <% when 'Message' %> <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %> - <% when 'ProjectCreateInfo'%> + <% when 'Project'%> <%# cache (act) do %> <%= render :partial => 'project_create', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <%# end %> diff --git a/db/migrate/20160519070718_change_user_activities_data.rb b/db/migrate/20160519070718_change_user_activities_data.rb new file mode 100644 index 000000000..1a1bfb827 --- /dev/null +++ b/db/migrate/20160519070718_change_user_activities_data.rb @@ -0,0 +1,9 @@ +class ChangeUserActivitiesData < ActiveRecord::Migration + def up + execute("update user_activities set act_type = 'Project' where act_type = 'ProjectCreateInfo'") + execute("update org_activities set org_act_type = 'Project' where org_act_type = 'ProjectCreateInfo'") + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 43153fb76..9c4b4b333 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,8 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160511055221) do +ActiveRecord::Schema.define(:version => 20160519070718) do + create_table "activities", :force => true do |t| t.integer "act_id", :null => false t.string "act_type", :null => false From 3ebef0eae239955a499315a859054caeb19b1941 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 May 2016 15:57:20 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=B8=AD=E7=94=B3=E8=AF=B7=E5=BC=95=E7=94=A8=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E7=94=A8=E6=88=B7=E7=82=B9=E5=87=BB=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E7=9A=84=E6=B6=88=E6=81=AF=E6=89=93=E5=BC=80=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=9D=83=E9=99=90=E8=AE=BF=E9=97=AE=E7=9A=84=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 8 ++++++-- public/stylesheets/new_user.css | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index bab7bb5ec..d46c45593 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -240,14 +240,18 @@
  • <%= link_to ma.course_message.user.show_name, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> - "><%= ma.apply_result == 1 ? '同意' : '拒绝'%>引用作业: + <%= ma.apply_result == 1 ? '同意' : '拒绝'%>引用作业:
  • <% link_str = ma.apply_result == 1 ? '您申请引用作业"'+HomeworkCommon.find(ma.course_message_id).name+'"的申请已通过' : '您申请引用作业"'+HomeworkCommon.find(ma.course_message_id).name+'"的申请被拒绝' %> - <%= link_to link_str, student_work_index_path(:homework => ma.course_message.id), :title => link_str,:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey "}", :target => '_blank' %> + <% if User.current.member_of_course?(ma.course_message.course) || User.current.admin? || ma.course_message.is_open == 1 %> + <%= link_to link_str, student_work_index_path(:homework => ma.course_message.id), :title => link_str,:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey "}", :target => '_blank' %> + <% else %> + <%=link_str %> + <% end %> diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 44e64e9ab..89712c89f 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -637,6 +637,7 @@ a.replyGrey1:hover {color:#4b4b4b;} a.newsBlue {color:#269ac9;} a.newsBlue:hover {color:#297fb8;} a.newsBlack {color:#4b4b4b; font-size:13px; font-weight:bold} +span.newsBlack {color:#4b4b4b; font-size:13px; font-weight:bold} a.menuGrey {color:#808080;} a.menuGrey:hover {color:#fe7d68;} .navSearchTypeBox {width:368px; height:35px; position:absolute; border:1px solid #e1e1e1; background-color:#ffffff; padding-left:10px; display:none; color:#3e3e3e; font-size:14px;}