curupira 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of curupira might be problematic. Click here for more details.

Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/controllers/curupira/users_controller.rb +6 -0
  4. data/app/views/curupira/users/_group_user_fields.html.erb +1 -10
  5. data/app/views/curupira/users/_role_group_user_fields.html.erb +1 -1
  6. data/app/views/curupira/users/permission.html.erb +20 -0
  7. data/app/views/curupira/users/show.html.erb +1 -1
  8. data/lib/curupira/rails/routes.rb +4 -1
  9. data/lib/curupira/version.rb +1 -1
  10. data/lib/generators/curupira/install/model_generators_helper.rb +1 -0
  11. data/spec/dummy/app/models/user.rb +1 -0
  12. data/spec/dummy/log/test.log +25971 -0
  13. data/spec/generators/curupira/install/install_generators_spec.rb +2 -0
  14. data/spec/tmp/app/models/user.rb +1 -0
  15. data/spec/tmp/db/migrate/{20150320032239_create_role_group_users.rb → 20150323194119_create_role_group_users.rb} +0 -0
  16. data/spec/tmp/db/migrate/{20150320032240_create_authorizations.rb → 20150323194120_create_authorizations.rb} +0 -0
  17. data/spec/tmp/db/migrate/{20150320032241_create_features.rb → 20150323194121_create_features.rb} +0 -0
  18. data/spec/tmp/db/migrate/{20150320032242_create_groups.rb → 20150323194122_create_groups.rb} +0 -0
  19. data/spec/tmp/db/migrate/{20150320032243_create_roles.rb → 20150323194123_create_roles.rb} +0 -0
  20. data/spec/tmp/db/migrate/{20150320032244_sorcery_core.rb → 20150323194124_sorcery_core.rb} +0 -0
  21. data/spec/tmp/db/migrate/{20150320032245_create_group_users.rb → 20150323194125_create_group_users.rb} +0 -0
  22. data/spec/tmp/db/migrate/{20150320032246_create_role_groups.rb → 20150323194126_create_role_groups.rb} +0 -0
  23. data/spec/tmp/db/migrate/{20150320032247_create_action_labels.rb → 20150323194127_create_action_labels.rb} +0 -0
  24. metadata +21 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f14fa682e08b79b040066b77987f1e349d6f7fc
4
- data.tar.gz: 1e079aeade659aa49a9a845685bb729ab32fd547
3
+ metadata.gz: 8ca4be82e390515697d16daa359b5a036d5d7189
4
+ data.tar.gz: 49744e964b4f0572f47371659ae0cba69b503237
5
5
  SHA512:
6
- metadata.gz: 4d0748f95cd07df56e5c71e7010a6d5c8c0fc3ee87431916e7892ef623b7d2acc49e06871044ab302739a5bdebd86c51eb1131ac4b9bc875be19cc87f1b29b31
7
- data.tar.gz: d22e13945075d7f2e9cd8c5725140c6f2884e57bc4134bd5c0bd654dbf5506770c68c8cb737a6d2735438ee565f7cdc8c49350684b39a72cbe71612739497597
6
+ metadata.gz: 21fc605d450e4b1ec20d09e7014c29a7516b328efb814f442a187db99c0aaa1bff6b341cb14bcd8750351c8939c598d820adb93767008b27b26cecf25ccaf8e1
7
+ data.tar.gz: a8416b6983a96add5385eb7cb806442ad6d5878e1f5e7cff48260c9abec3ab94db3cbe2d90d976b87444d5336a9e298156358424302442edd26a9aaf234c8ba5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- curupira (0.1.2)
4
+ curupira (0.1.3)
5
5
  cocoon
6
6
  jquery-rails
7
7
  rails (~> 4.2.0)
@@ -39,6 +39,12 @@ class Curupira::UsersController < Curupira::AuthorizedController
39
39
  end
40
40
  end
41
41
 
42
+ def permission
43
+ @user = User.find(params[:user_id])
44
+ @group_user = @user.group_users.find_by(group_id: params[:group_id])
45
+ @group = @group_user.group
46
+ end
47
+
42
48
  private
43
49
 
