parent
abf6b5ff70
commit
d8c6775f42
|
@ -28,7 +28,7 @@ class OrganizationsController < ApplicationController
|
|||
helper :project_score
|
||||
helper :issues
|
||||
include UsersHelper
|
||||
before_filter :find_organization, :only => [:show, :members]
|
||||
before_filter :find_organization, :only => [:show, :members, :apply_subdomain]
|
||||
layout 'base_org'
|
||||
def index
|
||||
|
||||
|
@ -291,4 +291,20 @@ class OrganizationsController < ApplicationController
|
|||
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@org_subfield.update_attribute(:hide, 0)
|
||||
end
|
||||
|
||||
def apply_subdomain
|
||||
@organization = Organization.find(params[:id])
|
||||
admins = User.where("admin=1")
|
||||
admins.each do |admin|
|
||||
OrgMessage.create(:user_id => admin.id, :organization_id => @organization.id, :message_type => 'ApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:domain])
|
||||
end
|
||||
end
|
||||
|
||||
def agree_apply_subdomain
|
||||
@organization = Organization.find(params[:organization_id])
|
||||
@organization.update_attribute(:domain, params[:org_domain])
|
||||
if OrgMessage.where("message_type='AgreeApplySubdomain' and organization_id=#{@organization.id} and content=#{params[:org_domain]}").count == 0
|
||||
OrgMessage.create(:user_id => params[:user_id], :organization_id => @organization.id, :message_type => 'AgreeApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:org_domain])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
|
@ -45,7 +45,7 @@
|
|||
<a href="javascript:void(0);" class="sendSourceText" onclick="submit_set_evaluation_attr('<%= @homework.end_time%>');">确定</a>
|
||||
</div>
|
||||
<div class="courseSendCancel">
|
||||
<a href="javascript:void(0);" class="sendSourceText linkGrey6" onclick="clickCanel();">取消</a>
|
||||
<a href="javascript:void(0);" class="sendSourceText linkGrey6" onclick="hideModal();">取消</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -2,5 +2,5 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/se
|
|||
showModal('ajax-modal', '350px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
"<a href='javascript:' onclick='hideModal();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed");
|
|
@ -3,7 +3,7 @@ var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: 0, showOn: 'button', bu
|
|||
showModal('ajax-modal', '350px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
"<a href='javascript:' onclick='hideModal();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed");
|
||||
$(function() { $('#evaluation_start_time').datepicker(datepickerOptions);
|
||||
$('#evaluation_end_time').datepicker(datepickerOptions);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#agree_apply_subdomain").text("已同意申请");
|
|
@ -54,14 +54,14 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
<div style="margin-left: 80px " id="check_desc_hint"></div>
|
||||
<!--<div class="orgRow mb10"><span class="ml10">组织URL:</span>-->
|
||||
<!--<div class="w607 fr">https://-->
|
||||
<!--<input type="text" name="organization[domain]" value="<%= @organization.domain%>" class="orgUrlInput" />-->
|
||||
<!--.trustie.net<a href="javascript:void(0);" class="linkBlue ml15" style="text-decoration:underline;">申请</a>-->
|
||||
<!--<p id="apply_hint"></p></div>-->
|
||||
<!--<!–class="c_green f12" 您的申请已提交,系统会以消息的形式通知您结果 –>-->
|
||||
<!--</div>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<div class="orgRow mb10"><span class="ml10">组织URL:</span>
|
||||
<div class="w607 fr">https://
|
||||
<input type="text" name="organization[domain]" id="domain" value="<%= @organization.domain%>" class="orgUrlInput" />
|
||||
.trustie.net<a href="javascript:void(0);" class="linkBlue ml15" style="text-decoration:underline;" onclick="apply_subdomain(<%= @organization.id %>,$('#domain').val());">申请</a>
|
||||
<p class="c_green f12" id="apply_hint" ></p></div>
|
||||
<!--class="c_green f12" 您的申请已提交,系统会以消息的形式通知您结果 -->
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="orgRow mb10 mt5"><span style="margin-left:38px;" >公开 : </span>
|
||||
<input type="checkbox" name="organization[is_public]" <%= @organization.is_public ? 'checked': ''%> class="ml3" />
|
||||
</div>
|
||||
|
@ -139,4 +139,17 @@
|
|||
if ($("#subfield_name").val().trim() != "")
|
||||
$("#add_subfield_form").submit();
|
||||
}
|
||||
function apply_subdomain(id, domain){
|
||||
$.ajax({
|
||||
url:"<%= apply_subdomain_organization_path %>",
|
||||
type:'post',
|
||||
data:{
|
||||
id:id,
|
||||
domain:domain
|
||||
},
|
||||
success:function(){
|
||||
$("#apply_hint").text("您的申请已提交,系统会以消息的形式通知您结果");
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -56,7 +56,7 @@
|
|||
<a href="javascript:void(0);" class="sendSourceText" onclick="$('#ajax-modal').find('form').submit();clickCanel();">确定</a>
|
||||
</div>
|
||||
<div class="courseSendCancel">
|
||||
<a href="javascript:void(0);" class="sendSourceText linkGrey6" onclick="clickCanel();">取消</a>
|
||||
<a href="javascript:void(0);" class="sendSourceText linkGrey6" onclick="hideModal();">取消</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -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 %>
|
|
@ -31,6 +31,8 @@
|
|||
<!--用户留言-->
|
||||
<%= render :partial => 'users/user_message_userfeedaback', :locals => {:ma => ma} %>
|
||||
|
||||
<%= render :partial => 'users/user_message_org', :locals => {:ma => ma} %>
|
||||
|
||||
<% 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%>
|
||||
|
|
|
@ -22,7 +22,11 @@
|
|||
</div>
|
||||
<div class="orgWrap">
|
||||
<div class="orgTitle">
|
||||
<%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
|
||||
<% if org.domain.nil? %>
|
||||
<%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
|
||||
<% else %>
|
||||
<a href="http://test.<%= org.domain %>.trustie.net" class = 'f16 linkBlue'><%= org.name %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="orgIntro"><%= org.description %></div>
|
||||
<div class="postCreater">创建者:<%= link_to User.find(org.creator_id), user_path(org.creator_id), :class => 'linkGrey2', :target => '_blank' %></div>
|
||||
|
|
|
@ -47,12 +47,14 @@ RedmineApp::Application.routes.draw do
|
|||
post 'join_project_menu'
|
||||
post 'join_projects'
|
||||
post 'logout'
|
||||
post 'apply_subdomain'
|
||||
end
|
||||
collection do
|
||||
get 'check_uniq'
|
||||
get 'autocomplete_search'
|
||||
post 'hide_org_subfield'
|
||||
post 'show_org_subfield'
|
||||
post 'agree_apply_subdomain'
|
||||
end
|
||||
resources :org_document_comments do
|
||||
member do
|
||||
|
@ -64,6 +66,9 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
Organization.where("domain is not null").each do |org|
|
||||
get '/', to: 'organizations#show', defaults: { id: org.id }, constraints: {subdomain: org.domain}
|
||||
end
|
||||
get '/', to: 'organizations#show', defaults: { id: 5 }, constraints: {subdomain: 'micros'}
|
||||
get '/', to: 'organizations#show', defaults: { id: 23 }, constraints: {subdomain: 'nubot'}
|
||||
|
||||
|
|
|
@ -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