From 21f81a931afc105bde4d15c0bea6165e8054c4a0 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 11 Aug 2015 11:26:22 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E7=9A=84=E2=80=9C=E6=96=B0=E5=BB=BA=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E2=80=9D=E2=80=9C=E6=96=B0=E5=BB=BA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E2=80=9D=E2=80=9C=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E2=80=9D?= =?UTF-8?q?=E2=80=9D=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E2=80=9C=E7=9A=84?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/show.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e53d734c6..b2e6258ee 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -5,14 +5,14 @@ <% if @user.allowed_to?(:add_project, nil, :global => true) %> 新建项目 <% else %> - 加入项目 + 加入项目 <% end %> <% if @user.user_extensions.identity == 0 && @user.allowed_to?(:add_course, nil, :global => true) %> - 新建课程 + 新建课程 <% else %> - 加入课程 + 加入课程 <% end %>
From a87269298457474cc5e27d01644b9d6f1d6f4462 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 11 Aug 2015 14:49:32 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E4=B8=BAactivities=E8=A1=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0created=5Fat=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/projects/en.yml | 6 +++--- ...0810064247_add_created_at_to_activities.rb | 8 +++++++ .../20150811010817_update_activities_data.rb | 21 +++++++++++++++++++ db/schema.rb | 21 +++++++------------ 4 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20150810064247_add_created_at_to_activities.rb create mode 100644 db/migrate/20150811010817_update_activities_data.rb diff --git a/config/locales/projects/en.yml b/config/locales/projects/en.yml index b142c6ca8..703e0878e 100644 --- a/config/locales/projects/en.yml +++ b/config/locales/projects/en.yml @@ -42,10 +42,10 @@ en: label_member: "Members" project_module_attachments: "Resources" - label_project_mail_attachments: Project Resources - label_project_mail_upload: had uploaded project resources + label_project_mail_attachments: "Project Resources" + label_project_mail_upload: "had uploaded project resources" - label_invite: Invitation + label_invite: "Invitation" label_invite_new_user: "Send email to invite new user" label_invite_trustie_user: "Invite the Trustie registered user" diff --git a/db/migrate/20150810064247_add_created_at_to_activities.rb b/db/migrate/20150810064247_add_created_at_to_activities.rb new file mode 100644 index 000000000..864ed82d6 --- /dev/null +++ b/db/migrate/20150810064247_add_created_at_to_activities.rb @@ -0,0 +1,8 @@ +class AddCreatedAtToActivities < ActiveRecord::Migration + def up + add_column :activities, :created_at, :timestamp + end + def end + remove_column :activities, :created_at + end +end diff --git a/db/migrate/20150811010817_update_activities_data.rb b/db/migrate/20150811010817_update_activities_data.rb new file mode 100644 index 000000000..de4a080f2 --- /dev/null +++ b/db/migrate/20150811010817_update_activities_data.rb @@ -0,0 +1,21 @@ +class UpdateActivitiesData < ActiveRecord::Migration + def up + count = Activity.all.count / 10 + 1 + transaction do + for i in 1 ... count do i + Activity.all.each do |activity| + type = activity.act_type + if type=='Contest' || type=='Message' || type=='News'|| type=='Journal'|| type=='Issue'|| type=='Principal'||type=='JournalsForMessage' + activity.created_at = activity.act.created_on if activity.act + elsif type=='Contestnotification' || type=='HomeworkCommon' || type=='Poll' + activity.created_at = activity.act.created_at if activity.act + end + activity.save + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 30ca29d12..db9b9ff9b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,14 +11,15 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150801034945) do +ActiveRecord::Schema.define(:version => 20150810064247) do create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - t.integer "activity_container_id" - t.string "activity_container_type", :default => "" + t.integer "act_id", :null => false + t.string "act_type", :null => false + t.integer "user_id", :null => false + t.integer "activity_container_id" + t.string "activity_container_type", :default => "" + t.datetime "created_at" end add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" @@ -454,13 +455,6 @@ ActiveRecord::Schema.define(:version => 20150801034945) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -863,6 +857,7 @@ ActiveRecord::Schema.define(:version => 20150801034945) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" + t.datetime "updated_on" end add_index "news", ["author_id"], :name => "index_news_on_author_id" From 5cf6b7e76afc83018bd71e5e5905418db210d73d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 09:38:24 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=97=B6=E9=97=B4--->=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 7159c3c83..6eb722981 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -24,7 +24,7 @@ <%= course_activity_desc activity%>
- <%= l :label_activity_time %> : <%= format_time(activity.created_at) %> + <%= activity.course_act_type == "Course" ? l(:label_create_time) : l(:label_activity_time) %> : <%= format_time(activity.created_at) %>

