组织功能实现及缺陷修改

This commit is contained in:
ouyangxuhua 2015-11-12 20:57:41 +08:00
parent 7dc02d2c4f
commit 6ec27761fb
12 changed files with 103 additions and 44 deletions

View File

@ -1,6 +1,6 @@
# encoding: utf-8
class OrganizationsController < ApplicationController
before_filter :find_organization, :only => [:show]
before_filter :find_organization, :only => [:show, :members]
layout 'base_org'
def index
@ -25,7 +25,7 @@ class OrganizationsController < ApplicationController
end
def show
if User.current.admin? || User.current.member_of_org?(@organization)
if @organization.is_public? || 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')
@ -50,6 +50,7 @@ class OrganizationsController < ApplicationController
def check_uniq
@check = false;
@org_name = params[:org_name].strip
@config_page = params[:config_page]
sameName = @config_page ? Organization.where('name = ? and id != ?',params[:org_name],params[:org_id].to_i).count == 0 : Organization.where('name = ?',params[:org_name]).count == 0
if sameName == true
@ -91,4 +92,8 @@ class OrganizationsController < ApplicationController
format.js
end
end
def members
@members = OrgMember.where("organization_id =?", @organization.id)
end
end

View File

@ -1,6 +1,7 @@
class OrgMember < ActiveRecord::Base
attr_accessible :organization_id, :role, :user_id
belongs_to :organization
belongs_to :user
has_many :roles ,:through => :org_member_roles,:foreign_key => 'role_id'
has_many :org_member_roles,:dependent => :destroy

View File

@ -97,6 +97,7 @@ class User < Principal
has_many :org_document_comments, :dependent =>:destroy
has_one :api_token, :class_name => 'Token', :conditions => "action='api'"
belongs_to :auth_source
has_many :org_members
belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang
## added by xianbo for delete
# has_many :biding_projects, :dependent => :destroy

View File

@ -86,6 +86,9 @@
<li>
<%= link_to "修改资料", my_account_path, :class => "menuGrey"%>
</li>
<li>
<%= link_to "新建组织", new_organization_path, :class => "menuGrey"%>
</li>
<!--<li><a href="javascript:void(0);" class="menuGrey">账号设置</a> </li>-->
<li>
<%= link_to "退出",signout_path,:class => "menuGrey",:method => "post"%>

View File

@ -55,13 +55,16 @@
<div class="cl"></div>
<div class="f12 fontGrey3">
<%= link_to '文章', organization_org_document_comments_path(@organization) %>&nbsp;(&nbsp;
<%= link_to '文章', organization_org_document_comments_path(@organization) %>&nbsp;(
<%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %>
&nbsp;)&nbsp;|&nbsp;成员&nbsp;(&nbsp;<%= @organization.org_members.count %> &nbsp;)
)&nbsp;|&nbsp;
<%= link_to '成员', members_organization_path(@organization.id ) %>&nbsp;<%= @organization.org_members.count %> )
</div>
</div>
<div class="homepageLeftMenuContainer">
<div class="homepageLeftMenuBlock"><a href="javascript:void(0);" class="homepageMenuText">动态</a></div>
<div class="homepageLeftMenuBlock">
<%= link_to "动态",organization_path(@organization), :class => "homepageMenuText" %>
</div>
<div class="homepageLeftMenuBlock"><a href="javascript:void(0);" class="homepageMenuText">项目</a><a href="javascript:void(0);" class="homepageMenuSetting fr" title="关联您的已有项目"></a></div>
<div class="homepageLeftMenuCourses borderBottomNone">
<ul style="display:none;">

View File

@ -1,14 +1,24 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%>
<script>
function check_org_title(title)
function check_org_title()
{
if($("#document_title").val().trim() == "")
{
$("#doc_title_hint").html("<span class='c_red'>标题不能为空</span>").show();
return false;
}
else
{
$("#doc_title_hint").hide();
return true;
}
}
function create_org_document()
{
if(check_org_title() == true)
{
org_document_description_editor.sync();
$('#new_org_document_form').submit();
}
}
</script>
@ -30,7 +40,7 @@
<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>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="create_org_document();">确定</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>

