curupira 0.1.0

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 (181) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +19 -0
  5. data/Gemfile +17 -0
  6. data/Gemfile.lock +202 -0
  7. data/README.md +72 -0
  8. data/Rakefile +31 -0
  9. data/app/controllers/curupira/authorized_controller.rb +9 -0
  10. data/app/controllers/curupira/groups_controller.rb +43 -0
  11. data/app/controllers/curupira/passwords_controller.rb +46 -0
  12. data/app/controllers/curupira/roles_controller.rb +43 -0
  13. data/app/controllers/curupira/sessions_controller.rb +30 -0
  14. data/app/controllers/curupira/users_controller.rb +47 -0
  15. data/app/helpers/curupira/authorize_helper.rb +21 -0
  16. data/app/helpers/curupira/relationship_select_options_helper.rb +17 -0
  17. data/app/mailers/curupira/reset_password_mailer.rb +13 -0
  18. data/app/views/curupira/groups/_form.html.erb +28 -0
  19. data/app/views/curupira/groups/_role_group_fields.html.erb +9 -0
  20. data/app/views/curupira/groups/edit.html.erb +3 -0
  21. data/app/views/curupira/groups/index.html.erb +24 -0
  22. data/app/views/curupira/groups/new.html.erb +3 -0
  23. data/app/views/curupira/groups/show.html.erb +32 -0
  24. data/app/views/curupira/passwords/edit.html.erb +14 -0
  25. data/app/views/curupira/passwords/new.html.erb +14 -0
  26. data/app/views/curupira/reset_password_mailer/instructions.html.erb +19 -0
  27. data/app/views/curupira/reset_password_mailer/reseted.html.erb +7 -0
  28. data/app/views/curupira/roles/_authorization_fields.html.erb +10 -0
  29. data/app/views/curupira/roles/_form.html.erb +23 -0
  30. data/app/views/curupira/roles/edit.html.erb +3 -0
  31. data/app/views/curupira/roles/index.html.erb +24 -0
  32. data/app/views/curupira/roles/new.html.erb +3 -0
  33. data/app/views/curupira/roles/show.html.erb +37 -0
  34. data/app/views/curupira/sessions/new.html.erb +17 -0
  35. data/app/views/curupira/shared/_model_links.html.erb +7 -0
  36. data/app/views/curupira/shared/_session_links.html.erb +7 -0
  37. data/app/views/curupira/users/_form.html.erb +43 -0
  38. data/app/views/curupira/users/_group_user_fields.html.erb +20 -0
  39. data/app/views/curupira/users/_role_group_user_fields.html.erb +10 -0
  40. data/app/views/curupira/users/edit.html.erb +3 -0
  41. data/app/views/curupira/users/index.html.erb +28 -0
  42. data/app/views/curupira/users/new.html.erb +3 -0
  43. data/app/views/curupira/users/show.html.erb +28 -0
  44. data/curupira.gemspec +28 -0
  45. data/lib/curupira.rb +16 -0
  46. data/lib/curupira/authorizer.rb +43 -0
  47. data/lib/curupira/rails.rb +30 -0
  48. data/lib/curupira/rails/routes.rb +15 -0
  49. data/lib/curupira/version.rb +3 -0
  50. data/lib/generators/curupira/controllers/controllers_generator.rb +27 -0
  51. data/lib/generators/curupira/install/install_generator.rb +80 -0
  52. data/lib/generators/curupira/install/model_generators_helper.rb +266 -0
  53. data/lib/generators/curupira/routes/routes_generator.rb +21 -0
  54. data/lib/generators/curupira/routes/templates/routes.rb +1 -0
  55. data/lib/generators/curupira/templates/db/migrate/add_curupira_to_users.rb +20 -0
  56. data/lib/generators/curupira/templates/db/migrate/create_action_labels.rb +12 -0
  57. data/lib/generators/curupira/templates/db/migrate/create_authorizations.rb +12 -0
  58. data/lib/generators/curupira/templates/db/migrate/create_features.rb +11 -0
  59. data/lib/generators/curupira/templates/db/migrate/create_group_users.rb +13 -0
  60. data/lib/generators/curupira/templates/db/migrate/create_groups.rb +10 -0
  61. data/lib/generators/curupira/templates/db/migrate/create_role_group_users.rb +12 -0
  62. data/lib/generators/curupira/templates/db/migrate/create_role_groups.rb +13 -0
  63. data/lib/generators/curupira/templates/db/migrate/create_roles.rb +8 -0
  64. data/lib/generators/curupira/templates/db/migrate/sorcery_core.rb +27 -0
  65. data/lib/generators/curupira/templates/models/action_label.rb +2 -0
  66. data/lib/generators/curupira/templates/models/authorization.rb +2 -0
  67. data/lib/generators/curupira/templates/models/feature.rb +2 -0
  68. data/lib/generators/curupira/templates/models/feature_service.rb +4 -0
  69. data/lib/generators/curupira/templates/models/group.rb +2 -0
  70. data/lib/generators/curupira/templates/models/group_user.rb +2 -0
  71. data/lib/generators/curupira/templates/models/role.rb +2 -0
  72. data/lib/generators/curupira/templates/models/role_group.rb +2 -0
  73. data/lib/generators/curupira/templates/models/role_group_user.rb +2 -0
  74. data/lib/generators/curupira/templates/models/service.rb +2 -0
  75. data/lib/generators/curupira/templates/models/user.rb +2 -0
  76. data/lib/generators/curupira/templates/sorcery.rb +462 -0
  77. data/lib/generators/curupira/views/views_generator.rb +27 -0
  78. data/lib/tasks/curupira_tasks.rake +4 -0
  79. data/spec/app_templates/app/models/action_label.rb +2 -0
  80. data/spec/app_templates/app/models/authorization.rb +2 -0
  81. data/spec/app_templates/app/models/feature.rb +2 -0
  82. data/spec/app_templates/app/models/feature_service.rb +2 -0
  83. data/spec/app_templates/app/models/group.rb +4 -0
  84. data/spec/app_templates/app/models/group_user.rb +2 -0
  85. data/spec/app_templates/app/models/role.rb +2 -0
  86. data/spec/app_templates/app/models/role_group.rb +2 -0
  87. data/spec/app_templates/app/models/role_group_user.rb +2 -0
  88. data/spec/app_templates/app/models/service.rb +2 -0
  89. data/spec/app_templates/app/models/user.rb +2 -0
  90. data/spec/app_templates/config/routes.rb +3 -0
  91. data/spec/controllers/controller_spec.rb +40 -0
  92. data/spec/controllers/groups_controller_spec.rb +162 -0
  93. data/spec/controllers/passwords_controller_spec.rb +171 -0
  94. data/spec/controllers/roles_controller_spec.rb +168 -0
  95. data/spec/controllers/sessions_controller_spec.rb +112 -0
  96. data/spec/controllers/users_controller_spec.rb +182 -0
  97. data/spec/curupira/authorization_spec.rb +67 -0
  98. data/spec/dummy/README.rdoc +28 -0
  99. data/spec/dummy/Rakefile +6 -0
  100. data/spec/dummy/app/assets/images/.keep +0 -0
  101. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  102. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  103. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  104. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  105. data/spec/dummy/app/controllers/home_controller.rb +4 -0
  106. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  107. data/spec/dummy/app/mailers/.keep +0 -0
  108. data/spec/dummy/app/models/.keep +0 -0
  109. data/spec/dummy/app/models/action_label.rb +3 -0
  110. data/spec/dummy/app/models/authorization.rb +4 -0
  111. data/spec/dummy/app/models/feature.rb +3 -0
  112. data/spec/dummy/app/models/group.rb +9 -0
  113. data/spec/dummy/app/models/group_user.rb +7 -0
  114. data/spec/dummy/app/models/role.rb +10 -0
  115. data/spec/dummy/app/models/role_group.rb +4 -0
  116. data/spec/dummy/app/models/role_group_user.rb +4 -0
  117. data/spec/dummy/app/models/user.rb +10 -0
  118. data/spec/dummy/app/views/home/index.html.erb +5 -0
  119. data/spec/dummy/app/views/home/test.html.erb +1 -0
  120. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  121. data/spec/dummy/bin/bundle +3 -0
  122. data/spec/dummy/bin/rails +4 -0
  123. data/spec/dummy/bin/rake +4 -0
  124. data/spec/dummy/bin/setup +29 -0
  125. data/spec/dummy/config.ru +4 -0
  126. data/spec/dummy/config/application.rb +25 -0
  127. data/spec/dummy/config/boot.rb +5 -0
  128. data/spec/dummy/config/database.yml +25 -0
  129. data/spec/dummy/config/environment.rb +5 -0
  130. data/spec/dummy/config/environments/development.rb +46 -0
  131. data/spec/dummy/config/environments/production.rb +79 -0
  132. data/spec/dummy/config/environments/test.rb +44 -0
  133. data/spec/dummy/config/initializers/assets.rb +11 -0
  134. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  135. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  136. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  137. data/spec/dummy/config/initializers/inflections.rb +16 -0
  138. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  139. data/spec/dummy/config/initializers/session_store.rb +3 -0
  140. data/spec/dummy/config/initializers/sorcery.rb +462 -0
  141. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  142. data/spec/dummy/config/locales/en.yml +23 -0
  143. data/spec/dummy/config/routes.rb +6 -0
  144. data/spec/dummy/config/secrets.yml +22 -0
  145. data/spec/dummy/db/migrate/20150305011941_create_role_group_users.rb +12 -0
  146. data/spec/dummy/db/migrate/20150305011942_create_authorizations.rb +12 -0
  147. data/spec/dummy/db/migrate/20150305011944_create_groups.rb +10 -0
  148. data/spec/dummy/db/migrate/20150305011945_create_roles.rb +8 -0
  149. data/spec/dummy/db/migrate/20150305011946_sorcery_core.rb +27 -0
  150. data/spec/dummy/db/migrate/20150305011947_create_group_users.rb +13 -0
  151. data/spec/dummy/db/migrate/20150305011948_create_role_groups.rb +13 -0
  152. data/spec/dummy/db/migrate/20150312181229_create_action_labels.rb +12 -0
  153. data/spec/dummy/db/migrate/20150312181747_create_features.rb +11 -0
  154. data/spec/dummy/db/schema.rb +112 -0
  155. data/spec/dummy/db/seeds.rb +137 -0
  156. data/spec/dummy/lib/assets/.keep +0 -0
  157. data/spec/dummy/log/.keep +0 -0
  158. data/spec/dummy/public/404.html +67 -0
  159. data/spec/dummy/public/422.html +67 -0
  160. data/spec/dummy/public/500.html +66 -0
  161. data/spec/dummy/public/favicon.ico +0 -0
  162. data/spec/features/link_authorize_spec.rb +25 -0
  163. data/spec/features/list_users_spec.rb +38 -0
  164. data/spec/features/log_in_spec.rb +15 -0
  165. data/spec/generators/curupira/install/action_label_spec.rb +53 -0
  166. data/spec/generators/curupira/install/authorization_generator_spec.rb +51 -0
  167. data/spec/generators/curupira/install/feature_generator_spec.rb +52 -0
  168. data/spec/generators/curupira/install/group_user_generator_spec.rb +51 -0
  169. data/spec/generators/curupira/install/install_generators_spec.rb +159 -0
  170. data/spec/generators/curupira/install/role_generator_spec.rb +38 -0
  171. data/spec/generators/curupira/install/role_group_generator_spec.rb +51 -0
  172. data/spec/generators/curupira/install/role_group_user_generator_spec.rb +52 -0
  173. data/spec/helpers/relationship_select_options_helper_spec.rb +18 -0
  174. data/spec/rails_helper.rb +55 -0
  175. data/spec/spec_helper.rb +87 -0
  176. data/spec/support/factories.rb +64 -0
  177. data/spec/support/generator_spec_helpers.rb +42 -0
  178. data/spec/support/helpers_spec.rb +23 -0
  179. data/spec/support/shared_examples/role_generator_shared_example_spec.rb +13 -0
  180. data/spec/support/sorcery.rb +4 -0
  181. metadata +539 -0