<%= link_to_attachments_course(activity.course_act) if activity.course_act_type.to_s == "News" %> From 35d6c76a8e99ba2a9d5487e29ba1726501f6a935 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 13:55:46 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E9=83=A8=E5=88=86=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50811083234_update_course_activity_time.rb | 22 ------------------- .../20150814024425_change_attachment_time.rb | 13 +++++++++++ ...50814031258_update_course_activity_time.rb | 22 +++++++++++++++++++ db/schema.rb | 2 +- 4 files changed, 36 insertions(+), 23 deletions(-) delete mode 100644 db/migrate/20150811083234_update_course_activity_time.rb create mode 100644 db/migrate/20150814024425_change_attachment_time.rb create mode 100644 db/migrate/20150814031258_update_course_activity_time.rb diff --git a/db/migrate/20150811083234_update_course_activity_time.rb b/db/migrate/20150811083234_update_course_activity_time.rb deleted file mode 100644 index 9ba8140d8..000000000 --- a/db/migrate/20150811083234_update_course_activity_time.rb +++ /dev/null @@ -1,22 +0,0 @@ -class UpdateCourseActivityTime < ActiveRecord::Migration - def up - count = CourseActivity.all.count / 10 + 1 - transaction do - for i in 1 ... count do i - CourseActivity.page(i).per(10).each do |activity| - if activity.course_act - if activity.course_act.respond_to?("created_at") - activity.created_at = activity.course_act.created_at - elsif activity.course_act.respond_to?("created_on") - activity.created_at = activity.course_act.created_on - end - activity.save - end - end - end - end - end - - def down - end -end diff --git a/db/migrate/20150814024425_change_attachment_time.rb b/db/migrate/20150814024425_change_attachment_time.rb new file mode 100644 index 000000000..fd1ffb7a7 --- /dev/null +++ b/db/migrate/20150814024425_change_attachment_time.rb @@ -0,0 +1,13 @@ +class ChangeAttachmentTime < ActiveRecord::Migration + def up + Attachment.where("container_type = 'Course'").each do |attachment| + if attachment.container && attachment.container.created_at.to_i > attachment.created_on.to_i + attachment.created_on = attachment.container.created_at + 3600 * 24 + attachment.save + end + end + end + + def down + end +end diff --git a/db/migrate/20150814031258_update_course_activity_time.rb b/db/migrate/20150814031258_update_course_activity_time.rb new file mode 100644 index 000000000..155e212a3 --- /dev/null +++ b/db/migrate/20150814031258_update_course_activity_time.rb @@ -0,0 +1,22 @@ +class UpdateCourseActivityTime < ActiveRecord::Migration + def up + count = CourseActivity.all.count / 10 + 1 + transaction do + for i in 1 ... count do i + CourseActivity.page(i).per(10).each do |activity| + if activity.course_act + if activity.course_act.respond_to?("created_at") + activity.created_at = activity.course_act.created_at + elsif activity.course_act.respond_to?("created_on") + activity.created_at = activity.course_act.created_on + end + activity.save + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 1488ca365..2014bf1ef 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 => 20150811083234) do +ActiveRecord::Schema.define(:version => 20150814031258) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 50fa03d00cd0a2bdfd6184a68945ee5fb6d94a6b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 14:44:31 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=AF=A5=E9=97=AE=E5=8D=B7=E6=89=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=9C=A8=E5=8A=A8=E6=80=81=EF=BC=8C=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=90=8E=E5=8F=96=E6=B6=88=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=AF=A5=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/poll.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 34a381246..3adbbb791 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -10,7 +10,7 @@ class Poll < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy - after_create :act_as_activity, :act_as_course_activity + before_save :act_as_activity, :act_as_course_activity acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" }, :description => :polls_description, @@ -32,7 +32,11 @@ class Poll < ActiveRecord::Base #课程动态公共表记录 def act_as_course_activity if self.polls_type == "Course" - self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) + if self.polls_status == 2 #问卷是发布状态 + self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) + elsif self.polls_status == 1 #问卷是新建状态 + self.course_acts.destroy_all + end end end end From a8283a28617d18113b45e511ad22c43bd7b0174c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 14:46:14 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E7=82=B9=E5=87=BB=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E5=8A=A8=E6=80=81=EF=BC=8C=E8=B7=B3=E8=BD=AC=E5=88=B0=E7=AD=94?= =?UTF-8?q?=E9=A2=98=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index ac142f5a1..f9fb31969 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -704,7 +704,7 @@ module CoursesHelper url = course_feedback_path(activity.course) when "Poll" title = "问卷 " + activity.course_act.polls_name - url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id) + url = poll_path(activity.course_act_id) end end link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb" From 16aea5ef4291b6c7371315f33730e2a5a4b7755c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 15:44:54 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E8=BF=9F=E4=BA=A4=E6=89=A3=E5=88=860-50?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_manual_form.html.erb | 3 ++- .../_homework_detail_programing_form.html.erb | 3 ++- public/javascripts/course.js | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/views/homework_common/_homework_detail_manual_form.html.erb b/app/views/homework_common/_homework_detail_manual_form.html.erb index ffec93e73..3af12973a 100644 --- a/app/views/homework_common/_homework_detail_manual_form.html.erb +++ b/app/views/homework_common/_homework_detail_manual_form.html.erb @@ -48,7 +48,8 @@