组织资源栏目显示转发的帖子
This commit is contained in:
parent
b9ae579622
commit
73d377d06d
|
@ -313,9 +313,16 @@ class MessagesController < ApplicationController
|
|||
def join_org_subfields
|
||||
org_subfield_ids = params[:org_subfields]
|
||||
@message = Message.find(params[:id])
|
||||
# @message.update_attribute(:updated_on, Time.now)
|
||||
type = @message.board.course_id.nil? ? "Project":"Course"
|
||||
org_subfield_ids.each do |field_id|
|
||||
OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => @message.id, :message_type => type)
|
||||
org_acts = OrgActivity.where("container_type='OrgSubfield' and container_id=? and org_act_type='Message' and org_act_id=?", field_id.to_i, @message.id)
|
||||
if org_acts.all.size() > 0
|
||||
org_acts.first.update_attribute(:updated_at, Time.now)
|
||||
else
|
||||
OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'Message', :org_act_id => @message.id, :user_id => User.current.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,17 @@ class OrgSubfieldsController < ApplicationController
|
|||
@subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type])
|
||||
end
|
||||
|
||||
def show
|
||||
@org_subfield = OrgSubfield.find(params[:id])
|
||||
@organization = @org_subfield.organization.id
|
||||
@messages = []
|
||||
@messages << @org_subfield.org_document_comments
|
||||
@messages << @org_subfield.messages
|
||||
@messages.sort{|a, b| b.updated_at <=> a.updated_at}
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_org'}
|
||||
end
|
||||
end
|
||||
def destroy
|
||||
@subfield = OrgSubfield.find(params[:id])
|
||||
@organization = Organization.find(@subfield.organization_id)
|
||||
|
@ -18,7 +29,4 @@ class OrgSubfieldsController < ApplicationController
|
|||
@subfield.update_attributes(:name => params[:name])
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -71,7 +71,7 @@ class OrganizationsController < ApplicationController
|
|||
if params[:org_subfield_id]
|
||||
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
|
||||
@org_activities = OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})").order('updated_at desc').page(params[:page] || 1).per(10)
|
||||
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
|
||||
else
|
||||
project_ids = @organization.projects.map(&:id) << 0
|
||||
course_ids = @organization.courses.map(&:id) << 0
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class OrgSubfieldMessage < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
end
|
|
@ -49,6 +49,16 @@
|
|||
<%= render :partial => 'org_course_create', :locals => {:activity => Course.find(act.org_act_id), :user_activity_id => act.id} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if act.container_type == 'OrgSubfield' %>
|
||||
<% if act.org_act_type == 'Message' %>
|
||||
<% message = Message.find(act.org_act_id) %>
|
||||
<% if !message.board.course_id.nil? %>
|
||||
<%= render :partial => 'org_course_message', :locals => {:activity => message,:user_activity_id =>act.id} %>
|
||||
<% else %>
|
||||
<%= render :partial => 'organizations/project_message', :locals => {:activity => message,:user_activity_id =>act.id} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<!--<ul class="wlist" style=" border:none; padding-top: 15px;">-->
|
||||
<%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
class CreateOrgSubfieldMessages < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :org_subfield_messages do |t|
|
||||
t.integer :org_subfield_id
|
||||
t.integer :message_id
|
||||
t.string :message_type
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
FactoryGirl.define do
|
||||
factory :org_subfield_message, :class => 'OrgSubfieldMessage' do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe OrgSubfieldMessage, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue