From 42d89c7ed05a6c66dc590f1aac86b21ed01a3a60 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 15:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=AF=BC=E8=AF=AD=E5=8F=91?= =?UTF-8?q?=E9=80=81=E8=BF=99=E6=94=B9=E6=88=90=E8=AF=BE=E5=A0=82=E4=BD=BF?= =?UTF-8?q?=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_activity.rb | 3 ++- app/views/messages/_course_show.html.erb | 17 ++++------------- app/views/users/_course_message.html.erb | 18 +++++------------- .../20160317070611_update_course_lead.rb | 8 ++++++++ db/schema.rb | 17 +++++++++-------- 5 files changed, 28 insertions(+), 35 deletions(-) create mode 100644 db/migrate/20160317070611_update_course_lead.rb diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 9c1431d5d..94eb097b8 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -71,7 +71,8 @@ class CourseActivity < ActiveRecord::Base name = lead_message.subject content = lead_message.content # message的status状态为0为正常,为1表示创建课程时发送的message - message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => self.course.tea_id , :sticky => true, :status => true ) + # author_id 默认为课程使者创建 + message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => 1 , :sticky => true, :status => true ) # 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一直 message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first end diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 49207d5c5..f36f8a63c 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -34,11 +34,7 @@
- <% if @topic.status == 1 %> - <%= image_tag("/images/trustie_logo1.png", width: "50px", height: "50px") %> - <% else %> - <%= link_to image_tag(url_to_avatar(@topic.author), :width => 50, :height => 50,:alt=>'图像' ), user_path(@topic.author) %> - <% end %> + <%= link_to image_tag(url_to_avatar(@topic.author), :width => 50, :height => 50,:alt=>'图像' ), user_path(@topic.author) %>
<% if User.current.logged? %> @@ -74,16 +70,11 @@ 主题: <%= @topic.subject%>
-
- <% if @topic.status == 1 %> - 确实团队 + <% if @topic.try(:author).try(:realname) == ' ' %> + <%= link_to @topic.try(:author), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> <% else %> - <% if @topic.try(:author).try(:realname) == ' ' %> - <%= link_to @topic.try(:author), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% else %> - <%= link_to @topic.try(:author).try(:realname), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% end %> + <%= link_to @topic.try(:author).try(:realname), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> <% end %>
<%= format_time( @topic.created_on)%>
diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index df084357a..7477eaabd 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -1,23 +1,15 @@
- <% if activity.status == 1 %> - <%= image_tag("/images/trustie_logo1.png", width: "50px", height: "50px") %> - <% else %> - <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> - <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> - <% end %> + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
- <% if activity.status == 1 %> - 确实团队 + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> <% else %> - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% end %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> <% end %> TO <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> diff --git a/db/migrate/20160317070611_update_course_lead.rb b/db/migrate/20160317070611_update_course_lead.rb new file mode 100644 index 000000000..0c68fa40f --- /dev/null +++ b/db/migrate/20160317070611_update_course_lead.rb @@ -0,0 +1,8 @@ +class UpdateCourseLead < ActiveRecord::Migration + def up + Message.where("status =? ", 1).update_all(:author_id => 1) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 2dad292f4..d2ecc2ca9 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 => 20160225031230) do +ActiveRecord::Schema.define(:version => 20160317070611) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -432,9 +432,11 @@ ActiveRecord::Schema.define(:version => 20160225031230) do t.integer "resource_num" t.integer "journal_num" t.integer "journal_reply_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "total_score" + t.integer "homework_journal_num", :default => 0 + t.integer "news_num", :default => 0 end create_table "course_groups", :force => true do |t| @@ -506,6 +508,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do t.integer "is_excellent", :default => 0 t.integer "excellent_option", :default => 0 t.integer "is_copy", :default => 0 + t.integer "visits", :default => 0 end create_table "custom_fields", :force => true do |t| @@ -1282,6 +1285,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.boolean "allow_guest_download", :default => true + t.integer "visits", :default => 0 end create_table "phone_app_versions", :force => true do |t| @@ -1441,6 +1445,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do t.integer "acts_count", :default => 0 t.integer "journals_count", :default => 0 t.integer "boards_reply_count", :default => 0 + t.integer "visits", :default => 0 end add_index "projects", ["lft"], :name => "index_projects_on_lft" @@ -1900,6 +1905,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do t.string "mail_notification", :default => "", :null => false t.string "salt", :limit => 64 t.integer "gid" + t.integer "visits", :default => 0 end add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" @@ -2013,11 +2019,6 @@ ActiveRecord::Schema.define(:version => 20160225031230) do add_index "wikis", ["project_id"], :name => "wikis_project_id" - create_table "wlcs", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "workflows", :force => true do |t| t.integer "tracker_id", :default => 0, :null => false t.integer "old_status_id", :default => 0, :null => false