parent
abf6b5ff70
commit
d8c6775f42
@ -0,0 +1,15 @@
|
||||
class OrgMessage < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :organization
|
||||
has_many :message_alls, :as => :message, :dependent => :destroy
|
||||
validates :message_type, :presence => true
|
||||
validates :message_id, :presence => true
|
||||
validates :organization_id, :presence => true
|
||||
after_create :add_user_message
|
||||
|
||||
def add_user_message
|
||||
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
|
||||
self.message_alls << MessageAll.new(:user_id => self.user_id)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1 @@
|
||||
$("#agree_apply_subdomain").text("已同意申请");
|
@ -0,0 +1,39 @@
|
||||
<% if ma.class == OrgMessage %>
|
||||
<% if ma.message_type == 'ApplySubdomain'%>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.organization), :width => "30", :height => "30"), organization_path(ma.organization_id) %></a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%=link_to ma.organization.name, organization_path(ma.organization_id), :class => "newsBlue homepageNewsPublisher" %>
|
||||
<span class='<%= ma.viewed == 0 ? 'homepageNewsTypeNotRead fl' : 'homepageNewsType fl' %>'>申请子域名:</span>
|
||||
</li>
|
||||
<li class="homepageHomeworkContent fl">
|
||||
<%= ma.content %>
|
||||
</li>
|
||||
<li class="homepageHomeworkContentWarn fl">
|
||||
<%=link_to ma.organization.domain.nil? ? "同意申请":"已同意申请", agree_apply_subdomain_organizations_path( :organization_id => ma.organization_id, :org_domain => ma.content, :user_id => ma.sender_id ),
|
||||
:id => 'agree_apply_subdomain',
|
||||
:method => 'post',
|
||||
:remote => true,
|
||||
:class => "green_btn_cir ml10",
|
||||
:style => "color:#fff" %>
|
||||
</li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ma.message_type == 'AgreeApplySubdomain'%>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);"><div class="navHomepageLogo fl"><%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %></div></a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<span class='<%= ma.viewed == 0 ? 'homepageNewsTypeNotRead fl' : 'homepageNewsType fl' %>'>管理员同意了您的子域名申请:</span>
|
||||
</li>
|
||||
<li class="homepageNewsContent fl">
|
||||
<%= ma.content %>
|
||||
</li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
@ -0,0 +1,19 @@
|
||||
class CreateOrgMessages < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :org_messages do |t|
|
||||
t.integer :user_id
|
||||
t.integer :sender_id
|
||||
t.integer :organization_id
|
||||
t.string :message_type
|
||||
t.integer :message_id
|
||||
t.integer :viewed
|
||||
t.string :content
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :org_messages
|
||||
end
|
||||
end
|
Loading…
Reference in new issue