we_bridge_rails_engine_orgs 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/org_department_positions.js +2 -0
- data/app/assets/javascripts/org_departments.js +2 -0
- data/app/assets/stylesheets/org_department_positions.css +4 -0
- data/app/assets/stylesheets/org_departments.css +4 -0
- data/app/controllers/org_department_positions_controller.rb +58 -0
- data/app/controllers/org_departments_controller.rb +58 -0
- data/app/helpers/org_department_positions_helper.rb +2 -0
- data/app/helpers/org_departments_helper.rb +2 -0
- data/app/models/org.rb +11 -3
- data/app/models/org_branch.rb +15 -0
- data/app/models/org_department.rb +19 -0
- data/app/models/org_department_position.rb +26 -0
- data/app/models/org_department_position_member_mapping.rb +7 -0
- data/app/models/org_department_position_text.rb +10 -0
- data/app/models/org_department_text.rb +11 -0
- data/app/models/org_member.rb +5 -0
- data/app/views/org_department_positions/_form.html.builder +14 -0
- data/app/views/org_department_positions/edit.html.builder +7 -0
- data/app/views/org_department_positions/index.html.builder +25 -0
- data/app/views/org_department_positions/new.html.builder +5 -0
- data/app/views/org_department_positions/show.html.builder +8 -0
- data/app/views/org_departments/_form.html.builder +14 -0
- data/app/views/org_departments/edit.html.builder +7 -0
- data/app/views/org_departments/index.html.builder +25 -0
- data/app/views/org_departments/new.html.builder +5 -0
- data/app/views/org_departments/show.html.builder +8 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20151204183447_create_org_departments.rb +18 -0
- data/db/migrate/20151204183612_create_org_department_positions.rb +26 -0
- data/lib/we_bridge_rails_engine_orgs/version.rb +1 -1
- data/spec/controllers/org_department_positions_controller_spec.rb +159 -0
- data/spec/controllers/org_departments_controller_spec.rb +159 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +47 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1262 -0
- data/spec/dummy/log/test.log +3269 -0
- data/spec/factories/org_department_positions.rb +6 -0
- data/spec/factories/org_departments.rb +6 -0
- data/spec/helpers/org_department_positions_helper_spec.rb +15 -0
- data/spec/helpers/org_departments_helper_spec.rb +15 -0
- data/spec/models/org_branch_spec.rb +26 -1
- data/spec/models/org_department_position_spec.rb +5 -0
- data/spec/models/org_department_spec.rb +32 -0
- data/spec/models/org_member_spec.rb +18 -1
- data/spec/models/org_spec.rb +39 -1
- data/spec/routing/org_department_positions_routing_spec.rb +39 -0
- data/spec/routing/org_departments_routing_spec.rb +39 -0
- data/spec/views/org_department_positions/edit.html.builder_spec.rb +14 -0
- data/spec/views/org_department_positions/index.html.builder_spec.rb +14 -0
- data/spec/views/org_department_positions/new.html.builder_spec.rb +14 -0
- data/spec/views/org_department_positions/show.html.builder_spec.rb +11 -0
- data/spec/views/org_departments/edit.html.builder_spec.rb +14 -0
- data/spec/views/org_departments/index.html.builder_spec.rb +14 -0
- data/spec/views/org_departments/new.html.builder_spec.rb +14 -0
- data/spec/views/org_departments/show.html.builder_spec.rb +11 -0
- metadata +65 -4
- data/spec/dummy/tmp/pids/server.pid +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14b9016374ad865cee705818e1fedcc60a6aecf7
|
4
|
+
data.tar.gz: 1fe2962883d1053edd554e5a4cf714ba72d1dd8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04cbf683c96391ab51fbcdc1b1461cc52d2d427eea06bccac18d67f3580e8fd76a47cc941394daefe037031a1dd6119e76308eda10be10d66f8e7811fc12fd8e
|
7
|
+
data.tar.gz: 3fbe31cbe763da133302f89c64de3bd28fb8f2e1c8a50b4d4b2bbc698b0bf43d140c2085a4d34842cb80adf2b786a6491ac2f62749456c662640c76d9356b7d8
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
class OrgDepartmentPositionsController < ApplicationController
|
2
|
+
before_action :set_org_department_position, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
# GET /org_department_positions
|
5
|
+
def index
|
6
|
+
@org_department_positions = OrgDepartmentPosition.all
|
7
|
+
end
|
8
|
+
|
9
|
+
# GET /org_department_positions/1
|
10
|
+
def show
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /org_department_positions/new
|
14
|
+
def new
|
15
|
+
@org_department_position = OrgDepartmentPosition.new
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET /org_department_positions/1/edit
|
19
|
+
def edit
|
20
|
+
end
|
21
|
+
|
22
|
+
# POST /org_department_positions
|
23
|
+
def create
|
24
|
+
@org_department_position = OrgDepartmentPosition.new(org_department_position_params)
|
25
|
+
|
26
|
+
if @org_department_position.save
|
27
|
+
redirect_to @org_department_position, notice: 'Org department position was successfully created.'
|
28
|
+
else
|
29
|
+
render :new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# PATCH/PUT /org_department_positions/1
|
34
|
+
def update
|
35
|
+
if @org_department_position.update(org_department_position_params)
|
36
|
+
redirect_to @org_department_position, notice: 'Org department position was successfully updated.'
|
37
|
+
else
|
38
|
+
render :edit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# DELETE /org_department_positions/1
|
43
|
+
def destroy
|
44
|
+
@org_department_position.destroy
|
45
|
+
redirect_to org_department_positions_url, notice: 'Org department position was successfully destroyed.'
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
# Use callbacks to share common setup or constraints between actions.
|
50
|
+
def set_org_department_position
|
51
|
+
@org_department_position = OrgDepartmentPosition.find(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
# Only allow a trusted parameter "white list" through.
|
55
|
+
def org_department_position_params
|
56
|
+
params[:org_department_position]
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class OrgDepartmentsController < ApplicationController
|
2
|
+
before_action :set_org_department, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
# GET /org_departments
|
5
|
+
def index
|
6
|
+
@org_departments = OrgDepartment.all
|
7
|
+
end
|
8
|
+
|
9
|
+
# GET /org_departments/1
|
10
|
+
def show
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /org_departments/new
|
14
|
+
def new
|
15
|
+
@org_department = OrgDepartment.new
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET /org_departments/1/edit
|
19
|
+
def edit
|
20
|
+
end
|
21
|
+
|
22
|
+
# POST /org_departments
|
23
|
+
def create
|
24
|
+
@org_department = OrgDepartment.new(org_department_params)
|
25
|
+
|
26
|
+
if @org_department.save
|
27
|
+
redirect_to @org_department, notice: 'Org department was successfully created.'
|
28
|
+
else
|
29
|
+
render :new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# PATCH/PUT /org_departments/1
|
34
|
+
def update
|
35
|
+
if @org_department.update(org_department_params)
|
36
|
+
redirect_to @org_department, notice: 'Org department was successfully updated.'
|
37
|
+
else
|
38
|
+
render :edit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# DELETE /org_departments/1
|
43
|
+
def destroy
|
44
|
+
@org_department.destroy
|
45
|
+
redirect_to org_departments_url, notice: 'Org department was successfully destroyed.'
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
# Use callbacks to share common setup or constraints between actions.
|
50
|
+
def set_org_department
|
51
|
+
@org_department = OrgDepartment.find(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
# Only allow a trusted parameter "white list" through.
|
55
|
+
def org_department_params
|
56
|
+
params[:org_department]
|
57
|
+
end
|
58
|
+
end
|
data/app/models/org.rb
CHANGED
@@ -3,13 +3,21 @@ require 'activerecord/mlang'
|
|
3
3
|
class Org < ActiveRecord::Base
|
4
4
|
belongs_to :lang
|
5
5
|
has_many :director_types, class_name: "OrgDirectorType"
|
6
|
-
has_many :directors,
|
7
|
-
has_many :members,
|
8
|
-
has_many :
|
6
|
+
has_many :directors, through: :director_types
|
7
|
+
has_many :members, class_name: "OrgMember"
|
8
|
+
has_many :member_types, class_name: "OrgMemberType"
|
9
|
+
has_many :member_tags, class_name: "OrgMemberTag"
|
10
|
+
has_many :activities, class_name: "OrgActivity"
|
9
11
|
include ActiveRecord::Mlang
|
10
12
|
include ActionView::Helpers::AutoTagHelper::FormInfo
|
11
13
|
set_accessible_attrs :lang_id, :email,:url,:domain,:started_on,:post_number,:tel
|
12
14
|
set_input_options :email, type: :email
|
13
15
|
set_input_options :url, type: :url
|
14
16
|
set_input_options :tel, type: :phone
|
17
|
+
|
18
|
+
def representative
|
19
|
+
tname = OrgDirectorType.table_name
|
20
|
+
self.directors.joins(:org_director_type).where("#{tname}.position" => OrgDirectorType.where(org_id: self.id).minimum(:position)).order(id: :asc).uniq.first
|
21
|
+
end
|
22
|
+
|
15
23
|
end
|
data/app/models/org_branch.rb
CHANGED
@@ -3,6 +3,11 @@ require 'activerecord/mlang'
|
|
3
3
|
class OrgBranch < ActiveRecord::Base
|
4
4
|
belongs_to :org
|
5
5
|
belongs_to :org_branch_type
|
6
|
+
has_many :branch_member_mappings, class_name: "OrgBranchMemberMapping"
|
7
|
+
has_many :members, through: :branch_member_mappings, source: :org_member
|
8
|
+
|
9
|
+
scope :has_member, ->(){ all.joins(branch_member_mappings: :org_member).uniq }
|
10
|
+
|
6
11
|
include ActiveRecord::Mlang
|
7
12
|
include ActionView::Helpers::AutoTagHelper::FormInfo
|
8
13
|
set_accessible_attrs :org_branch_type_id, :position
|
@@ -11,4 +16,14 @@ class OrgBranch < ActiveRecord::Base
|
|
11
16
|
def __display__
|
12
17
|
self.text.name + self.org_branch_type.__display__
|
13
18
|
end
|
19
|
+
|
20
|
+
# @member : OrgMember
|
21
|
+
def add(member)
|
22
|
+
member_id = case member
|
23
|
+
when Integer then member
|
24
|
+
when OrgMember then member.id
|
25
|
+
else member.to_i
|
26
|
+
end
|
27
|
+
OrgBranchMemberMapping.find_or_create_by(org_member_id: member_id, org_branch_id: self.id)
|
28
|
+
end
|
14
29
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'action_view/helpers/auto_tag_helper/form_info'
|
2
|
+
require 'activerecord/mlang'
|
3
|
+
class OrgDepartment < ActiveRecord::Base
|
4
|
+
belongs_to :org
|
5
|
+
belongs_to :manager, class_name: "OrgMember"
|
6
|
+
has_many :positions, class_name: "OrgDepartmentPosition"
|
7
|
+
has_many :position_member_mappings, through: :positions , source: :member_mappings
|
8
|
+
has_many :members, ->(){ uniq }, through: :position_member_mappings, source: :org_member
|
9
|
+
|
10
|
+
include ActiveRecord::Mlang
|
11
|
+
include ActionView::Helpers::AutoTagHelper::FormInfo
|
12
|
+
|
13
|
+
# def self.editable_columns(); [] ; end
|
14
|
+
|
15
|
+
def __display__
|
16
|
+
self.text.label
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'action_view/helpers/auto_tag_helper/form_info'
|
2
|
+
require 'activerecord/mlang'
|
3
|
+
class OrgDepartmentPosition < ActiveRecord::Base
|
4
|
+
belongs_to :org_department
|
5
|
+
has_many :member_mappings, class_name: "OrgDepartmentPositionMemberMapping"
|
6
|
+
has_many :members, through: :member_mappings, source: :org_member
|
7
|
+
|
8
|
+
include ActiveRecord::Mlang
|
9
|
+
include ActionView::Helpers::AutoTagHelper::FormInfo
|
10
|
+
|
11
|
+
# def self.editable_columns(); [] ; end
|
12
|
+
|
13
|
+
def __display__
|
14
|
+
self.text.label
|
15
|
+
end
|
16
|
+
|
17
|
+
def add(member)
|
18
|
+
member_id = case member
|
19
|
+
when OrgMember then member.id
|
20
|
+
when Integer then member
|
21
|
+
else member.to_i
|
22
|
+
end
|
23
|
+
OrgDepartmentPositionMemberMapping.find_or_create_by(org_department_position_id: self.id, org_member_id: member_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'action_view/helpers/auto_tag_helper/form_info'
|
2
|
+
require 'activerecord/mlang'
|
3
|
+
class OrgDepartmentPositionText < ActiveRecord::Base
|
4
|
+
include ActiveRecord::Mlang::Text
|
5
|
+
include ActionView::Helpers::AutoTagHelper::FormInfo
|
6
|
+
set_accessible_attrs :name, :desc
|
7
|
+
def __display__
|
8
|
+
self.name
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'action_view/helpers/auto_tag_helper/form_info'
|
2
|
+
require 'activerecord/mlang'
|
3
|
+
class OrgDepartmentText < ActiveRecord::Base
|
4
|
+
include ActiveRecord::Mlang::Text
|
5
|
+
include ActionView::Helpers::AutoTagHelper::FormInfo
|
6
|
+
set_accessible_attrs :name,:desc
|
7
|
+
def __display__
|
8
|
+
self.name
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
data/app/models/org_member.rb
CHANGED
@@ -10,6 +10,9 @@ class OrgMember < ActiveRecord::Base
|
|
10
10
|
has_many :member_tag_mappings, class_name: "OrgMemberTagMapping"
|
11
11
|
has_many :tags, through: :member_tag_mappings, source: :org_member_tag
|
12
12
|
|
13
|
+
has_many :branch_member_mappings, class_name: "OrgBranchMemberMapping"
|
14
|
+
has_many :branches, through: :branch_member_mappings, source: :org_branch
|
15
|
+
|
13
16
|
enum sex: [:male,:female, :unknown]
|
14
17
|
|
15
18
|
include ActiveRecord::Mlang
|
@@ -20,6 +23,8 @@ class OrgMember < ActiveRecord::Base
|
|
20
23
|
set_input_options :bday, min: 1, max: 31
|
21
24
|
set_input_options :sex, min: -1, max: 1
|
22
25
|
|
26
|
+
default_scope ->(){ where(retired_on: nil) }
|
27
|
+
|
23
28
|
def others
|
24
29
|
self.class.where(org_id: self.org_id).where.not(id: self.id)
|
25
30
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
form_for @org_department_position do |f|
|
2
|
+
markup{|m|
|
3
|
+
if @org_department_position.errors.any?
|
4
|
+
#error_explanation
|
5
|
+
m.h2 "#{pluralize(@org_department_position.errors.count, "error")} prohibited this org_department_position from being saved:"
|
6
|
+
m.ul do
|
7
|
+
@org_department_position.errors.full_messages.each do |message|
|
8
|
+
m.li message
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
m << f.submit
|
13
|
+
}.html_safe
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
markup do |m|
|
2
|
+
m.h1 'Listing org_department_positions'
|
3
|
+
m.table do
|
4
|
+
m.thead do
|
5
|
+
m.tr do
|
6
|
+
m.th
|
7
|
+
m.th
|
8
|
+
m.th
|
9
|
+
end
|
10
|
+
end
|
11
|
+
m.tbody do
|
12
|
+
@org_department_positions.each do |org_department_position|
|
13
|
+
m.tr do
|
14
|
+
m.td { m << link_to('Show', 'org_department_position') }
|
15
|
+
m.td { m << link_to('Edit', edit_org_department_position_path(org_department_position)) }
|
16
|
+
m.td { m << link_to('Destroy', org_department_position, data: { confirm: 'Are you sure?' }, method: :delete) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
m.br
|
23
|
+
m << link_to('New Org department position', new_org_department_position_path)
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
form_for @org_department do |f|
|
2
|
+
markup{|m|
|
3
|
+
if @org_department.errors.any?
|
4
|
+
#error_explanation
|
5
|
+
m.h2 "#{pluralize(@org_department.errors.count, "error")} prohibited this org_department from being saved:"
|
6
|
+
m.ul do
|
7
|
+
@org_department.errors.full_messages.each do |message|
|
8
|
+
m.li message
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
m << f.submit
|
13
|
+
}.html_safe
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
markup do |m|
|
2
|
+
m.h1 'Listing org_departments'
|
3
|
+
m.table do
|
4
|
+
m.thead do
|
5
|
+
m.tr do
|
6
|
+
m.th
|
7
|
+
m.th
|
8
|
+
m.th
|
9
|
+
end
|
10
|
+
end
|
11
|
+
m.tbody do
|
12
|
+
@org_departments.each do |org_department|
|
13
|
+
m.tr do
|
14
|
+
m.td { m << link_to('Show', 'org_department') }
|
15
|
+
m.td { m << link_to('Edit', edit_org_department_path(org_department)) }
|
16
|
+
m.td { m << link_to('Destroy', org_department, data: { confirm: 'Are you sure?' }, method: :delete) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
m.br
|
23
|
+
m << link_to('New Org department', new_org_department_path)
|
24
|
+
|
25
|
+
end
|