View File

@ -0,0 +1,26 @@
<%= stylesheet_link_tag 'courses' %>
<div class="project_r_h">
<h2 class="project_h2"> 组织成员</h2>
</div>
<div class="st_list">
<div class="st_box">
<div class="cl"></div><!--st_box_top end-->
<% members.each do |member| %>
<div class="st_boxlist">
<a href="javascript:" class="st_img">
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %>
</a>
<span class="fl ml10 c_grey"><%= l(:label_username)%></span>
<%= link_to(member.user.show_name, user_path(member.user),:class => "ml10 c_blue02") %>
<span class="fr c_grey mr30 w45"><%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %></span>
</div>
<div class="cl"></div>
<% end%>
<ul class="wlist">
<%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<div class="cl"></div>
</div>
</div>

View File

@ -16,28 +16,32 @@
<%= document.content.html_safe %>
</div>
<% end %>
<div class="homepagePostSetting">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= form_for('new_form',:url => {:controller => 'organizations',:action => 'set_homepage',:id => document.organization_id, :home_id => document.id},:method => "put",:remote => true) do |f|%>
<a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">设为首页</a>
<% end %>
</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' %>
<% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id) || User.current.id == document.creator_id) %>
<div class="homepagePostSetting">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= form_for('new_form',:url => {:controller => 'organizations',:action => 'set_homepage',:id => document.organization_id, :home_id => document.id},:method => "put",:remote => true) do |f|%>
<a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">设为首页</a>
<% end %>
</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',
:data => {:confirm => l(:text_are_you_sure)},
:remote => true, :class => 'postOptionLink' %>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="cl"></div>
</div>
</div>
</div>
<div class="cl"></div>
</div>
<% end %>
<% comments_for_doc = document.children.reorder("created_at desc") %>
<% count = document.children.count() %>

View File

@ -1,18 +1,22 @@
<%if @check == false %>
$checkName = false
<% if @config_page%>
$("#check_name_hint").html('<span class="c_red">名字不能重复<span>').show();
<% else%>
$("#organization_name_notice").html('<span class="c_red">名字不能重复<span>').show();
<% if !@org_name.blank? %>
<%if @check == false %>
$checkName = false
<% if @config_page%>
$("#check_name_hint").html('<span class="c_red">名字不能重复<span>').show();
<% else%>
$("#organization_name_notice").html('<span class="c_red">名字不能重复<span>').show();
<%end%>
<% else %>
$checkName = true;
<% if @config_page%>
$("#check_name_hint").html('<span class="c_green">名字可以使用</span>').show();
<% else%>
$("#organization_name_notice").html('<span class="c_green">名字可以使用</span>').show();
<%end%>
<%end%>
<% else %>
$checkName = true;
<% if @config_page%>
$("#check_name_hint").html('<span class="c_green">名字可以使用</span>').show();
<% else%>
$("#organization_name_notice").html('<span class="c_green">名字可以使用</span>').show();
<%end%>
<%end%>
$("#check_name_hint").html('<span class="c_green">名字不能为空</span>').show();
<% end %>

View File

@ -0,0 +1 @@
<%= render :partial => 'org_members', :locals => {:members => @members, :organization => @organization} %>

View File

@ -48,8 +48,8 @@
<script>
//////////////////////////////////////////////////////////////
//新建项目
//验证项目名称
//新建组织
//验证组织名称
function regex_organization_name()
{
var name = $.trim($("#organization_name").val());

View File

@ -36,6 +36,7 @@ RedmineApp::Application.routes.draw do
get 'setting'#, :action => 'settings', :as => 'settings'
get 'clear_org_avatar_temp'
put 'set_homepage'
get 'members'
end
collection do
get 'check_uniq'