Merge branch 'dev_hjq' of http://repository.trustie.net/xianbo/trustie2 into dev_hjq
commit
d0c4230e69
@ -0,0 +1,34 @@
|
|||||||
|
class PrincipalActivity < ActiveRecord::Base
|
||||||
|
attr_accessible :principal_act_id, :principal_act_type, :principal_id, :user_id
|
||||||
|
#虚拟关联
|
||||||
|
belongs_to :principal_act ,:polymorphic => true
|
||||||
|
belongs_to :user
|
||||||
|
validates :user_id,presence: true
|
||||||
|
validates :principal_id,presence: true
|
||||||
|
validates :principal_act_id,presence: true
|
||||||
|
validates :principal_act_type, presence: true
|
||||||
|
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
|
||||||
|
after_save :add_user_activity
|
||||||
|
before_destroy :destroy_user_activity
|
||||||
|
|
||||||
|
#在个人动态里面增加当前动态
|
||||||
|
def add_user_activity
|
||||||
|
user_activity = UserActivity.where("act_type = '#{self.principal_act_type.to_s}' and act_id = '#{self.principal_act_id}'").first
|
||||||
|
if user_activity
|
||||||
|
user_activity.save
|
||||||
|
else
|
||||||
|
user_activity = UserActivity.new
|
||||||
|
user_activity.act_id = self.principal_act_id
|
||||||
|
user_activity.act_type = self.principal_act_type
|
||||||
|
user_activity.container_type = "Principal"
|
||||||
|
user_activity.container_id = self.principal_id
|
||||||
|
user_activity.user_id = self.user_id
|
||||||
|
user_activity.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy_user_activity
|
||||||
|
user_activity = UserActivity.where("act_type = '#{self.principal_act_type.to_s}' and act_id = '#{self.principal_act_id}'")
|
||||||
|
user_activity.destroy_all
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,16 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
$(function(){
|
||||||
|
$("#RSide").removeAttr("id");
|
||||||
|
$("#Container").css("width","1000px");
|
||||||
|
$("#message_subject").focus();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<div class="homepageRight mt0 ml10">
|
||||||
|
<div class="homepageRightBanner">
|
||||||
|
<div class="NewsBannerName">
|
||||||
|
编辑帖子
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= render :partial => 'boards/course_new',
|
||||||
|
:locals => {:f => f, :edit_mode => edit_mode, :topic => topic} %>
|
||||||
|
</div>
|
@ -1,12 +1,69 @@
|
|||||||
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
|
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
||||||
|
<%= error_messages_for 'message' %>
|
||||||
|
<div class="resources mt10">
|
||||||
|
<div id="new_course_topic">
|
||||||
|
<div class="homepagePostBrief c_grey">
|
||||||
|
<div>
|
||||||
|
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="255" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
|
||||||
|
<p id="subjectmsg"></p>
|
||||||
|
</div>
|
||||||
|
<div id="topic_editor" style="display: none;">
|
||||||
|
<%if User.current.member_of_course?(course)%>
|
||||||
|
<div class="mt10">
|
||||||
|
<%= f.check_box :sticky, :value => topic.sticky%>
|
||||||
|
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
|
||||||
|
<%= f.check_box :locked, :value => topic.locked%>
|
||||||
|
<%= label_tag 'message_locked', l(:label_board_locked) %>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div class="mt10">
|
||||||
|
<div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
|
||||||
|
<%= text_area :quote,:quote,:style => 'display:none' %>
|
||||||
|
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||||
|
|
||||||
<%= render :partial => 'form_course', :locals => {:f => f, :topic => @message} %>
|
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
|
||||||
<li>
|
:owner_id => topic.nil? ? 0: topic.id,
|
||||||
|
:owner_type => OwnerTypeHelper::MESSAGE,
|
||||||
|
:width => '100%',
|
||||||
|
:height => 300,
|
||||||
|
:minHeight=>300,
|
||||||
|
:class => 'talk_text fl',
|
||||||
|
:input_html => { :id => 'message_content',
|
||||||
|
:class => 'talk_text fl',
|
||||||
|
:maxlength => 5000 }%>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<p id="message_content_span"></p>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="mt10">
|
||||||
|
<div class="fl" id="topic_attachments">
|
||||||
|
<%= render :partial => 'attachments/form_course', :locals => {:container => topic, :isReply => @isReply} %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="mt5">
|
||||||
|
<%if !edit_mode %>
|
||||||
|
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_topic();">确定</a>
|
||||||
|
<span class="fr mr10 mt3">或</span>
|
||||||
|
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a>
|
||||||
|
<% else %>
|
||||||
|
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_topic();">确定</a>
|
||||||
|
<span class="fr mr10 mt3">或</span>
|
||||||
|
<%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %>
|
||||||
|
<!--<li>
|
||||||
<div class="ml55 fl" nhname="toolbar_container"></div>
|
<div class="ml55 fl" nhname="toolbar_container"></div>
|
||||||
<a href="javascript:void(0);" nhname="cancelbtn" class="grey_btn fr ml10"><%= l(:button_cancel) %></a>
|
<a href="javascript:void(0);" nhname="cancelbtn" class="grey_btn fr ml10"><%#= l(:button_cancel) %></a>
|
||||||
<a href="javascript:void(0);" nhname="submitbtn" class="blue_btn fr " style="margin-left: 55px">
|
<a href="javascript:void(0);" nhname="submitbtn" class="blue_btn fr " style="margin-left: 55px">
|
||||||
<%= l(:button_submit)%>
|
<%#= l(:button_submit)%>
|
||||||
</a>
|
</a>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</li>
|
</li>-->
|
||||||
<% end %>
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1 @@
|
|||||||
|
$("#show_more_course_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/course_show',:locals => {:topics => @topics, :page => @page} )%>");
|
@ -0,0 +1,31 @@
|
|||||||
|
<style type="text/css">
|
||||||
|
/*回复框*/
|
||||||
|
.ReplyToMessageInputContainer .ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
|
||||||
|
.ReplyToMessageInputContainer .ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
|
||||||
|
.ReplyToMessageInputContainer .ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
|
||||||
|
.ReplyToMessageInputContainer .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
|
||||||
|
.ReplyToMessageInputContainer .ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
|
||||||
|
.ReplyToMessageInputContainer .ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
|
||||||
|
.ReplyToMessageInputContainer .ke-outline{border:none;}
|
||||||
|
.ReplyToMessageInputContainer .ke-inline-block{display: none;}
|
||||||
|
.ReplyToMessageInputContainer .ke-container{float:left;}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="ReplyToMessageContainer borderBottomNone" id="reply_to_message_<%= reply.id%>">
|
||||||
|
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= reply.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
|
||||||
|
<div class="ReplyToMessageInputContainer mb10">
|
||||||
|
<div nhname='new_message_<%= reply.id%>'>
|
||||||
|
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'new_form'} do |f| %>
|
||||||
|
<input type="hidden" name="quote[quote]" id="quote_quote">
|
||||||
|
<input type="hidden" name="reply[subject]" id="reply_subject">
|
||||||
|
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= reply.id%>' name="reply[content]"></textarea>
|
||||||
|
<div nhname='toolbar_container_<%= reply.id%>' style="float:left; margin-left: 5px; padding-top:3px;"></div>
|
||||||
|
<a id="new_message_submit_btn_<%= reply.id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<p nhname='contentmsg_<%= reply.id%>'></p>
|
||||||
|
<% end%>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
@ -1,45 +1,38 @@
|
|||||||
<div class="project_r_h">
|
<% if @message.project %>
|
||||||
<h2 class="project_h2"><%= l(:label_course_board) %></h2>
|
<div class="project_r_h">
|
||||||
</div>
|
<h2 class="project_h2"><%= l(:label_course_board) %></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<% if @message.project %>
|
|
||||||
<%#= board_breadcrumb(@message) %>
|
<%#= board_breadcrumb(@message) %>
|
||||||
<!--<h3><%#= avatar(@topic.author, :size => "24") %><span style = "width:100%;word-break:break-all;word-wrap: break-word;"><%#=h @topic.subject %></span></h3>-->
|
<!--<h3><%#= avatar(@topic.author, :size => "24") %><span style = "width:100%;word-break:break-all;word-wrap: break-word;"><%#=h @topic.subject %></span></h3>-->
|
||||||
<div class="ml15">
|
<div class="ml15">
|
||||||
<ul>
|
<ul>
|
||||||
<%= form_for @message, { :as => :message,
|
<%= form_for @message, {:as => :message,
|
||||||
:url => {:action => 'edit'},
|
:url => {:action => 'edit'},
|
||||||
:html => {:multipart => true,
|
:html => {:multipart => true,
|
||||||
:id => 'message-form',
|
:id => 'message-form',
|
||||||
:method => :post}
|
:method => :post}
|
||||||
} do |f| %>
|
} do |f| %>
|
||||||
<%= render :partial => 'form_project',
|
<%= render :partial => 'form_project',
|
||||||
:locals => {:f => f, :replying => !@message.parent.nil?} %>
|
:locals => {:f => f, :replying => !@message.parent.nil?} %>
|
||||||
<a href="#" onclick="submitProjectsBoard();"class="blue_btn fl c_white"><%= l(:button_submit)%></a>
|
<a href="#" onclick="submitProjectsBoard();" class="blue_btn fl c_white"><%= l(:button_submit) %></a>
|
||||||
<%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "blue_btn grey_btn fl c_white" %>
|
<%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "blue_btn grey_btn fl c_white" %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% elsif @message.course %>
|
<% elsif @message.course %>
|
||||||
<%#= course_board_breadcrumb(@message) %>
|
<%= form_for @message, {
|
||||||
<div class="talk_new ml15">
|
:as => :message,
|
||||||
<ul>0
|
:url => {:action => 'edit'},
|
||||||
<%= form_for @message, {
|
:html => {:multipart => true,
|
||||||
:as => :message,
|
:id => 'message-form',
|
||||||
:url => {:action => 'edit'},
|
:method => :post}
|
||||||
:html => {:multipart => true,
|
} do |f| %>
|
||||||
:id => 'message-form',
|
<%= render :partial => 'boards/course_message_edit',
|
||||||
:method => :post}
|
:locals => {:f => f, :edit_mode => true, :topic => @message} %>
|
||||||
} do |f| %>
|
|
||||||
<%= render :partial => 'form_course',
|
|
||||||
:locals => {:f => f, :replying => !@message.parent.nil?} %>
|
|
||||||
<a href="javascript:void(0)" onclick="submitCoursesBoard();"class="blue_btn fl c_white"><%= l(:button_submit)%></a>
|
|
||||||
<%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "blue_btn grey_btn fl c_white" %>
|
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<div id="preview" class="wiki"></div>
|
<div id="preview" class="wiki"></div>
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
$('#message_subject').val("<%= raw escape_javascript(@subject) %>");
|
/*$('#message_subject').val("<%#= raw escape_javascript(@subject) %>");
|
||||||
$('#message_quote').html("<%= raw escape_javascript(@temp.content.html_safe) %>");
|
$('#message_quote').html("<%#= raw escape_javascript(@temp.content.html_safe) %>");
|
||||||
//$('#message_content').val("<#%= raw escape_javascript(@content) %>");
|
//$('#message_content').val("<#%= raw escape_javascript(@content) %>");
|
||||||
$('#quote_quote').html("<%= raw escape_javascript(@temp.content.html_safe) %>");
|
$('#quote_quote').html("<%#= raw escape_javascript(@temp.content.html_safe) %>");
|
||||||
|
|
||||||
showAndScrollTo("reply", "message_content");
|
showAndScrollTo("reply", "message_content");
|
||||||
$('#message_content').scrollTop = $('#message_content').scrollHeight - $('#message_content').clientHeight;
|
$('#message_content').scrollTop = $('#message_content').scrollHeight - $('#message_content').clientHeight;
|
||||||
$("img").removeAttr("align");
|
$("img").removeAttr("align");*/
|
||||||
|
if($("#reply_message_<%= @message.id%>").length > 0) {
|
||||||
|
$("#reply_message_<%= @message.id%>").replaceWith("<%= escape_javascript(render :partial => 'reply_message', :locals => {:reply => @message,:temp =>@temp,:subject =>@subject}) %>");
|
||||||
|
$(function(){
|
||||||
|
$('#reply_subject').val("<%= raw escape_javascript(@subject) %>");
|
||||||
|
$('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>");
|
||||||
|
init_activity_KindEditor_data(<%= @message.id%>,null,"85%");
|
||||||
|
});
|
||||||
|
}else if($("#reply_to_message_<%= @message.id%>").length >0) {
|
||||||
|
$("#reply_to_message_<%= @message.id%>").replaceWith("<p id='reply_message_<%= @message.id%>'></p>");
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
$("input[name='occupation']").val('<%= @school.id%>');
|
||||||
|
$("#hint").html('<span style="color: #64bdd9">创建成功</span>').show();
|
@ -0,0 +1,8 @@
|
|||||||
|
<% attachments.each_with_index do |attachment,i| %>
|
||||||
|
<div id="attachment_<%= attachment.id%>">
|
||||||
|
<%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%>
|
||||||
|
<%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) if attachment.id && User.current == attachment.author && status != 2 %>
|
||||||
|
<span class="ml5 fl">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<% end -%>
|
@ -1,48 +1,48 @@
|
|||||||
<% has_commit = has_commit_poll?(activity.id ,User.current)%>
|
<% has_commit = has_commit_poll?(activity.id ,User.current)%>
|
||||||
<% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%>
|
<% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%>
|
||||||
<% if ( activity.polls_status==2) %>
|
<% if ( activity.polls_status==2) %>
|
||||||
<div class="resources mt10">
|
<div class="resources mt10">
|
||||||
<div class="homepagePostBrief">
|
<div class="homepagePostBrief">
|
||||||
<div class="homepagePostPortrait">
|
<div class="homepagePostPortrait">
|
||||||
<!-- <a href="javascript:void(0);"><img src="images/homepageImage.jpg" width="90" height="90" alt="用户头像"/></a>-->
|
<!-- <a href="javascript:void(0);"><img src="images/homepageImage.jpg" width="90" height="90" alt="用户头像"/></a>-->
|
||||||
<%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
|
<%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="homepagePostDes">
|
<div class="homepagePostDes">
|
||||||
<div class="homepagePostTo break_word">
|
<div class="homepagePostTo break_word mt-4">
|
||||||
<% if activity.try(:user).try(:realname) == ' ' %>
|
<% if activity.try(:user).try(:realname) == ' ' %>
|
||||||
<%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %>
|
<%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %>
|
<%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
TO
|
TO
|
||||||
<%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", poll_index_path(:polls_type => "Course", :polls_group_id => activity.polls_group_id), :class => "newsBlue ml15" %>
|
<%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", poll_index_path(:polls_type => "Course", :polls_group_id => activity.polls_group_id), :class => "newsBlue ml15" %>
|
||||||
<!--<a href="javascript:void(0);" class="newsBlue ml15">分布式计算环境(课程名称)</a>-->
|
<!--<a href="javascript:void(0);" class="newsBlue ml15">分布式计算环境(课程名称)</a>-->
|
||||||
</div>
|
</div>
|
||||||
<div class="homepagePostTitle break_word" >
|
<div class="homepagePostTitle break_word" >
|
||||||
<%#= link_to activity.polls_name.to_s/*+"(问卷名称)"*/, %>
|
<%#= link_to activity.polls_name.to_s/*+"(问卷名称)"*/, %>
|
||||||
<% if has_commit %>
|
<% if has_commit %>
|
||||||
<%= link_to poll_name, poll_result_poll_path(activity.id), :class => "postGrey"%>
|
<%= link_to poll_name, poll_result_poll_path(activity.id), :class => "postGrey"%>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to poll_name, poll_path(activity.id), :class => "postGrey"%>
|
<%= link_to poll_name, poll_path(activity.id), :class => "postGrey"%>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="homepagePostDate">
|
<div class="homepagePostDate">
|
||||||
发布时间:<%= format_time(activity.published_at) %>
|
发布时间:<%= format_time(activity.published_at) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>"><%=activity.polls_description.html_safe.to_s%></div>
|
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>"><%=activity.polls_description.html_safe.to_s%></div>
|
||||||
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
|
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="homepagePostSettingIcon">
|
<li class="homepagePostSettingIcon">
|
||||||
<ul class="homepagePostSettiongText">
|
<ul class="homepagePostSettiongText">
|
||||||
<li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li>
|
<li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li>
|
||||||
<li><a href="javascript:void(0);" class="postOptionLink">复制</a></li>
|
<li><a href="javascript:void(0);" class="postOptionLink">复制</a></li>
|
||||||
<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>
|
<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
@ -0,0 +1,12 @@
|
|||||||
|
class CreatePrincipalActivities < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :principal_activities do |t|
|
||||||
|
t.integer :user_id
|
||||||
|
t.integer :principal_id
|
||||||
|
t.integer :principal_act_id
|
||||||
|
t.string :principal_act_type
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,15 @@
|
|||||||
|
class UpdatePrincipalActivity < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
User.all.each do |user|
|
||||||
|
transaction do
|
||||||
|
user.principal_acts << PrincipalActivity.new(:user_id => user.id,:principal_id => user.id)
|
||||||
|
user.journals_for_messages.each do |jour|
|
||||||
|
jour.principal_acts << PrincipalActivity.new(:user_id => jour.user_id,:principal_id => user.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,43 @@
|
|||||||
|
class UpdatePrincipalActivityTime < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
count = PrincipalActivity.all.count / 30 + 2
|
||||||
|
transaction do
|
||||||
|
for i in 1 ... count do i
|
||||||
|
PrincipalActivity.page(i).per(30).each do |activity|
|
||||||
|
if activity.principal_act
|
||||||
|
if activity.principal_act.respond_to?("created_on")
|
||||||
|
activity.created_at = activity.principal_act.created_on
|
||||||
|
activity.updated_at = activity.principal_act.created_on
|
||||||
|
elsif activity.principal_act.respond_to?("created_at")
|
||||||
|
activity.created_at = activity.principal_act.created_at
|
||||||
|
activity.updated_at = activity.principal_act.created_at
|
||||||
|
end
|
||||||
|
activity.save
|
||||||
|
|
||||||
|
user_activity = UserActivity.where("act_type = '#{activity.principal_act_type.to_s}' and act_id = '#{activity.principal_act_id}'").first
|
||||||
|
user_activity.created_at = activity.created_at
|
||||||
|
user_activity.updated_at = activity.created_at
|
||||||
|
if user_activity.act_type == 'JournalsForMessage'
|
||||||
|
if user_activity.act
|
||||||
|
unless user_activity.act.m_parent_id.nil?
|
||||||
|
parent_act = UserActivity.where("act_id = #{user_activity.act.m_parent_id} and act_type='JournalsForMessage' and container_type='Principal'").first
|
||||||
|
if parent_act
|
||||||
|
parent_act.created_at = user_activity.act.parent.children.maximum("created_on")
|
||||||
|
parent_act.save
|
||||||
|
user_activity.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
user_activity.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
user_activity.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddColumnPinyinToSchools < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :schools, :pinyin, :string
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,16 @@
|
|||||||
|
class UpdateUserActivityUpdatedAt < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
count = UserActivity.all.count / 30 + 2
|
||||||
|
transaction do
|
||||||
|
for i in 1 ... count do i
|
||||||
|
UserActivity.page(i).per(30).each do |activity|
|
||||||
|
activity.updated_at = activity.created_at
|
||||||
|
activity.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,11 @@
|
|||||||
|
class TransferNameColumnValueToPinyinColumnValue < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
School.all.each do |school|
|
||||||
|
school.pinyin = Pinyin.t(school.name, splitter: '')
|
||||||
|
school.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 944 B |
@ -0,0 +1,10 @@
|
|||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :principal_activity do
|
||||||
|
user_id 1
|
||||||
|
principal_id 1
|
||||||
|
principal_act_id 1
|
||||||
|
principal_act_type "MyString"
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe PrincipalActivity, :type => :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in new issue