组织模块功能缺陷修改
This commit is contained in:
parent
bf01994e4f
commit
21275e8b7b
|
@ -28,13 +28,15 @@ class OrgDocumentCommentsController < ApplicationController
|
||||||
end
|
end
|
||||||
def update
|
def update
|
||||||
@org_document = OrgDocumentComment.find(params[:id])
|
@org_document = OrgDocumentComment.find(params[:id])
|
||||||
|
@org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content])
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
# format.html {redirect_to :}
|
format.html {redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@org_document = OrgDocumentComment.find(params[:id])
|
||||||
|
@organization = Organization.find(params[:organization_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_reply
|
def add_reply
|
||||||
|
|
|
@ -25,10 +25,14 @@ class OrganizationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@organization = Organization.find(params[:id])
|
if User.current.admin? || User.current.member_of_org?(@organization)
|
||||||
@activities = OrgActivity.where('(org_act_id = ? and org_act_type = ?) || (container_id =? and org_act_type =? and org_act_id !=?)',
|
@organization = Organization.find(params[:id])
|
||||||
@organization.id, 'CreateOrganization ', @organization.id, 'OrgDocumentComment', @organization.home_id).order('updated_at desc')
|
@activities = OrgActivity.where('(org_act_id = ? and org_act_type = ?) || (container_id =? and org_act_type =? and org_act_id !=?)',
|
||||||
@activities = paginateHelper @activities, 10
|
@organization.id, 'CreateOrganization ', @organization.id, 'OrgDocumentComment', @organization.home_id).order('updated_at desc')
|
||||||
|
@activities = paginateHelper @activities, 10
|
||||||
|
else
|
||||||
|
render_403
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@ -61,7 +65,12 @@ class OrganizationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def setting
|
def setting
|
||||||
@organization = Organization.find(params[:id])
|
@organization = Organization.find(params[:id])
|
||||||
|
|
||||||
|
if User.current.admin? || User.current.admin_of_org?(@organization)
|
||||||
|
else
|
||||||
|
render_403
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,14 +88,14 @@ class Principal < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
|
|
||||||
scope :not_member_of_org, lambda {|org|
|
scope :not_member_of_org, lambda {|org|
|
||||||
orgs = [org] unless org.is_a?(Array)
|
orgs = [org] unless org.is_a?(Array)
|
||||||
if orgs.empty?
|
if orgs.empty?
|
||||||
where("1=0")
|
where("1=0")
|
||||||
else
|
else
|
||||||
ids = orgs.map(&:id)
|
ids = orgs.map(&:id)
|
||||||
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{OrgMember.table_name} WHERE organization_id IN (?))", ids)
|
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{OrgMember.table_name} WHERE organization_id IN (?))", ids)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
scope :sorted, lambda { order(*Principal.fields_for_order_statement)}
|
scope :sorted, lambda { order(*Principal.fields_for_order_statement)}
|
||||||
|
|
||||||
|
|
|
@ -770,6 +770,21 @@ class User < Principal
|
||||||
courses.to_a.include?(course)
|
courses.to_a.include?(course)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def member_of_org?(org)
|
||||||
|
OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def admin_of_org?(org)
|
||||||
|
if OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count == 0
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
role = OrgMember.where("user_id =? and organization_id =?", self.id, org.id)[0].roles[0]
|
||||||
|
unless role.nil?
|
||||||
|
role.name == 'orgManager' ? true : false
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
def member_of_course_group?(course_group)
|
def member_of_course_group?(course_group)
|
||||||
course_groups.to_a.include?(course_group)
|
course_groups.to_a.include?(course_group)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%>
|
||||||
|
<script>
|
||||||
|
function check_org_title(title)
|
||||||
|
{
|
||||||
|
if($("#document_title").val().trim() == "")
|
||||||
|
{
|
||||||
|
$("#doc_title_hint").html("<span class='c_red'>标题不能为空</span>").show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#doc_title_hint").hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<div class="homepageRightBanner mb10">
|
||||||
|
<div class="NewsBannerName">编辑文章</div>
|
||||||
|
</div>
|
||||||
|
<%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id),:method => 'put', :id => 'new_org_document_form' do |f| %>
|
||||||
|
<div class="resources">
|
||||||
|
<div>
|
||||||
|
<input class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" onblur="check_org_title();" value="<%= @org_document.title %>" />
|
||||||
|
</div>
|
||||||
|
<div id="doc_title_hint"></div>
|
||||||
|
<div id="org_document_editor" class="mt15" style="">
|
||||||
|
<div class="mt10">
|
||||||
|
<%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org_document_description_editor', :height => "150px" %>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
|
||||||
|
|
||||||
|
<p id="homework_course_id_span" class="c_red mt5"></p>
|
||||||
|
<div class="cl"></div>
|
||||||
|
|
||||||
|
<div class="mt5">
|
||||||
|
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="org_document_description_editor.sync();$('#new_org_document_form').submit();">确定</a>
|
||||||
|
<span class="fr mr10 mt3">或</span>
|
||||||
|
<a href="javascript:void(0);" onclick="$('#org_document_editor').hide(); $('#doc_title_hint').hide();" class="fr mr10 mt3">取消</a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -25,7 +25,9 @@
|
||||||
<a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">设为首页</a>
|
<a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">设为首页</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="javascript:void(0);" class="postOptionLink">编辑文章</a></li>
|
<li>
|
||||||
|
<%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :class => "postOptionLink" %>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete',:remote => true, :class => 'postOptionLink' %>
|
<%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete',:remote => true, :class => 'postOptionLink' %>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="ml15 mr15" id="orgContent_1">
|
<div class="ml15 mr15" id="orgContent_1">
|
||||||
<!--<div class="orgLogo mb10"><a href="javascript:void(0);"><img src="images/org_default.jpg" width="55" height="55" alt="组织logo" class="mr10 logoBorder fl ml10" /></a>-->
|
<!--<div class="orgLogo mb10"><a href="javascript:void(0);"><img src="images/0" width="55" height="55" alt="组织logo" class="mr10 logoBorder fl ml10" /></a>-->
|
||||||
<!--<a href="javascript:void(0);" class="logoEnter fl linkGrey4">上传图片</a>-->
|
<!--<a href="javascript:void(0);" class="logoEnter fl linkGrey4">上传图片</a>-->
|
||||||
<%#= form_for( @organization,{:controller => 'organizations',:action => 'update',:id=>@organization,:html=>{:id=>'update_org_form',:method=>'put'}}) do %>
|
<%#= form_for( @organization,{:controller => 'organizations',:action => 'update',:id=>@organization,:html=>{:id=>'update_org_form',:method=>'put'}}) do %>
|
||||||
<%= labelled_form_for @organization do |f|%>
|
<%= labelled_form_for @organization do |f|%>
|
||||||
|
@ -55,14 +55,14 @@
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-left: 80px " id="check_desc_hint"></div>
|
<div style="margin-left: 80px " id="check_desc_hint"></div>
|
||||||
<div class="orgRow mb10"><span class="ml10">组织URL:</span>
|
<!--<div class="orgRow mb10"><span class="ml10">组织URL:</span>-->
|
||||||
<div class="w607 fr">https://
|
<!--<div class="w607 fr">https://-->
|
||||||
<input type="text" name="organization[domain]" value="<%= @organization.domain%>" class="orgUrlInput" />
|
<!--<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>
|
<!--.trustie.net<a href="javascript:void(0);" class="linkBlue ml15" style="text-decoration:underline;">申请</a>-->
|
||||||
<p id="apply_hint"></p></div>
|
<!--<p id="apply_hint"></p></div>-->
|
||||||
<!--class="c_green f12" 您的申请已提交,系统会以消息的形式通知您结果 -->
|
<!--<!–class="c_green f12" 您的申请已提交,系统会以消息的形式通知您结果 –>-->
|
||||||
</div>
|
<!--</div>-->
|
||||||
<div class="cl"></div>
|
<!--<div class="cl"></div>-->
|
||||||
<div class="orgRow mb10 mt5"><span style="margin-left:38px;" >公开 : </span>
|
<div class="orgRow mb10 mt5"><span style="margin-left:38px;" >公开 : </span>
|
||||||
<input type="checkbox" name="organization[is_public]" <%= @organization.is_public ? 'checked': ''%> class="ml3" />
|
<input type="checkbox" name="organization[is_public]" <%= @organization.is_public ? 'checked': ''%> class="ml3" />
|
||||||
</div>
|
</div>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue