cm-admin 2.1.2 → 2.1.3
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/models/cm_permission.rb +5 -6
- data/lib/cm_admin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c68983444fcc76457f2f9c67844a6518d39a6e1a9f4656d5e869188d517ae1b7
|
4
|
+
data.tar.gz: 6dda9b94f136c52dba561e65b31db92b4a2b9036f078d2d1aaf66d1c972a49ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb734f37af1c3a6204c6b5e6aa04530410cafd8f1bb208457ae84bbf452a1b2811154acab9a7b330bfad42d7ded483f9c58c7a0f51a5c490ca7ad77a7ce5679
|
7
|
+
data.tar.gz: 3e27a73e792d282d2d8f334716c7a56692ed3f11af67eddcbccfe529f8fc117833d6aee191673b3cf44edc4af5b768d8ce3b03264e4ac366cf5560f6a348b9ed
|
data/Gemfile.lock
CHANGED
data/app/models/cm_permission.rb
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
class CmPermission < ApplicationRecord
|
2
|
-
|
3
2
|
after_create :create_hidden_permission
|
4
3
|
after_destroy :destroy_hidden_permission
|
5
4
|
|
6
|
-
validates :action_name, presence: true, uniqueness: {scope:
|
5
|
+
validates :action_name, presence: true, uniqueness: { scope: %i[ar_model_name cm_role_id] }
|
7
6
|
|
8
7
|
def create_hidden_permission
|
9
8
|
if action_name == 'new'
|
10
|
-
CmPermission.where(action_name: 'create', ar_model_name
|
9
|
+
CmPermission.where(action_name: 'create', ar_model_name:, cm_role_id:).first_or_create
|
11
10
|
elsif action_name == 'edit'
|
12
|
-
CmPermission.where(action_name: 'update', ar_model_name
|
11
|
+
CmPermission.where(action_name: 'update', ar_model_name:, cm_role_id:).first_or_create
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
def destroy_hidden_permission
|
17
16
|
if action_name == 'new'
|
18
|
-
CmPermission.where(action_name: 'create', ar_model_name
|
17
|
+
CmPermission.where(action_name: 'create', ar_model_name:, cm_role_id:).first&.destroy
|
19
18
|
elsif action_name == 'edit'
|
20
|
-
CmPermission.where(action_name: 'update', ar_model_name
|
19
|
+
CmPermission.where(action_name: 'update', ar_model_name:, cm_role_id:).first&.destroy
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
data/lib/cm_admin/version.rb
CHANGED