课程动态的数据迁移
This commit is contained in:
parent
15b45e6706
commit
223bac373f
|
@ -621,22 +621,22 @@ class CoursesController < ApplicationController
|
|||
if params[:type].present?
|
||||
case params[:type]
|
||||
when "homework"
|
||||
@course_activities = course_activities.where("course_act_type = 'HomeworkCommon'").order('created_at desc').limit(10).offset(@page * 10)
|
||||
@course_activities = course_activities.where("course_act_type = 'HomeworkCommon'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "news"
|
||||
@course_activities = course_activities.where("course_act_type = 'News'").order('created_at desc').limit(10).offset(@page * 10)
|
||||
@course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "message"
|
||||
@course_activities = course_activities.where("course_act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10)
|
||||
@course_activities = course_activities.where("course_act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "poll"
|
||||
@course_activities = course_activities.where("course_act_type = 'Poll'").order('created_at desc').limit(10).offset(@page * 10)
|
||||
@course_activities = course_activities.where("course_act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "attachment"
|
||||
@course_activities = course_activities.where("course_act_type = 'Attachment'").order('created_at desc').limit(10).offset(@page * 10)
|
||||
@course_activities = course_activities.where("course_act_type = 'Attachment'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "journalsForMessage"
|
||||
@course_activities = course_activities.where("course_act_type = 'JournalsForMessage'").order('created_at desc').limit(10).offset(@page * 10)
|
||||
@course_activities = course_activities.where("course_act_type = 'JournalsForMessage'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
else
|
||||
@course_activities = course_activities.order('created_at desc').limit(10).offset(@page * 10)
|
||||
@course_activities = course_activities.order('updated_at desc').limit(10).offset(@page * 10)
|
||||
end
|
||||
else
|
||||
@course_activities = course_activities.order('created_at desc').limit(10).offset(@page * 10)
|
||||
@course_activities = course_activities.order('updated_at desc').limit(10).offset(@page * 10)
|
||||
end
|
||||
@type = params[:type]
|
||||
respond_to do |format|
|
||||
|
|
|
@ -39,7 +39,7 @@ class WordsController < ApplicationController
|
|||
# 删除留言功能要调用destroy,也记得在destroy.js中修改
|
||||
|
||||
# deny api. api useless
|
||||
@parent_id = params[:reference_id]
|
||||
parent_id = params[:reference_id]
|
||||
author_id = User.current.id
|
||||
reply_user_id = params[:reference_user_id]
|
||||
reply_id = params[:reference_message_id] # 暂时不实现
|
||||
|
@ -47,13 +47,21 @@ class WordsController < ApplicationController
|
|||
@show_name = params[:show_name] == "true"
|
||||
options = {:user_id => author_id,
|
||||
:status => true,
|
||||
:m_parent_id => @parent_id,
|
||||
:m_parent_id => parent_id,
|
||||
:m_reply_id => reply_id,
|
||||
:reply_id => reply_user_id,
|
||||
:notes => content,
|
||||
:is_readed => false}
|
||||
@jfm = add_reply_adapter options
|
||||
|
||||
@save_succ = true if @jfm.errors.empty?
|
||||
if @save_succ
|
||||
course_activity = CourseActivity.where("course_act_type='JournalsForMessage' and course_act_id =#{parent_id}").first
|
||||
course_activity.updated_at = Time.now
|
||||
course_activity.save
|
||||
user_activity = UserActivity.where("act_type='JournalsForMessage' and act_id =#{parent_id}").first
|
||||
user_activity.updated_at = Time.now
|
||||
user_activity.save
|
||||
end
|
||||
respond_to do |format|
|
||||
# format.html {
|
||||
# if @jfm.errors.empty?
|
||||
|
@ -63,18 +71,12 @@ class WordsController < ApplicationController
|
|||
# end
|
||||
# render 'test/index'
|
||||
# }
|
||||
format.js{
|
||||
@save_succ = true if @jfm.errors.empty?
|
||||
format.js {
|
||||
@user_activity_id = params[:user_activity_id] if
|
||||
@activity = JournalsForMessage.find(parent_id)
|
||||
}
|
||||
end
|
||||
if @save_succ
|
||||
course_activity = CourseActivity.where("course_act_type='JournalsForMessage' and course_act_id =#{@parent_id}").first
|
||||
course_activity.updated_at = Time.now
|
||||
course_activity.save
|
||||
user_activity = UserActivity.where("act_type='JournalsForMessage' and act_id =#{@parent_id}").first
|
||||
user_activity.updated_at = Time.now
|
||||
user_activity.save
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
|
@ -185,7 +185,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.jour_type == 'Course'
|
||||
if self.jour_type == 'Course' && self.m_parent_id.nil?
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -194,7 +194,7 @@ class Message < ActiveRecord::Base
|
|||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.course
|
||||
if self.course && self.parent_id.nil?
|
||||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
<ul class="homepagePostType">
|
||||
<li>
|
||||
<ul class="homepagePostTypeHomework fl">
|
||||
<li><%= link_to "全部动态", {:controller => "courses", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%></li>
|
||||
<li><%= link_to "作业动态", {:controller => "courses", :action => "show", :type => "homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%></li>
|
||||
<li><%= link_to "通知动态", {:controller => "courses", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey"%></li>
|
||||
<li><%= link_to "资源库动态", {:controller => "courses", :action => "show", :type => "attachment"}, :class => "homepagePostTypeQuiz postTypeGrey"%></li>
|
||||
<li><%= link_to "资源库动态", {:controller => "courses", :action => "show", :type => "attachment"}, :class => "resourcesTypeAtt resourcesGrey"%></li>
|
||||
<li><%= link_to "论坛动态", {:controller => "courses", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey"%></li>
|
||||
<li><%= link_to "留言动态", {:controller => "courses", :action => "show", :type => "journalsForMessage"}, :class => "homepagePostTypeQuiz postTypeGrey"%></li>
|
||||
<li><%= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%></li>
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
<%= link_to course.name.to_s+" | 课程留言", course_feedback_path(course), :class => "newsBlue ml15" %>
|
||||
</div>
|
||||
<div class="homepagePostTitle break_word">
|
||||
<%= link_to activity.notes.to_s, course_feedback_path(course), :class => "postGrey" %>
|
||||
<% if activity.m_parent_id.nil? %>
|
||||
<%= link_to activity.notes.to_s, course_feedback_path(course), :class => "postGrey" %>
|
||||
<% else %>
|
||||
<%= link_to activity.parent.notes.to_s, course_feedback_path(course), :class => "postGrey" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="homepagePostDate">
|
||||
留言时间:<%= format_time(activity.created_on) %>
|
||||
|
@ -22,7 +26,7 @@
|
|||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% count=course.journals_for_messages.count %>
|
||||
<% count=course.journals_for_messages.where('m_parent_id IS NULL').count %>
|
||||
<div class="homepagePostReply">
|
||||
<div class="topBorder" style="display: <%= count>0 ? 'none': '' %>"></div>
|
||||
<div class="homepagePostReplyBanner" style="display: <%= count>0 ? '': 'none' %>">
|
||||
|
@ -43,7 +47,7 @@
|
|||
<% if count > 0 %>
|
||||
<div class="" id="reply_div_<%= user_activity_id %>">
|
||||
<ul>
|
||||
<% course.journals_for_messages.reorder("created_on desc").each do |comment| %>
|
||||
<% course.journals_for_messages.where('m_parent_id IS NULL').reorder("created_on desc").each do |comment| %>
|
||||
<% replies_all_i = replies_all_i + 1 %>
|
||||
<li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i > 2 ? 'none' : '' %>">
|
||||
<div class="homepagePostReplyPortrait">
|
||||
|
@ -59,6 +63,33 @@
|
|||
<%= format_time(comment.created_on) %>
|
||||
</div>
|
||||
<div class="homepagePostReplyContent break_word list_style"><%= comment.notes.html_safe %></div>
|
||||
<% fetch_user_leaveWord_reply(comment).each do |reply| unless fetch_user_leaveWord_reply(comment).nil? %>
|
||||
<div class="recall">
|
||||
<div class="homepagePostReplyPortrait">
|
||||
<%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33", :class =>"mt8"), user_path(reply.user_id), :alt => "用户头像" %>
|
||||
</div>
|
||||
<div class="homepagePostReplyjournal">
|
||||
<div class="homepagePostReplyPublisher">
|
||||
<% if reply.try(:user).try(:realname) == ' ' %>
|
||||
<%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
|
||||
<% else %>
|
||||
<%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
|
||||
<% end %>
|
||||
<%= l(:label_reply_to)%>
|
||||
<% if comment.try(:user).try(:realname) == ' ' %>
|
||||
<%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14 ml10" %>
|
||||
<% else %>
|
||||
<%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14 ml10" %>
|
||||
<% end %>
|
||||
<%= format_time reply.created_on %>
|
||||
</div>
|
||||
<div class="homepagePostReplyContent break_word list_style"><%= reply.notes.html_safe %></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
@ -76,7 +107,7 @@
|
|||
<%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %>
|
||||
<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
|
||||
<%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
|
||||
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
|
||||
<%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
|
||||
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="user_notes"></textarea>
|
||||
<div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px; margin-left: 5px;"></div>
|
||||
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<% if @save_succ %>
|
||||
<% if params[:user_activity_id] %>
|
||||
<% @user_activity_id = params[:user_activity_id] %>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => JournalsForMessage.find(@parent_id),:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
|
||||
<% if @user_activity_id %>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
|
||||
init_activity_KindEditor_data('<%= @user_activity_id%>', "", "87%");
|
||||
<% else %>
|
||||
<% if !@jfm.nil? && @jfm.jour_type == 'Principal' %>
|
||||
|
|
35
db/schema.rb
35
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20150918134804) do
|
||||
ActiveRecord::Schema.define(:version => 20150925060939) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -490,26 +490,23 @@ ActiveRecord::Schema.define(:version => 20150918134804) do
|
|||
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
|
||||
add_index "documents", ["project_id"], :name => "documents_project_id"
|
||||
|
||||
create_table "dts", :primary_key => "Num", :force => true do |t|
|
||||
t.string "Defect", :limit => 50
|
||||
t.string "Category", :limit => 50
|
||||
t.string "File"
|
||||
t.string "Method"
|
||||
t.string "Module", :limit => 20
|
||||
t.string "Variable", :limit => 50
|
||||
t.integer "StartLine"
|
||||
t.integer "IPLine"
|
||||
t.string "IPLineCode", :limit => 200
|
||||
t.string "Judge", :limit => 15
|
||||
t.integer "Review", :limit => 1
|
||||
create_table "dts", :force => true do |t|
|
||||
t.string "IPLineCode"
|
||||
t.string "Description"
|
||||
t.text "PreConditions", :limit => 2147483647
|
||||
t.text "TraceInfo", :limit => 2147483647
|
||||
t.text "Code", :limit => 2147483647
|
||||
t.string "Num"
|
||||
t.string "Variable"
|
||||
t.string "TraceInfo"
|
||||
t.string "Method"
|
||||
t.string "File"
|
||||
t.string "IPLine"
|
||||
t.string "Review"
|
||||
t.string "Category"
|
||||
t.string "Defect"
|
||||
t.string "PreConditions"
|
||||
t.string "StartLine"
|
||||
t.integer "project_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "id", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "enabled_modules", :force => true do |t|
|
||||
|
|
|
@ -188,6 +188,7 @@ 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;}
|
||||
#navSearchAlert {display:none;}
|
||||
.homepagePostReplyjournal{margin-left: 15px; float: left;}
|
||||
|
||||
/*邮件邀请*/
|
||||
.box_main{ width:345px; margin:0 auto;}
|
||||
|
@ -366,7 +367,7 @@ a:hover.ping_sub{ background:#14a8b9;}
|
|||
.recall_head a{ display:block; width:30px; height:30px; border:1px solid #CCC; padding:1px;}
|
||||
.recall_head a:hover{border:1px solid #15bccf;}
|
||||
.recall_con{ float:left;color:#777777; width:520px; margin-left:10px;word-break: break-all;word-wrap: break-word; }
|
||||
.recall_con a{ color:#15bccf; }
|
||||
.recall_con a{ color:#269ac9; }
|
||||
.ping_list{ margin-top:15px;}
|
||||
.ping_ttl{height:18px;}
|
||||
.ping_ctt{height:auto;padding:6px;clear:both;}
|
||||
|
|
|
@ -642,6 +642,7 @@ a.postGrey {color:#484848;}
|
|||
a.postGrey:hover {color:#000000;}
|
||||
a.gz_btn{display:block; background:url(../images/pic_uersall.png) -318px -25px no-repeat; width:53px; height:18px; border:1px solid #cdcdcd; color:#333333; padding:0px 0 0 18px;margin-top: 2px;margin-right: 15px;}
|
||||
a:hover.gz_btn{ color:#ff5722;}
|
||||
.homepagePostReplyjournal{margin-left: 15px; float: left;}
|
||||
|
||||
/*课程主页css*/
|
||||
.homepageCoursesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:5px 10px; left:-65px; font-size:12px; color:#4b4b4b; line-height:2; z-index:9999; display:none;}
|
||||
|
|
|
@ -648,6 +648,7 @@ a.postReplyCancel:hover {color:#ffffff;}
|
|||
.postAttSize {color:#888888; font-size:12px;}
|
||||
a.postGrey {color:#484848;}
|
||||
a.postGrey:hover {color:#000000;}
|
||||
.homepagePostReplyjournal{margin-left: 15px; float: left;}
|
||||
|
||||
/*课程主页css*/
|
||||
.homepageCoursesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:5px 10px; left:-65px; font-size:12px; color:#4b4b4b; line-height:2; z-index:9999; display:none;}
|
||||
|
@ -870,7 +871,7 @@ a.box_close{background:url(../images/img_floatbox.png) -22px 0 no-repeat;}
|
|||
|
||||
/*文本左对齐*/
|
||||
.tl{text-align: left;}
|
||||
img,embed{max-width: 100%;}
|
||||
.embed img,embed{max-width: 100%;}
|
||||
.attachments {clear: both;}
|
||||
.is_public_checkbox{margin-left: 15px;margin-right: 10px;}
|
||||
.author_name{color: #3ca5c6 !important;}
|
||||
|
|
Loading…
Reference in New Issue