@@ -0,0 +1,43 @@
1
+ class Curupira::RolesController < Curupira::AuthorizedController
2
+ def index
3
+ @roles = Role.all
4
+ end
5
+
6
+ def show
7
+ @role = Role.find params[:id]
8
+ end
9
+
10
+ def new
11
+ @role = Role.new
12
+ end
13
+
14
+ def edit
15
+ @role = Role.find params[:id]
16
+ end
17
+
18
+ def create
19
+ @role = Role.new role_params
20
+
21
+ if @role.save
22
+ redirect_to @role, notice: "Perfil criado com sucesso"
23
+ else
24
+ render :new
25
+ end
26
+ end
27
+
28
+ def update
29
+ @role = Role.find params[:id]
30
+
31
+ if @role.update(role_params)
32
+ redirect_to @role, notice: "Perfil atualizado com sucesso"
33
+ else
34
+ render :edit
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def role_params
41
+ params.require(:role).permit(:name, :active, authorizations_attributes: [:id, :feature_id, :_destroy])
42
+ end
43
+ end
@@ -0,0 +1,30 @@
1
+ class Curupira::SessionsController < ApplicationController
2
+ before_filter :redirect_to_root_with_errors, if: :current_user, except: :destroy
3
+
4
+ def new
5
+ @user = User.new
6
+ end
7
+
8
+ def create
9
+ @user = login(params[:user][:username], params[:user][:password])
10
+
11
+ if @user
12
+ redirect_back_or_to(root_path, notice: 'Bem vindo!')
13
+ else
14
+ @user = User.new username: params[:user][:username]
15
+ flash[:alert] = "Login ou senha inválidos"
16
+ render :new
17
+ end
18
+ end
19
+
20
+ def destroy
21
+ logout
22
+ redirect_to new_session_path
23
+ end
24
+
25
+ private
26
+
27
+ def redirect_to_root_with_errors
28
+ redirect_to root_path, alert: "Você já está logado"
29
+ end
30
+ end
@@ -0,0 +1,47 @@
1
+ class Curupira::UsersController < Curupira::AuthorizedController
2
+ def index
3
+ if current_user.admin?
4
+ @users = User.all
5
+ else
6
+ @users = User.all_belonging_to(current_user)
7
+ end
8
+ end
9
+
10
+ def show
11
+ @user = User.find(params[:id])
12
+ end
13
+
14
+ def new
15
+ @user = User.new
16
+ end
17
+
18
+ def edit
19
+ @user = User.find(params[:id])
20
+ end
21
+
22
+ def create
23
+ @user = User.new(user_params)
24
+
25
+ if @user.save
26
+ redirect_to @user, notice: "Usuário criado com sucesso"
27
+ else
28
+ render :new
29
+ end
30
+ end
31
+
32
+ def update
33
+ @user = User.find(params[:id])
34
+
35
+ if @user.update user_params
36
+ redirect_to @user, notice: "Usuário atualizado com sucesso"
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def user_params
45
+ params.require(:user).permit(:email, :name, :username, :password, group_users_attributes: [:id, :group_id, :_destroy, role_group_users_attributes: [:id, :role_id]])
46
+ end
47
+ end
@@ -0,0 +1,21 @@
1
+ module Curupira::AuthorizeHelper
2
+ def link_to_authorize(name = nil, options = nil, html_options = nil, &block)
3
+ html_options, options, name = options, name, block if block_given?
4
+ options ||= {}
5
+
6
+ html_options = convert_options_to_data_attributes(options, html_options)
7
+
8
+ url = url_for(options)
9
+
10
+ request_data = Rails.application.routes.recognize_path(url)
11
+
12
+ if has_authorization_for(request_data)
13
+ html_options['href'] ||= url
14
+ else
15
+ html_options['style'] = "cursor: not-allowed;"
16
+ html_options['class'] = "not-allowed";
17
+ end
18
+
19
+ content_tag(:a, name || url, html_options, &block)
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module Curupira::RelationshipSelectOptionsHelper
2
+ def active_user_groups_select_options(user)
3
+ [["Selecione um grupo", nil]] + Group.joins(:users).where(users: { id: user }, active: true).map { |g| [g.name, g.id] }
4
+ end
5
+
6
+ def active_features_select_options
7
+ [["Selecione uma funcionalidade", nil]] + Feature.all.map { |f| [f.name, f.id] }
8
+ end
9
+
10
+ def active_roles_select_options
11
+ [["Selecione um perfil", nil]] + Role.all.map { |r| [r.name, r.id] }
12
+ end
13
+
14
+ def active_role_groups_select_options(group)
15
+ [["Selecione um perfil", nil]] + Role.joins(:groups).where(groups:{id:group}).map { |r| [r.name, r.id] }
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ class Curupira::ResetPasswordMailer < ActionMailer::Base
2
+ default from: 'notifications@example.com'
3
+
4
+ def instructions(user)
5
+ @user = user
6
+ mail(to: @user.email, subject: 'Recuperar senha')
7
+ end
8
+
9
+ def reseted(user)
10
+ @user = user
11
+ mail(to: @user.email, subject: 'Você criou uma nova senha')
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ <%= form_for @group do |f| %>
2
+ <div class="field">
3
+ <%= f.label :name, "Nome" %><br>
4
+ <%= f.text_field :name %>
5
+ </div>
6
+
7
+ <div class="field">
8
+ <%= f.label :active, "Ativo" %><br>
9
+ <%= f.check_box :active %>
10
+ </div>
11
+
12
+ <div class="roles">
13
+ <h3>Perfis</h3>
14
+
15
+ <%= f.fields_for :role_groups do |b| %>
16
+ <%= render 'role_group_fields', :f => b %>
17
+ <% end %>
18
+
19
+ <div class="links">
20
+ <%= link_to_add_association 'Adicionar perfil', f, :role_groups %>
21
+ </div>
22
+ </div>
23
+
24
+ <div class="actions">
25
+ <%= f.submit %><br>
26
+ or <%= link_to "Cancelar", groups_path %>
27
+ </div>
28
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <div class="nested-fields">
2
+ <% if f.object.role.blank? || f.object.role.active? %>
3
+ <%= f.select :role_id, active_roles_select_options %>
4
+ <% else %>
5
+ <%= f.object.role.name %>
6
+ <% end %>
7
+
8
+ <%= link_to_remove_association "Remover", f %>
9
+ </div>
@@ -0,0 +1,3 @@
1
+ <h1>Editar Grupo de Usuários</h1>
2
+
3
+ <%= render "form" %>
@@ -0,0 +1,24 @@
1
+ <h1>Grupo de Usuários</h1>
2
+
3
+ <div class="actions">
4
+ <%= link_to "Novo", new_group_path %>
5
+ </div>
6
+
7
+ <table>
8
+ <thead>
9
+ <tr>
10
+ <th>Nome</th>
11
+ <th>Ativo</th>
12
+ <th></th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% @groups.each do |group| %>
17
+ <tr>
18
+ <td><%= link_to group.name, group %></td>
19
+ <td><%= group.active %></td>
20
+ <td><%= link_to "Editar", edit_group_path(group) %></td>
21
+ </tr>
22
+ <% end %>
23
+ </tbody>
24
+ </table>
@@ -0,0 +1,3 @@
1
+ <h1>Novo Grupo de Usuários</h1>
2
+
3
+ <%= render "form" %>
@@ -0,0 +1,32 @@
1
+ <h1>Grupo de Usuário</h1>
2
+
3
+ <div class="actions">
4
+ <%= link_to "Editar", edit_group_path(@group) %>
5
+ </div>
6
+
7
+ <ul>
8
+ <li>Nome: <%= @group.name %></li>
9
+ <li>Ativo: <%= @group.active %></li>
10
+ </ul>
11
+
12
+ <div id="role_groups">
13
+ <h3>Perfis</h3>
14
+
15
+ <ul>
16
+ <% @group.role_groups.each do |g| %>
17
+ <li><%= g.role.name %></li>
18
+ <% end %>
19
+ </ul>
20
+ </div>
21
+
22
+ <div id="group_users">
23
+ <h3>Usuários vinculados</h3>
24
+
25
+ <ul>
26
+ <% @group.group_users.each do |g| %>
27
+ <li><%= link_to g.user.name, g.user %></li>
28
+ <% end %>
29
+ </ul>
30
+ </div>
31
+
32
+ <%= link_to "Voltar", groups_path %>
@@ -0,0 +1,14 @@
1
+ <h1>Reiniciar senha</h1>
2
+
3
+ <%= form_for @user, url: password_path(id: @user.reset_password_token) do |f| %>
4
+ <div class="field">
5
+ <%= f.label :password, "Nova senha" %>
6
+ <%= f.password_field :password %>
7
+ </div>
8
+
9
+ <div class="actions">
10
+ <%= f.submit "Criar nova senha" %>
11
+ </div>
12
+ <% end %>
13
+
14
+ <%= link_to "Cancelar", new_session_path%>
@@ -0,0 +1,14 @@
1
+ <h1>Esqueci minha senha</h1>
2
+
3
+ <%= form_for @user, url: passwords_path do |f| %>
4
+ <div class="field">
5
+ <%= f.label :email, "Email" %>
6
+ <%= f.text_field :email %>
7
+ </div>
8
+
9
+ <div class="actions">
10
+ <%= f.submit "Me envie instruções por email" %>
11
+ </div>
12
+ <% end %>
13
+
14
+ <%= link_to "Cancelar", new_session_path%>
@@ -0,0 +1,19 @@
1
+ <p>
2
+ Olá <%= @user.name %>,
3
+ </p>
4
+
5
+ <p>
6
+ Este é um email automático.
7
+ </p>
8
+
9
+ <p>
10
+ Você solicitou instruções para recuperar sua senha.
11
+ </p>
12
+
13
+ <p>
14
+ <%= link_to "Clique aqui para crirar uma nova senha", edit_password_url(id: @user.reset_password_token) %>
15
+ </p>
16
+
17
+ <p>
18
+ Caso você não tenha feito esta solicitação, por favor, desconsidere este email.
19
+ </p>
@@ -0,0 +1,7 @@
1
+ <p>
2
+ Olá <%= @user.name %>,
3
+ </p>
4
+
5
+ <p>
6
+ Este é um email automático de segurança para confirmar que você criou uma nova senha.<br>
7
+ </p>
@@ -0,0 +1,10 @@
1
+ <div class="nested-fields">
2
+ <% if f.object.feature.blank? ||
3
+ f.object.feature.active? %>
4
+ <%= f.select :feature_id, active_features_select_options %>
5
+ <% else %>
6
+ <%= f.object.feature.name %>
7
+ <% end %>
8
+
9
+ <%= link_to_remove_association "Remover", f %>
10
+ </div>
@@ -0,0 +1,23 @@
1
+ <%= form_for @role do |f| %>
2
+ <div class="field">
3
+ <%= f.label :name, "Nome" %><br>
4
+ <%= f.text_field :name %>
5
+ </div>
6
+
7
+ <div class="features">
8
+ <h3>Funcionalidades</h3>
9
+
10
+ <%= f.fields_for :authorizations do |b| %>
11
+ <%= render 'authorization_fields', :f => b %>
12
+ <% end %>
13
+
14
+ <div class="links">
15
+ <%= link_to_add_association 'Adicionar funcionalidade', f, :authorizations %>
16
+ </div>
17
+ </div>
18
+
19
+ <div class="actions">
20
+ <%= f.submit %><br>
21
+ or <%= link_to :cancel, roles_path %>
22
+ </div>
23
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <h1>Editar Perfil</h1>
2
+
3
+ <%= render "form" %>
@@ -0,0 +1,24 @@
1
+ <h1>Perfis</h1>
2
+
3
+ <div class="actions">
4
+ <%= link_to "Novo Perfil", new_role_path %>
5
+ </div>
6
+
7
+ <table>
8
+ <thead>
9
+ <tr>
10
+ <th>Nome</th>
11
+ <th>Ativo</th>
12
+ <th></th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% @roles.each do |role| %>
17
+ <tr>
18
+ <td><%= link_to role.name, role %></td>
19
+ <td><%= role.active %></td>
20
+ <td><%= link_to "Editar", edit_role_path(role) %></td>
21
+ </tr>
22
+ <% end %>
23
+ </tbody>
24
+ </table>
@@ -0,0 +1,3 @@
1
+ <h2>Novo Perfil</h2>
2
+
3
+ <%= render "form" %>
@@ -0,0 +1,37 @@
1
+ <h1>Perfil</h1>
2
+
3
+ <div class="actions">
4
+ <%= link_to "Editar", edit_role_path(@role) %>
5
+ </div>
6
+
7
+ <ul>
8
+ <li>Name: <%= @role.name %></li>
9
+ <li>Active: <%= @role.active %></li>
10
+ </ul>
11
+
12
+ <div id="features">
13
+ <h3>Funcionalidades</h3>
14
+
15
+ <ul>
16
+ <% @role.features.each do |feature| %>
17
+ <li><%= link_to feature.name, feature %></li>
18
+ <% end %>
19
+ </ul>
20
+ </div>
21
+
22
+ <div id="user_groups">
23
+ <h3>Usuários vinculados</h3>
24
+
25
+ <ul>
26
+ <% @role.group_users.group(:group_id).each do |gu| %>
27
+ <h4>Grupo <%= link_to gu.group.name, gu.group %></h4>
28
+ <% @role.group_users.where(group_id:gu.group_id).each do |group_user|%>
29
+ <ul>
30
+ <li><%= link_to group_user.user.name, group_user.user %></li>
31
+ </ul>
32
+ <% end %>
33
+ <% end %>
34
+ </ul>
35
+ </div>
36
+
37
+ <%= link_to "Voltar", roles_path %>