adeia 0.11.0 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/lib/adeia/controller_resource.rb +4 -4
- data/lib/adeia/helpers/user_helper.rb +14 -1
- data/lib/adeia/version.rb +1 -1
- data/lib/tasks/init.rake +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d27952eb40a8808b7ba846ff9dd9a3e6360006d
|
4
|
+
data.tar.gz: 01adea387c3d8b18791f877b569158e7eb87f0c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4abec95b33ba33e13336f0b7672657b3ee0bc252de077abb646be3721ceaf672d85a58d5ae89c15b91a1691e5307447c43045d16dc820cd386c5991536a9b9b1
|
7
|
+
data.tar.gz: 190837048b0ea27bcf8ffb9c2c957e654d4e6b55f978b7eb4b07a1e5332378115c336aaaae9a0dcaacb4ffa33ad38704bb4ec66514e0e5744193285fc854ff7b
|
data/README.md
CHANGED
@@ -26,6 +26,12 @@ Then include the engine's routes in your `routes.rb`. The URL on which you mount
|
|
26
26
|
mount Adeia::Engine => "/adeia"
|
27
27
|
```
|
28
28
|
|
29
|
+
### Tasks
|
30
|
+
|
31
|
+
The first task to run is `rake adeia:permissions elements="first_element, second_element"`. It creates the given elements in the database and a superadmin group which has all the permissions.
|
32
|
+
Then you can run `adeia:superuser user_id=your_id`, which add the given user in the superadmin group.
|
33
|
+
If you need to add new groups, run `adeia:groups groups="first_group, second_group"`.
|
34
|
+
|
29
35
|
## Requirements
|
30
36
|
|
31
37
|
Requires a User model with:
|
@@ -141,6 +147,13 @@ class EventsController < ApplicationController
|
|
141
147
|
end
|
142
148
|
```
|
143
149
|
|
144
|
-
###
|
150
|
+
### Controller methods
|
145
151
|
|
146
152
|
When an authorization exception is raised by the engine, it automatically store the current user's location in a cookie. The called method is `store_location` and is available in your controllers. Then you can use the method `redirect_back_or(default, message = nil)` which either redirects to the stored location if any or redirects the default provided path, with an optional message.
|
153
|
+
|
154
|
+
## Model methods
|
155
|
+
|
156
|
+
TODO
|
157
|
+
|
158
|
+
* User model
|
159
|
+
* Permission model
|
@@ -38,7 +38,7 @@ module Adeia
|
|
38
38
|
|
39
39
|
def load_resource
|
40
40
|
begin
|
41
|
-
@resource
|
41
|
+
@resource ||= resource_class.find(@controller.params.fetch(:id))
|
42
42
|
@controller.instance_variable_set("@#{resource_name}", @resource)
|
43
43
|
rescue KeyError
|
44
44
|
raise MissingParams.new(:id)
|
@@ -81,9 +81,9 @@ module Adeia
|
|
81
81
|
|
82
82
|
def resource_class
|
83
83
|
begin
|
84
|
-
@
|
84
|
+
@controller_name.classify.constantize
|
85
85
|
rescue NameError
|
86
|
-
@
|
86
|
+
@controller_name.classify.demodulize.constantize
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -118,4 +118,4 @@ module Adeia
|
|
118
118
|
|
119
119
|
end
|
120
120
|
|
121
|
-
end
|
121
|
+
end
|
@@ -16,6 +16,19 @@ module Adeia
|
|
16
16
|
has_many :permissions, class_name: "Adeia::Permission"
|
17
17
|
end
|
18
18
|
|
19
|
+
def add_to_group(name)
|
20
|
+
group = Group.find_by_name
|
21
|
+
Adeia::GroupUser.create(group: group, user: self)
|
22
|
+
end
|
23
|
+
|
24
|
+
def permissions
|
25
|
+
@permissions ||= Adeia::Permission.where(owner: groups << self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def groups
|
29
|
+
@groups ||= Adeia::Group.joins(:group_users).where(adeia_group_users: { user_id: self.id })
|
30
|
+
end
|
31
|
+
|
19
32
|
end
|
20
33
|
end
|
21
|
-
end
|
34
|
+
end
|
data/lib/adeia/version.rb
CHANGED
data/lib/tasks/init.rake
CHANGED
@@ -23,4 +23,12 @@ namespace :adeia do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
desc "Create groups"
|
27
|
+
task groups: :environment do
|
28
|
+
groups = ENV["groups"].split(",").map { |e| e.strip } if ENV["groups"].present?
|
29
|
+
if groups.present?
|
30
|
+
groups.each { |group| Adeia::Group.create!(name: group) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
26
34
|
end
|