44
50
  def user_params
@@ -4,17 +4,8 @@
4
4
  <% else %>
5
5
  <%= f.object.user_group.name %>
6
6
  <% end %>
7
-
8
- <div style="margin: 50px">
9
- <h4>Perfis</h4>
10
- <%= f.fields_for :role_group_users do |role_group_user| %>
11
- <%= render "role_group_user_fields", f: role_group_user %>
12
- <% end %>
13
7
 
14
- <div class="links">
15
- <%= link_to_add_association 'Adicionar Permissão', f, :role_group_users %>
16
- </div>
17
-
8
+ <div class="links">
18
9
  <%= link_to_remove_association "Remover", f %>
19
10
  </div>
20
11
  </div>
@@ -1,7 +1,7 @@
1
1
  <div class="nested-fields">
2
2
  <% if f.object.role.blank? || f.object.role.active? %>
3
3
 
4
- <%= f.select :role_id, active_roles_select_options %>
4
+ <%= f.select :role_id, active_role_groups_select_options(@group) %>
5
5
  <% else %>
6
6
  <%= f.object.role.name %>
7
7
  <% end %>
@@ -0,0 +1,20 @@
1
+ <h2> Adicionar perfis ao Usuário </h2>
2
+
3
+ Usuário <%= @user.name %>
4
+
5
+ Grupo <%= @group.name %>
6
+
7
+ <%= form_for @user do |f| %>
8
+ <div class="group_users">
9
+ <h3>Perfil</h3>
10
+
11
+ <%= f.fields_for :role_group_users do |b| %>
12
+ <%= render "role_group_user_fields", f: b %>
13
+ <% end %>
14
+
15
+ <div class="links">
16
+ <%= link_to_add_association 'Adicionar perfil', f, :role_group_users %>
17
+ </div>
18
+ </div>
19
+ <% end %>
20
+
@@ -16,7 +16,7 @@
16
16
 
17
17
  <ul>
18
18
  <% @user.group_users.each do |group_user| %>
19
- <li><%= group_user.group.name %> <%= link_to "Editar grupo", edit_user_path(@user) %>
19
+ <li><%= group_user.group.name %> <%= link_to "Vincular perfis do grupo", user_permission_path(@user,group_user.group) %>
20
20
  <% group_user.role_group_users.each do |role_group_user|%>
21
21
  <p><%= role_group_user.role.name %></p>
22
22
  <% end %>
@@ -2,7 +2,10 @@ module ActionDispatch::Routing
2
2
  class Mapper
3
3
  def curupira_routes
4
4
  scope module: 'curupira' do
5
- resources :users, except: :destroy
5
+ resources :users, except: :destroy do
6
+ get 'groups/:group_id/roles', to: 'users#permission',as: 'permission', action: :permission, controller: :users
7
+ end
8
+
6
9
  resources :groups, except: :destroy
7
10
  resources :roles, except: :destroy
8
11
  resource :session, only: [:new, :create] do
@@ -1,3 +1,3 @@
1
1
  module Curupira
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -174,6 +174,7 @@ module Curupira
174
174
  has_many :groups, through: :group_users
175
175
  has_many :role_group_users, through: :group_users
176
176
  accepts_nested_attributes_for :group_users, reject_if: :all_blank, allow_destroy: :true
177
+ accepts_nested_attributes_for :role_group_users, reject_if: :all_blank, allow_destroy: :true
177
178
 
178
179
  scope :all_belonging_to, -> (user) { includes(group_users: :group).where(groups: { id: user.groups }) }
179
180
  CONTENT
@@ -5,6 +5,7 @@ class User < ActiveRecord::Base
5
5
  has_many :groups, through: :group_users
6
6
  has_many :role_group_users, through: :group_users
7
7
  accepts_nested_attributes_for :group_users, reject_if: :all_blank, allow_destroy: :true
8
+ accepts_nested_attributes_for :role_group_users, reject_if: :all_blank, allow_destroy: :true
8
9
 
9
10
  scope :all_belonging_to, -> (user) { includes(group_users: :group).where(groups: { id: user.groups }) }
10
11
  end