commit
8b2ed1d336
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the org_document_comment controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the OrgMember controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the org_projects controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,63 @@
|
||||
class OrgDocumentCommentsController < ApplicationController
|
||||
before_filter :find_organization, :only => [:new, :create, :show, :index]
|
||||
|
||||
layout 'base_org'
|
||||
|
||||
def new
|
||||
@org_document_comment = OrgDocumentComment.new
|
||||
end
|
||||
|
||||
def create
|
||||
@org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id)
|
||||
@org_document_comment.title = params[:org_document_comment][:title]
|
||||
@org_document_comment.content = params[:org_document_comment][:content]
|
||||
if @org_document_comment.save
|
||||
#flash[:notice] = 'success'
|
||||
OrgActivity
|
||||
redirect_to organization_org_document_comments_path(@organization)
|
||||
else
|
||||
redirect_to new_org_document_comment_path(:organization_id => @organization.id)
|
||||
end
|
||||
end
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def index
|
||||
@documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc")
|
||||
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 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
|
||||
@document = OrgDocumentComment.find(params[:id]).root
|
||||
@comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id])
|
||||
@comment.content = params[:org_content]
|
||||
@document.children << @comment
|
||||
@document.save
|
||||
end
|
||||
|
||||
def find_organization
|
||||
@organization = Organization.find(params[:organization_id])
|
||||
end
|
||||
|
||||
def destroy
|
||||
@org_document_comment = OrgDocumentComment.find(params[:id])
|
||||
org = @org_document_comment.organization
|
||||
if @org_document_comment.destroy
|
||||
if @org_document_comment.id == org.id
|
||||
org.home_id == nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,57 @@
|
||||
class OrgMemberController < ApplicationController
|
||||
|
||||
def org_member_autocomplete
|
||||
@org = Organization.find(params[:org])
|
||||
@flag = params[:flag] || false
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@org = Organization.find(params[:org])
|
||||
if params[:membership].nil?
|
||||
@fail_hint = l(:label_blank_user_lists_for_org)
|
||||
else
|
||||
member_ids = params[:membership][:user_ids]
|
||||
role_id = params[:orgRole]
|
||||
member_ids.each do |user_id|
|
||||
member = OrgMember.create(:user_id=>user_id)
|
||||
@org.org_members << member
|
||||
OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id)
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@member = OrgMember.find(params[:id])
|
||||
#@member.change_role params[:org_member][:role_ids]
|
||||
@member_role = @member.org_member_roles[0]
|
||||
@member_role.role_id = params[:org_member][:role_ids][0]
|
||||
@member_role.save
|
||||
@org = @member.organization
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
member = OrgMember.find(params[:id])
|
||||
@org = member.organization
|
||||
member.destroy
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
|
||||
end
|
||||
end
|
@ -0,0 +1,31 @@
|
||||
class OrgProjectsController < ApplicationController
|
||||
def create
|
||||
org_ids = params[:orgNames]
|
||||
@project = Project.find(params[:project_id])
|
||||
org_ids.each do |org_id|
|
||||
OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now)
|
||||
p 1
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
def destroy
|
||||
@project = Project.find(params[:project_id])
|
||||
@org_project = OrgProject.find(params[:id])
|
||||
@org_project.destroy
|
||||
|
||||
condition = '%%'
|
||||
project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:project_id]}").map(&:organization_id)
|
||||
if project_org_ids.empty?
|
||||
@orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page( 1).per(10)
|
||||
@org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count
|
||||
else
|
||||
project_org_ids = "(" + project_org_ids.join(',') + ")"
|
||||
@orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page( 1).per(10)
|
||||
@org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count
|
||||
end
|
||||
# @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count
|
||||
@orgs_page = Paginator.new @org_count, 10,1
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module OrgDocumentCommentHelper
|
||||
end
|
@ -0,0 +1,16 @@
|
||||
module OrgMemberHelper
|
||||
include ApplicationHelper
|
||||
def find_user_not_in_current_org_by_name org
|
||||
if params[:q] && params[:q].lstrip.rstrip != ""
|
||||
scope = Principal.active.sorted.not_member_of_org(org).like(params[:q])
|
||||
else
|
||||
scope = []
|
||||
end
|
||||
principals = paginateHelper scope,10
|
||||
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')
|
||||
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
|
||||
link_to text, org_member_autocomplete_org_member_index_path(parameters.merge(:q => params[:q],:flag => true,:org=> org, :format => 'js')), :remote => true
|
||||
}
|
||||
s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" )
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module OrgProjectsHelper
|
||||
end
|
@ -1,2 +1,20 @@
|
||||
# encoding: utf-8
|
||||
module OrganizationsHelper
|
||||
include ApplicationHelper
|
||||
|
||||
|
||||
def find_user_not_in_current_org_by_name org
|
||||
if params[:q] && params[:q].lstrip.rstrip != ""
|
||||
scope = Principal.active.sorted.not_member_of_org(org).like(params[:q])
|
||||
else
|
||||
scope = []
|
||||
end
|
||||
principals = paginateHelper scope,10
|
||||
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')
|
||||
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
|
||||
link_to text, org_member_autocomplete_org_member_index_path( parameters.merge(:q => params[:q],:flag => true,:org=>org, :format => 'js')), :remote => true
|
||||
}
|
||||
s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" )
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -0,0 +1,5 @@
|
||||
class OrgActivity < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
belongs_to :org_act ,:polymorphic => true
|
||||
belongs_to :container,:polymorphic => true
|
||||
end
|
@ -0,0 +1,16 @@
|
||||
class OrgDocumentComment < ActiveRecord::Base
|
||||
attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title,:sticky,:locked
|
||||
include Redmine::SafeAttributes
|
||||
belongs_to :organization
|
||||
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
|
||||
|
||||
acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc"
|
||||
has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy
|
||||
after_create :document_save_as_org_activity
|
||||
|
||||
def document_save_as_org_activity
|
||||
if(self.parent().nil?)
|
||||
self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.organization.id, :container_type => 'Organization')
|
||||
end
|
||||
end
|
||||
end
|
@ -1,4 +1,8 @@
|
||||
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
|
||||
|
||||
end
|
||||
|
@ -0,0 +1,5 @@
|
||||
class OrgMemberRole < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
belongs_to :org_member
|
||||
belongs_to :role
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class OrgProject < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
belongs_to :organization
|
||||
belongs_to :project
|
||||
end
|
@ -1,5 +1,14 @@
|
||||
class Organization < ActiveRecord::Base
|
||||
attr_accessible :name, :description, :creator_id, :home_id, :domain, :is_public
|
||||
has_many :org_members, :dependent => :destroy
|
||||
has_many :projects
|
||||
has_many :org_projects ,:dependent => :destroy
|
||||
has_many :projects,:through => :org_projects
|
||||
has_many :org_document_comments, :dependent => :destroy
|
||||
has_many :users, :through => :org_members
|
||||
validates_uniqueness_of :name
|
||||
after_create :save_as_org_activity
|
||||
|
||||
def save_as_org_activity
|
||||
OrgActivity.create(:user_id => User.current.id, :org_act_id => self.id, :org_act_type => 'CreateOrganization', :container_id => self.id, :container_type => 'Organization')
|
||||
end
|
||||
end
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue