effective_organizations 0.1.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ed8ea76f6be605f32e951431171d7be4d5c9885adf3adaa51ebd223ad2faa95
4
- data.tar.gz: '08a0fa735dc997d95203d90abd6c5657855b6e957b00802800222cf8cfe00d5c'
3
+ metadata.gz: 2ce60402fb05740c64591e80c230f056c38f2de281f46535ac9a28830a3bd15d
4
+ data.tar.gz: 983747000777d6a206be7b703885c5826407fcbff1a25c540f99d7869a3328cc
5
5
  SHA512:
6
- metadata.gz: 31c96c8af942654f9d314326363228f2cead96f47cd0f7e32f256d7a2362e7e5601bdeb35be78c5bf102c8bfa21d6adfe61664cb991e1d10effe2de937aeef36
7
- data.tar.gz: 62ebff63f53a735bb6d185648611d40f717dd469ea03f7f5cb62be5c6027d0248f10f77a38fc8ae2f8bea82d3c2eac9887ead68d847c8fffecaf71032d83d399
6
+ metadata.gz: eed049b33149af44daf3d148f4dce7398c26a9b5777c157c2587332edefd86059ea377fae4825ad858f3687dc20c7e2c4d63d2f58ff8f940f70a899079ab4dd3
7
+ data.tar.gz: 2d66e0a1b52951e3e5e9c73d623ea1df9ba92cadf8bc2b63efc7abd0892cb79e8764b74f1b97458e8e15eec7b06300997a84e822378b3983a427b4601ff7daca
@@ -5,8 +5,10 @@ class EffectiveRepresentativesDatatable < Effective::Datatable
5
5
  col :organization
6
6
  col :user
7
7
 
8
- col :email do |representative|
9
- mail_to(representative.user.email)
8
+ unless attributes[:user_id]
9
+ col :email do |representative|
10
+ mail_to(representative.user.email)
11
+ end
10
12
  end
11
13
 
12
14
  col :roles, search: roles_collection
@@ -32,10 +32,15 @@ module EffectiveOrganizationsOrganization
32
32
 
33
33
  effective_resource do
34
34
  title :string
35
+ email :string
36
+
35
37
  category :string
36
38
 
37
39
  notes :text
38
40
 
41
+ roles_mask :integer
42
+ archived :boolean
43
+
39
44
  representatives_count :integer # Counter cache
40
45
 
41
46
  timestamps
@@ -48,6 +53,9 @@ module EffectiveOrganizationsOrganization
48
53
  end
49
54
 
50
55
  # Instance Methods
56
+ def to_s
57
+ title.presence || 'organization'
58
+ end
51
59
 
52
60
  def representative(user:)
53
61
  representatives.find { |rep| rep.user_id == user.id }
@@ -26,6 +26,11 @@ module Effective
26
26
  user.password ||= SecureRandom.base64(12) + '!@#123abcABC-'
27
27
  end
28
28
 
29
+ after_commit(on: [:create, :destroy], if: -> { user.class.respond_to?(:effective_memberships_owner?) }) do
30
+ user.representatives.reload
31
+ user.update_member_role!
32
+ end
33
+
29
34
  validates :organization, presence: true
30
35
  validates :user, presence: true
31
36
 
@@ -5,5 +5,5 @@
5
5
 
6
6
  - if organization.persisted?
7
7
  %h2 Representatives
8
- - datatable = Admin::EffectiveRepresentativesDatatable.new(organization_id: organization.id, organization_type: organization.class.name)
8
+ - datatable = Admin::EffectiveRepresentativesDatatable.new(organization: organization)
9
9
  = render_inline_datatable(datatable)
@@ -6,7 +6,7 @@ EffectiveOrganizations.setup do |config|
6
6
  # Configure the Layout per controller, or all at once
7
7
  # config.layout = { application: 'application', admin: 'admin' }
8
8
 
9
- # Membership Categories Settings
9
+ # Organization Settings
10
10
  # Configure the class responsible for the organization.
11
11
  # config.organization_class_name = 'Effective::Organization'
12
12
  end
data/config/routes.rb CHANGED
@@ -12,7 +12,11 @@ EffectiveOrganizations::Engine.routes.draw do
12
12
  end
13
13
 
14
14
  namespace :admin do
15
- resources :organizations, except: [:show]
15
+ resources :organizations, except: [:show, :destroy] do
16
+ post :archive, on: :member
17
+ post :unarchive, on: :member
18
+ end
19
+
16
20
  resources :representatives, except: [:show]
17
21
  end
18
22
 
@@ -1,23 +1,28 @@
1
1
  class CreateEffectiveOrganizations < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  # Organizations
4
- create_table :organizations do |t|
4
+ create_table <%= @organizations_table_name %> do |t|
5
5
  t.string :title
6
6
 
7
7
  t.string :category
8
+ t.string :email
8
9
  t.text :notes
9
10
 
10
- t.integer :representatives_count, default: 0
11
+ t.integer :roles_mask
12
+ t.boolean :archived, default: false
13
+
14
+ t.integer :representatives_count, default: 0
11
15
 
12
16
  t.datetime :updated_at
13
17
  t.datetime :created_at
14
18
  end
15
19
 
16
- add_index :organizations, :title
20
+ add_index <%= @organizations_table_name %>, :title
17
21
 
18
22
  # Representatives
19
- create_table :representatives do |t|
23
+ create_table <%= @representatives_table_name %> do |t|
20
24
  t.integer :organization_id
25
+ t.string :organization_type
21
26
 
22
27
  t.integer :user_id
23
28
  t.string :user_type
@@ -28,8 +33,8 @@ class CreateEffectiveOrganizations < ActiveRecord::Migration[6.0]
28
33
  t.datetime :created_at
29
34
  end
30
35
 
31
- add_index :representatives, [:organization_id]
32
- add_index :representatives, [:user_id, :user_type]
36
+ add_index <%= @representatives_table_name %>, [:organization_id, :organization_type]
37
+ add_index <%= @representatives_table_name %>, [:user_id, :user_type]
33
38
 
34
39
  end
35
40
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrganizations
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_organizations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails