we_bridge_rails_engine_orgs 0.1.0 → 0.1.1
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/controllers/concerns/org_common.rb +17 -0
- data/app/controllers/org_activities_controller.rb +1 -4
- data/app/controllers/org_branch_types_controller.rb +1 -5
- data/app/controllers/org_branches_controller.rb +1 -5
- data/app/controllers/org_director_types_controller.rb +1 -4
- data/app/controllers/org_directors_controller.rb +1 -4
- data/app/controllers/org_member_tags_controller.rb +1 -4
- data/app/controllers/org_member_types_controller.rb +1 -4
- data/app/controllers/org_members_controller.rb +1 -4
- data/app/controllers/orgs_controller.rb +0 -1
- data/app/models/org_activity.rb +8 -1
- data/app/models/org_activity_text.rb +1 -1
- data/app/models/org_branch.rb +4 -0
- data/app/models/org_branch_text.rb +1 -1
- data/app/models/org_branch_type.rb +3 -1
- data/app/models/org_branch_type_text.rb +1 -1
- data/app/models/org_director_type.rb +11 -1
- data/app/models/org_director_type_text.rb +1 -1
- data/app/models/org_member.rb +17 -2
- data/app/models/org_member_tag.rb +7 -1
- data/app/models/org_member_tag_text.rb +1 -1
- data/app/models/org_member_type.rb +6 -1
- data/app/models/org_member_type_text.rb +1 -1
- data/app/views/common/_show.html.builder +9 -1
- data/app/views/org_activities/show.html.builder +1 -9
- data/app/views/org_branch_types/show.html.builder +1 -9
- data/app/views/org_branches/show.html.builder +1 -9
- data/app/views/org_director_types/show.html.builder +1 -9
- data/app/views/org_directors/show.html.builder +1 -9
- data/app/views/org_member_tags/show.html.builder +1 -9
- data/app/views/org_member_types/show.html.builder +1 -9
- data/app/views/org_members/show.html.builder +1 -9
- data/db/migrate/20150812025526_create_orgs.rb +2 -1
- data/db/migrate/20150814183339_create_org_branches_table.rb +8 -0
- data/lib/we_bridge_rails_engine_orgs/engine.rb +1 -0
- data/lib/we_bridge_rails_engine_orgs/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +24 -11
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +12129 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/3Gnkt_WJKoZJxixiYdm_FIRiS44X26Fu9fJJm7IHDG4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/57fly2mMC5ZRdxrJ0HMn68Dl8x8iWwoS1Wl0LthDHD8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6y2OXokkg_bBTgy9MnXOUhmmNC_dKCmJyKi_HMlQcSg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/9eeDXBwks5hHIZjdTNgcuNP2q1NieK4zl689cIWcVLo.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/9wUrLTpniuw3vFR8aaAAw3_KGA_MSofFcrT9TXvxZTY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/BCCvFrpyQECuSQFKRT6jwzLiPCHOaeWWrY81UH4GgXM.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Bt3QK9WXyQB08iE6IHK467jLG-93g4iaaaUBvfdzW9Q.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/D5gJ473aeV5oBcADjXr33ksUZTtZFdqbCA4rBWjMk6w.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/EGxE11Csn4xINTN_ugWXEpqOWr5pnwCfQuE17O8HnVc.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ELy3x34dthmYWMX3OgukmfqAiHx64bR_CMBF3NMGYnk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/EbrKuAOW1QpjGt2Iv2jeTaOGLBJc2Egi9shVVmdeERs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Hxow6764dYGwoCc-uvAIYuGN4HOylgF2on4fI_5yAPw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/JigkThideDLksj6ZrufTx6bLVyJBmNDbaouRbMbZdIA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/KkUWVglyAhTcj7j_Z_ALDsTxv1yg01qQ37vKUKW6NGY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Ku_V2tcnT_d-kZlCfXQgbhcG1MeKgDHX5K11qHXyY_A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/LDJY3T1TzDJaQmbrrDKq2b8Q8abMypZcHLZByDlpTrY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/LjWpbU6EpEYPafClHpZwV-CSBuUAKtw2VUTN__8BcqU.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/MYpL_S8fFtwDaIQlZS0tzHLCSvNoN2X2CHM3y5UI2vc.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/NpnEH-utlsgBAxVhT3-R4bCCqJ9_yisNYylIosRd0WY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/P6jJYd5nnvfCh5qCaOgKN4dYlJ92L2Rh4WjjdoZNJYg.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/QofpelZU6FjjxNs1Hu0JXtH7tRd7AyZJRxC1Uh8Sw-E.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/S7S5i_gDuGZ_zzm8DiNcIGt5ZkPEbslqYN6TFhCerzU.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/UOZrHC0gWtaDCl5XyhKdGr6kRZnDjrS5p1GmuTpGc_M.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/fBngxGbUQ45W5xkhfLE01MuMcBlhhkBNApm0dyuI5EE.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/g0Tk0OFLRI6eoF9xJOzK6ylrZ1rXj7elN7aIn2bEca4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/gL0gVZhLKEJhjgrNRxdoynZiPTZg6VQR0MdYz32GdDM.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/gjVFqYSxl63XPv_1FOOAQ64RfaAtkLHv1n9LiMBIpvw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/iLYNAzvIFMiMfLolPyhu--fVUT7WuJbsT4TcOMR7qKs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/rAssroOSxTjJ76HXZeMXD-7MijqdtSMrB7BWdOt7Z_M.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/s7AiRxV9LdOVAylAE38RiKCstOIGXxlkhZ15nV8_GfY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/uYE73cVE-RVipcx1xUC186KW80krIF-TVc_eQHE5BGU.cache +1 -0
- data/spec/dummy/tmp/pids/server.pid +1 -1
- metadata +61 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ed538429408a472c71a28894c57902ecb32edf7
|
4
|
+
data.tar.gz: f40da9c37dbd11b0bf39a8d5e153cdbcc8edaefb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c0fb690cb3ef788cb9668fb14fcaa8293266f0ee5aa7cdc7e0a1abfaafb535f3a2285f545036f68e911ee3f1f0e1f3b55a45f6cfd53dfead5bac2af4dd2abfa
|
7
|
+
data.tar.gz: 4d57d9219c54401e170a4823b07585375c31b9c462ff38f48c8fc10eb96afb71eda22641dd11faaf3bf7f47993346ef2cbd26dc18eddd57504a18aaf49f89eb1
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module OrgCommon
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
included do
|
4
|
+
# class_attribute :org_id_key
|
5
|
+
class << self; attr_accessor :org_id_key; end
|
6
|
+
before_action { @org = Org.find(params[self.class.org_id_key || :org_id]) }
|
7
|
+
before_action only: [:edit,:update,:destroy] do
|
8
|
+
login_required
|
9
|
+
# check_current_user(@record)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def record_params
|
14
|
+
super.tap{|rtn| rtn[:org_id] ||= @org.id }
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -1,9 +1,5 @@
|
|
1
1
|
class OrgBranchTypesController < ApplicationController
|
2
2
|
include WeBridge::AutoViewHelper::Controller
|
3
3
|
set_model OrgBranchType
|
4
|
-
|
5
|
-
before_action only: [:edit,:update,:destroy] do
|
6
|
-
login_required
|
7
|
-
# check_current_user(@record)
|
8
|
-
end
|
4
|
+
include OrgCommon
|
9
5
|
end
|
@@ -1,9 +1,5 @@
|
|
1
1
|
class OrgBranchesController < ApplicationController
|
2
2
|
include WeBridge::AutoViewHelper::Controller
|
3
3
|
set_model OrgBranch
|
4
|
-
|
5
|
-
before_action only: [:edit,:update,:destroy] do
|
6
|
-
login_required
|
7
|
-
# check_current_user(@record)
|
8
|
-
end
|
4
|
+
include OrgCommon
|
9
5
|
end
|
data/app/models/org_activity.rb
CHANGED
@@ -4,5 +4,12 @@ class OrgActivity < ActiveRecord::Base
|
|
4
4
|
belongs_to :org
|
5
5
|
include ActiveRecord::Mlang
|
6
6
|
include ActionView::Helpers::AutoTagHelper::FormInfo
|
7
|
-
|
7
|
+
set_accessible_attrs :position
|
8
|
+
def <=>(other)
|
9
|
+
self.position <=> (other.try(:position) || self.position + 1)
|
10
|
+
end
|
11
|
+
|
12
|
+
def __display__
|
13
|
+
self.text.label
|
14
|
+
end
|
8
15
|
end
|
data/app/models/org_branch.rb
CHANGED
@@ -4,7 +4,9 @@ class OrgBranchType < ActiveRecord::Base
|
|
4
4
|
belongs_to :org
|
5
5
|
include ActiveRecord::Mlang
|
6
6
|
include ActionView::Helpers::AutoTagHelper::FormInfo
|
7
|
-
|
7
|
+
set_accessible_attrs :position
|
8
|
+
set_input_options :position, min: 0
|
9
|
+
|
8
10
|
def __display__
|
9
11
|
self.text.label
|
10
12
|
end
|
@@ -3,7 +3,7 @@ require 'activerecord/mlang'
|
|
3
3
|
class OrgBranchTypeText < ActiveRecord::Base
|
4
4
|
include ActiveRecord::Mlang::Text
|
5
5
|
include ActionView::Helpers::AutoTagHelper::FormInfo
|
6
|
-
|
6
|
+
set_accessible_attrs :label, :desc
|
7
7
|
end
|
8
8
|
|
9
9
|
|
@@ -4,8 +4,18 @@ class OrgDirectorType < ActiveRecord::Base
|
|
4
4
|
belongs_to :org
|
5
5
|
include ActiveRecord::Mlang
|
6
6
|
include ActionView::Helpers::AutoTagHelper::FormInfo
|
7
|
-
|
7
|
+
set_accessible_attrs :position, :limit
|
8
|
+
validates :limit, length: {minimum: 1}
|
9
|
+
set_input_options :limit, min: 0
|
10
|
+
|
11
|
+
validates :position, length: {minimum: 0}
|
12
|
+
set_input_options :position, min: 0
|
13
|
+
|
8
14
|
def <=>(other)
|
9
15
|
self.position <=> (other.try(:position) || self.position + 1)
|
10
16
|
end
|
17
|
+
|
18
|
+
def __display__
|
19
|
+
self.text.try(:label).to_s
|
20
|
+
end
|
11
21
|
end
|
data/app/models/org_member.rb
CHANGED
@@ -8,12 +8,27 @@ class OrgMember < ActiveRecord::Base
|
|
8
8
|
|
9
9
|
include ActiveRecord::Mlang
|
10
10
|
include ActionView::Helpers::AutoTagHelper::FormInfo
|
11
|
-
set_accessible_attrs :lang_id, :handle_name, :byear, :bmonth, :bday, :entried_on, :sex, :expire_at, :retired_on
|
11
|
+
set_accessible_attrs :lang_id, :org_director_type_id, :org_member_type_id, :handle_name, :byear, :bmonth, :bday, :entried_on, :sex, :expire_at, :retired_on
|
12
12
|
set_input_options :byear, min: Time.now.year - 120, max: Time.now.year
|
13
13
|
set_input_options :bmonth, min: 1, max: 12
|
14
14
|
set_input_options :bday, min: 1, max: 31
|
15
15
|
set_input_options :sex, min: -1, max: 1
|
16
16
|
|
17
|
+
def others
|
18
|
+
self.class.where(org_id: self.org_id).where.not(id: self.id)
|
19
|
+
end
|
20
|
+
|
21
|
+
before_save do
|
22
|
+
if changed_attributes[:org_director_type_id]
|
23
|
+
limit = OrgDirectorType.select(:limit).where(id: self.org_director_type_id).first.limit
|
24
|
+
if limit < 1 || others.where(org_director_type_id: self.org_director_type_id).count < limit
|
25
|
+
# no problem
|
26
|
+
else
|
27
|
+
raise WeBridge::Exceptions::ForbiddenError
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
17
32
|
def <=>(other)
|
18
33
|
[:director_type, :member_type, :entried_on, :created_at].inspect(nil){|rtn,m| rtn || (self.try(m) <=> other.try(m)).to_i.nonzero? }
|
19
34
|
end
|
@@ -23,6 +38,6 @@ class OrgMember < ActiveRecord::Base
|
|
23
38
|
end
|
24
39
|
|
25
40
|
def real_name
|
26
|
-
self.text(self.lang_id
|
41
|
+
self.text(self.lang_id).try(:name).to_s
|
27
42
|
end
|
28
43
|
end
|
@@ -4,5 +4,11 @@ class OrgMemberTag < ActiveRecord::Base
|
|
4
4
|
belongs_to :org
|
5
5
|
include ActiveRecord::Mlang
|
6
6
|
include ActionView::Helpers::AutoTagHelper::FormInfo
|
7
|
-
|
7
|
+
|
8
|
+
def self.editable_columns(); [] ; end
|
9
|
+
|
10
|
+
def __display__
|
11
|
+
self.text.label
|
12
|
+
end
|
13
|
+
|
8
14
|
end
|
@@ -4,8 +4,13 @@ class OrgMemberType < ActiveRecord::Base
|
|
4
4
|
belongs_to :org
|
5
5
|
include ActiveRecord::Mlang
|
6
6
|
include ActionView::Helpers::AutoTagHelper::FormInfo
|
7
|
-
|
7
|
+
set_accessible_attrs :position
|
8
8
|
def <=>(other)
|
9
9
|
self.position <=> (other.try(:position) || self.position + 1)
|
10
10
|
end
|
11
|
+
|
12
|
+
def __display__
|
13
|
+
self.text.label
|
14
|
+
end
|
15
|
+
|
11
16
|
end
|
@@ -1 +1,9 @@
|
|
1
|
-
|
1
|
+
markup do |m|
|
2
|
+
m.div do
|
3
|
+
m.ul do
|
4
|
+
m.li do
|
5
|
+
m.a "Show members", href: url_for(controller: :org_members, action: :index, org_id: (@org || @record).id)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end + show_common(@record, show_path: url_for(action: :show, id: @record.id), back_path: url_for(action: :index), edit_path: url_for(action: :edit, id: @record.id))
|
@@ -25,13 +25,14 @@ class CreateOrgs < ActiveRecord::Migration
|
|
25
25
|
|
26
26
|
create_table :org_activities do |t|
|
27
27
|
t.integer :org_id , null: false
|
28
|
+
t.integer :position, null: false, default: 0
|
28
29
|
t.timestamps null: false
|
29
30
|
end
|
30
31
|
|
31
32
|
create_table :org_activity_texts do |t|
|
32
33
|
t.integer :parent_id, null: false
|
33
34
|
t.integer :lang_id, null: false
|
34
|
-
t.string :label
|
35
|
+
t.string :label
|
35
36
|
t.text :description
|
36
37
|
t.timestamps null: false
|
37
38
|
end
|