组织模块功能缺陷修改

This commit is contained in:
ouyangxuhua 2015-11-12 17:52:47 +08:00
parent bf01994e4f
commit 21275e8b7b
8 changed files with 96 additions and 25 deletions

View File

@ -28,13 +28,15 @@ class OrgDocumentCommentsController < ApplicationController
end
def update
@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|
# format.html {redirect_to :}
format.html {redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id)}
end
end
def edit
@org_document = OrgDocumentComment.find(params[:id])
@organization = Organization.find(params[:organization_id])
end
def add_reply

View File

@ -25,10 +25,14 @@ class OrganizationsController < ApplicationController
end
def show
@organization = Organization.find(params[:id])
@activities = OrgActivity.where('(org_act_id = ? and org_act_type = ?) || (container_id =? and org_act_type =? and org_act_id !=?)',
@organization.id, 'CreateOrganization ', @organization.id, 'OrgDocumentComment', @organization.home_id).order('updated_at desc')
@activities = paginateHelper @activities, 10
if User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
@activities = OrgActivity.where('(org_act_id = ? and org_act_type = ?) || (container_id =? and org_act_type =? and org_act_id !=?)',
@organization.id, 'CreateOrganization ', @organization.id, 'OrgDocumentComment', @organization.home_id).order('updated_at desc')
@activities = paginateHelper @activities, 10
else
render_403
end
end
def update
@ -61,7 +65,12 @@ class OrganizationsController < ApplicationController
end
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

View File

@ -88,14 +88,14 @@ class Principal < ActiveRecord::Base
}
scope :not_member_of_org, lambda {|org|
orgs = [org] unless org.is_a?(Array)
if orgs.empty?
where("1=0")
else
ids = orgs.map(&:id)
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{OrgMember.table_name} WHERE organization_id IN (?))", ids)
end
}
orgs = [org] unless org.is_a?(Array)
if orgs.empty?
where("1=0")
else
ids = orgs.map(&:id)
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{OrgMember.table_name} WHERE organization_id IN (?))", ids)
end
}
scope :sorted, lambda { order(*Principal.fields_for_order_statement)}

View File

@ -770,6 +770,21 @@ class User < Principal
courses.to_a.include?(course)
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)
course_groups.to_a.include?(course_group)
end

View File

@ -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 %>

View File

@ -25,7 +25,9 @@
<a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">设为首页</a>
<% end %>
</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>
<%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete',:remote => true, :class => 'postOptionLink' %>
</li>

View File

@ -38,7 +38,7 @@
<div class="cl"></div>
</ul>
<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>-->
<%#= form_for( @organization,{:controller => 'organizations',:action => 'update',:id=>@organization,:html=>{:id=>'update_org_form',:method=>'put'}}) do %>
<%= labelled_form_for @organization do |f|%>
@ -55,14 +55,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]" 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>-->
<!--&lt;!&ndash;class="c_green f12" 您的申请已提交,系统会以消息的形式通知您结果 &ndash;&gt;-->
<!--</div>-->
<!--<div class="cl"></div>-->
<div class="orgRow mb10 mt5"><span style="margin-left:38px;" >公开&nbsp;: </span>
<input type="checkbox" name="organization[is_public]" <%= @organization.is_public ? 'checked': ''%> class="ml3" />
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB