lato_core 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -12
  3. data/app/controllers/lato_core/api/v1/api_controller.rb +2 -3
  4. data/app/controllers/lato_core/application_controller.rb +1 -1
  5. data/app/controllers/lato_core/back/authentication_controller.rb +12 -11
  6. data/app/controllers/lato_core/back/back_controller.rb +13 -19
  7. data/app/controllers/lato_core/back/superusers_controller.rb +123 -148
  8. data/app/mailers/lato_core/application_mailer.rb +3 -4
  9. data/app/mailers/lato_core/superusers_mailer.rb +5 -7
  10. data/app/models/lato_core/superuser.rb +27 -19
  11. data/app/views/lato_core/back/authentication/login.html.erb +12 -9
  12. data/app/views/lato_core/back/authentication/password_edit.html.erb +9 -14
  13. data/app/views/lato_core/back/authentication/password_forget.html.erb +26 -27
  14. data/app/views/lato_core/back/back/home.html.erb +5 -5
  15. data/app/views/lato_core/back/superusers/edit.html.erb +12 -3
  16. data/app/views/lato_core/back/superusers/index.html.erb +23 -13
  17. data/app/views/lato_core/back/superusers/new.html.erb +12 -3
  18. data/app/views/lato_core/back/superusers/shared/_form.html.erb +3 -6
  19. data/config/config.yml +1 -1
  20. data/config/example.yml +3 -3
  21. data/config/initializers/init.rb +4 -5
  22. data/{test/dummy/log/test.log → config/initializers/lists.rb} +0 -0
  23. data/config/initializers/ram.rb +1 -37
  24. data/config/routes.rb +4 -5
  25. data/lib/lato_core.rb +2 -6
  26. data/lib/lato_core/engine.rb +6 -6
  27. data/lib/lato_core/interface.rb +12 -15
  28. data/lib/lato_core/interface/authentication.rb +19 -27
  29. data/lib/lato_core/interface/cache.rb +17 -23
  30. data/lib/lato_core/interface/communication.rb +68 -85
  31. data/lib/lato_core/interface/languages.rb +38 -47
  32. data/lib/lato_core/interface/navigation.rb +79 -93
  33. data/lib/lato_core/interface/session.rb +47 -61
  34. data/lib/lato_core/interface/superusers.rb +113 -122
  35. data/lib/tasks/lato_core_tasks.rake +2 -5
  36. metadata +4 -99
  37. data/test/controllers/lato_core/api/v1/api_controller_test.rb +0 -9
  38. data/test/controllers/lato_core/application_controller_test.rb +0 -9
  39. data/test/controllers/lato_core/back/authentication_controller_test.rb +0 -13
  40. data/test/controllers/lato_core/back/back_controller_test.rb +0 -9
  41. data/test/controllers/lato_core/back/session_controller_test.rb +0 -13
  42. data/test/controllers/lato_core/back/superusers_controller_test.rb +0 -13
  43. data/test/dummy/README.rdoc +0 -28
  44. data/test/dummy/Rakefile +0 -6
  45. data/test/dummy/app/assets/javascripts/application.js +0 -13
  46. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  47. data/test/dummy/app/controllers/application_controller.rb +0 -5
  48. data/test/dummy/app/helpers/application_helper.rb +0 -2
  49. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  50. data/test/dummy/bin/bundle +0 -3
  51. data/test/dummy/bin/rails +0 -4
  52. data/test/dummy/bin/rake +0 -4
  53. data/test/dummy/bin/setup +0 -29
  54. data/test/dummy/config.ru +0 -4
  55. data/test/dummy/config/application.rb +0 -25
  56. data/test/dummy/config/boot.rb +0 -5
  57. data/test/dummy/config/database.yml +0 -25
  58. data/test/dummy/config/environment.rb +0 -5
  59. data/test/dummy/config/environments/development.rb +0 -41
  60. data/test/dummy/config/environments/production.rb +0 -79
  61. data/test/dummy/config/environments/test.rb +0 -42
  62. data/test/dummy/config/initializers/assets.rb +0 -11
  63. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  64. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  65. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  66. data/test/dummy/config/initializers/inflections.rb +0 -16
  67. data/test/dummy/config/initializers/mime_types.rb +0 -4
  68. data/test/dummy/config/initializers/session_store.rb +0 -3
  69. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  70. data/test/dummy/config/locales/en.yml +0 -23
  71. data/test/dummy/config/routes.rb +0 -4
  72. data/test/dummy/config/secrets.yml +0 -22
  73. data/test/dummy/public/404.html +0 -67
  74. data/test/dummy/public/422.html +0 -67
  75. data/test/dummy/public/500.html +0 -66
  76. data/test/dummy/public/favicon.ico +0 -0
  77. data/test/fixtures/lato_core/superusers.yml +0 -11
  78. data/test/integration/navigation_test.rb +0 -8
  79. data/test/lato_core_test.rb +0 -7
  80. data/test/mailers/lato_core/lato_core_mailer_test.rb +0 -9
  81. data/test/mailers/previews/lato_core/lato_core_mailer_preview.rb +0 -6
  82. data/test/models/lato_core/superuser_test.rb +0 -9
  83. data/test/test_helper.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 158239153f779624bfaec9eebb2d116a69f333c8
4
- data.tar.gz: 95cf916a9e1969e24d972cb675faf1038cf794fc
3
+ metadata.gz: 9d4f8962583791bb07d2c7cf84bbdb2b4bdd8748
4
+ data.tar.gz: 4f3797dabf9b2cc4c116da0a15aa068d0a2fd10e
5
5
  SHA512:
6
- metadata.gz: d1f9654bdcf4e919765e01d1a4c40c5159877ec63233218886bea828f51a99d1ee9b7b31bb774edf388b1c37d2374b6baea2441041eca3c5404ba97a0342bd4d
7
- data.tar.gz: e0fe4cbfdd5795b42077a0b355d7fc2780611d3303d19ab0fcfb2a2cbc9e9c532d2e04b0144adbe7815597695f989cd5b599284881e966c32fabfcdaa3b022ed
6
+ metadata.gz: 4404c8c4c8a215f6998a62e0ca797ea0576b07cc639241ba3831b29ddacf16388990670eeb482353750c06760677c61a5e52667bceda0187614434fb21e3926e
7
+ data.tar.gz: b8baa9eb218ed86f43755091beeef61d970ccbd9a920fbb090d84b260eebb179bfe4302330e36cb87ac81bbc63a1d0dbc24004cbc76c97ace3d2760877cb5b0f
data/Rakefile CHANGED
@@ -4,17 +4,6 @@ rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
6
 
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'doc'
11
- rdoc.title = 'LatoCore'
12
- rdoc.rdoc_files.include('README.md')
13
- rdoc.rdoc_files.include('lib/lato_core.rb')
14
- rdoc.rdoc_files.include('lib/lato_core/**/*.rb')
15
- rdoc.rdoc_files.include('app/models/**/*.rb')
16
- end
17
-
18
7
  APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
19
8
  load 'rails/tasks/engine.rake'
20
9
 
@@ -22,7 +11,6 @@ load 'rails/tasks/engine.rake'
22
11
  load 'rails/tasks/statistics.rake'
23
12
 
24
13
 
25
-
26
14
  Bundler::GemHelper.install_tasks
27
15
 
28
16
  require 'rake/testtask'
@@ -1,9 +1,8 @@
1
1
  module LatoCore
2
2
  module Api::V1
3
-
4
- # Classe che gestisce le API del modulo
3
+ # This class is the main class for lato_core API.
5
4
  class ApiController < ApplicationController
6
- end
7
5
 
6
+ end
8
7
  end
9
8
  end
@@ -1,5 +1,5 @@
1
1
  module LatoCore
2
- # Classe base dei controller del modulo
2
+ # This class is the main controller class of lato_core.
3
3
  class ApplicationController < ActionController::Base
4
4
 
5
5
  end
@@ -1,18 +1,17 @@
1
1
  module LatoCore
2
2
  module Back
3
- # Controller che gestisce il login e il logout degli utenti
3
+ # This class is used for authentication actions.
4
4
  class AuthenticationController < Back::BackController
5
5
 
6
- # Disattivo il controllo dell'autenticazione utente
6
+ # not use login check for actions on this controller.
7
7
  skip_before_action :core_controlUser, except: [:exec_logout]
8
8
 
9
- # Richiama la view della pagina di login
9
+ # This function render login view if user is not logged.
10
10
  def login
11
11
  redirect_to lato_core.root_path if core_controlSession
12
12
  end
13
13
 
14
- # Esegue il login e, se l'utente e' autenticato lo rimanda
15
- # alla homepage del backoffice
14
+ # This function exec the login for user using username and password.
16
15
  def exec_login
17
16
  if core_createSession(params[:username], params[:password])
18
17
  redirect_to lato_core.root_path
@@ -22,20 +21,21 @@ module LatoCore
22
21
  end
23
22
  end
24
23
 
25
- # Esegue il logout e rimanda alla pagina di login del backoffice
24
+ # This function exec the logout for user and redirect it to login page.
26
25
  def exec_logout
27
26
  core_destroySession
28
27
  redirect_to lato_core.login_path
29
28
  end
30
29
 
31
- # Richiama la view per la richiesta di una nuova password nel caso di
32
- # password dimenticata
30
+ # This function render the password forget view if user active this
31
+ # action on config file.
33
32
  def password_forget
34
33
  redirect_to lato_core.root_path unless core_getRecoveryPasswordPermission
35
34
  redirect_to lato_core.root_path if core_controlSession
36
35
  end
37
36
 
38
- # Esegue il necessario per il recupero password e invia l'email al richiedente
37
+ # This function exec the recover password action and send the email to
38
+ # user for new password.
39
39
  def password_recover
40
40
  redirect_to lato_core.root_path unless core_getRecoveryPasswordPermission
41
41
  if user = LatoCore::Superuser.find_by(email: params[:email].downcase)
@@ -54,7 +54,8 @@ module LatoCore
54
54
  redirect_to lato_core.login_path
55
55
  end
56
56
 
57
- # Richiama la view con il form per l'inserimento di una nuova password
57
+ # This function render the edit view for user who ask to recover
58
+ # its password (and check if it can do this action).
58
59
  def password_edit
59
60
  redirect_to lato_core.root_path unless core_getRecoveryPasswordPermission
60
61
  redirect_to lato_core.root_path if core_controlSession
@@ -91,7 +92,7 @@ module LatoCore
91
92
  @user.update_attribute(:session_code, new_code)
92
93
  end
93
94
 
94
- # Aggiorna la password dell'utente che ha richiesto il recupero password
95
+ # This function ecec the password update after the recovery request.
95
96
  def password_update
96
97
  redirect_to lato_core.root_path unless core_getRecoveryPasswordPermission
97
98
  user = LatoCore::Superuser.find(params[:id])
@@ -1,27 +1,21 @@
1
- # Includo l'interfaccia di lato_core
2
- include LatoCore::Interface
3
- # Includo l'interfaccia di lato_view
4
- include LatoView::Interface
5
-
6
1
  module LatoCore
7
- module Back
8
- # Classe che gestisce il pannello di backoffice del modulo
9
- class BackController < ApplicationController
2
+ # This class is the main class for the lato backend panel.
3
+ class Back::BackController < ApplicationController
10
4
 
11
- # Imposto layout di base dal lato_view
12
- layout 'lato_layout'
5
+ # set default lato_view layout
6
+ layout 'lato_layout'
13
7
 
14
- # Attivo il controllo delle credenziali
15
- before_action :core_controlUser
8
+ # set check login control for every actions.
9
+ before_action :core_controlUser
16
10
 
17
- # Richiama la view della home del pannello di backoffice
18
- def home
19
- # rimando ad una pagina custom se è stato impostato da file di configurazione
20
- if login_root = core_getApplicationLoginRoot and login_root
21
- redirect_to login_root
22
- end
11
+ # This function render the default home view for lato after login or
12
+ # redirect to custom url if config file set one.
13
+ def home
14
+ # rimando ad una pagina custom se è stato impostato da file di
15
+ # configurazione
16
+ if login_root = core_getApplicationLoginRoot and login_root
17
+ redirect_to login_root
23
18
  end
24
-
25
19
  end
26
20
 
27
21
  end
@@ -1,171 +1,146 @@
1
1
  module LatoCore
2
- module Back
3
- # Controller che gestisce il CRUD degli utenti amministratori
4
- class SuperusersController < Back::BackController
2
+ class Back::SuperusersController < Back::BackController
3
+
4
+ # before actions
5
+ before_action do
6
+ # set menu voice active
7
+ view_setCurrentVoice('core_superusers')
8
+ # check minimum permission value to 6
9
+ redirect_to lato_core.root_path unless core_controlPermission(6)
10
+ end
5
11
 
6
- # Imposto la voce di menu da attivare
7
- before_action :set_unique_name
8
- # Controllo permessi utente
9
- before_action :control_permission
12
+ def new
13
+ @superuser = LatoCore::Superuser.new
14
+ end
10
15
 
11
- # Richiama la view di creazione di un nuovo utente con permessi di
12
- # accesso al pannello di backoffice
13
- def new
14
- @superuser = LatoCore::Superuser.new
16
+ def create
17
+ superuser = LatoCore::Superuser.new(superuser_params)
18
+ # controllo che l'utente creato non abbia permessi superiori dell'utente
19
+ # creatore
20
+ if superuser.permission > core_getCurrentUser.permission
21
+ flash[:warning] = CORE_LANG['superusers']['permission_create']
22
+ redirect_to lato_core.superusers_path and return false
23
+ end
24
+ # controllo che la creazione dell'utente non abbia avuto errori
25
+ unless superuser.save
26
+ flash[:danger] = CORE_LANG['superusers']['failed_create']
27
+ redirect_to lato_core.superusers_path and return false
15
28
  end
16
29
 
17
- # Crea un nuovo utente con permessi di accesso al pannello di backoffice
18
- # e rimanda alla pagina di visualizzazione del profilo utente appena
19
- # creato
20
- def create
21
- superuser = LatoCore::Superuser.new(superuser_params)
22
- # controllo che l'utente creato non abbia permessi superiori dell'utente
23
- # creatore
24
- if superuser.permission > core_getCurrentUser.permission
25
- flash[:warning] = CORE_LANG['superusers']['permission_create']
26
- redirect_to lato_core.superusers_path and return false
27
- end
28
- # controllo che la creazione dell'utente non abbia avuto errori
29
- unless superuser.save
30
- flash[:danger] = CORE_LANG['superusers']['failed_create']
31
- redirect_to lato_core.superusers_path and return false
32
- end
30
+ flash[:success] = CORE_LANG['superusers']['success_create']
31
+ redirect_to lato_core.superuser_path(superuser)
32
+ end
33
33
 
34
- flash[:success] = CORE_LANG['superusers']['success_create']
35
- redirect_to lato_core.superuser_path(superuser)
34
+ def edit
35
+ @superuser = LatoCore::Superuser.find(params[:id])
36
+ # controllo che l'utente da modificare esista
37
+ unless @superuser
38
+ flash[:warning] = CORE_LANG['superusers']['not_found']
39
+ redirect_to lato_core.superusers_path and return false
36
40
  end
37
-
38
- # Richiama la view di modifica dell'utente con id uguale a quello ricevuto
39
- # come parametro
40
- def edit
41
- @superuser = LatoCore::Superuser.find(params[:id])
42
- # controllo che l'utente da modificare esista
43
- unless @superuser
44
- flash[:warning] = CORE_LANG['superusers']['not_found']
45
- redirect_to lato_core.superusers_path and return false
46
- end
47
- # controllo che l'utente da modificare non abbia permessi uguali o
48
- # maggiori dell'utente modificatore
49
- if @superuser.permission >= core_getCurrentUser.permission &&
50
- @superuser.permission != core_getCurrentUser.permission
51
- flash[:warning] = CORE_LANG['superusers']['permission_update']
52
- redirect_to lato_core.superusers_path and return false
53
- end
41
+ # controllo che l'utente da modificare non abbia permessi uguali o
42
+ # maggiori dell'utente modificatore
43
+ if @superuser.permission >= core_getCurrentUser.permission &&
44
+ @superuser.permission != core_getCurrentUser.permission
45
+ flash[:warning] = CORE_LANG['superusers']['permission_update']
46
+ redirect_to lato_core.superusers_path and return false
54
47
  end
48
+ end
55
49
 
56
- # Aggiorna l'utente con i dati ricevuti come parametro
57
- def update
58
- superuser = LatoCore::Superuser.find(params[:id])
59
- # controllo che l'utente da modificare esista
60
- unless superuser
61
- flash[:warning] = CORE_LANG['superusers']['not_found']
62
- redirect_to lato_core.superusers_path and return false
63
- end
64
- # controllo che l'utente da modificare non abbia permessi uguali o
65
- # maggiori dell'utente modificatore
66
- if superuser.permission >= core_getCurrentUser.permission &&
67
- superuser != core_getCurrentUser
68
- flash[:warning] = CORE_LANG['superusers']['permission_update']
69
- redirect_to lato_core.superusers_path and return false
70
- end
71
- # controllo che l'utente non si stia auto aumentando i permessi
72
- if superuser.id === core_getCurrentUser.id &&
73
- superuser.permission < params[:superuser][:permission].to_i
74
- flash[:warning] = CORE_LANG['superusers']['level_update']
75
- redirect_to lato_core.superusers_path and return false
76
- end
77
- # faccio in modo che l'aggiornamento avvenga senza problemi anche se
78
- # la password non e' stata inserita
79
- if params[:superuser][:password].blank? &&
80
- params[:superuser][:password_confirmation].blank?
81
- params[:superuser].delete(:password)
82
- params[:superuser].delete(:password_confirmation)
83
- end
84
- # controllo che non ci siano stati errori di aggiornamento
85
- unless superuser.update(superuser_params)
86
- flash[:danger] = CORE_LANG['superusers']['failed_update']
87
- redirect_to lato_core.superuser_path(superuser) and return false
88
- end
89
-
90
- flash[:success] = CORE_LANG['superusers']['success_update']
91
- redirect_to lato_core.superuser_path(superuser)
50
+ def update
51
+ superuser = LatoCore::Superuser.find(params[:id])
52
+ # controllo che l'utente da modificare esista
53
+ unless superuser
54
+ flash[:warning] = CORE_LANG['superusers']['not_found']
55
+ redirect_to lato_core.superusers_path and return false
56
+ end
57
+ # controllo che l'utente da modificare non abbia permessi uguali o
58
+ # maggiori dell'utente modificatore
59
+ if superuser.permission >= core_getCurrentUser.permission &&
60
+ superuser != core_getCurrentUser
61
+ flash[:warning] = CORE_LANG['superusers']['permission_update']
62
+ redirect_to lato_core.superusers_path and return false
63
+ end
64
+ # controllo che l'utente non si stia auto aumentando i permessi
65
+ if superuser.id === core_getCurrentUser.id &&
66
+ superuser.permission < params[:superuser][:permission].to_i
67
+ flash[:warning] = CORE_LANG['superusers']['level_update']
68
+ redirect_to lato_core.superusers_path and return false
69
+ end
70
+ # faccio in modo che l'aggiornamento avvenga senza problemi anche se
71
+ # la password non e' stata inserita
72
+ if params[:superuser][:password].blank? &&
73
+ params[:superuser][:password_confirmation].blank?
74
+ params[:superuser].delete(:password)
75
+ params[:superuser].delete(:password_confirmation)
76
+ end
77
+ # controllo che non ci siano stati errori di aggiornamento
78
+ unless superuser.update(superuser_params)
79
+ flash[:danger] = CORE_LANG['superusers']['failed_update']
80
+ redirect_to lato_core.superuser_path(superuser) and return false
92
81
  end
93
82
 
94
- # Elimina l'utente con id ricevuto come parametro
95
- def destroy
96
- superuser = LatoCore::Superuser.find(params[:id])
97
- # controllo che l'utente da eliminare esista
98
- unless superuser
99
- flash[:warning] = CORE_LANG['superusers']['not_found']
100
- redirect_to lato_core.superusers_path and return false
101
- end
102
- # controllo che l'utente non stia provando a eliminare se stesso
103
- if superuser === core_getCurrentUser
104
- flash[:warning] = CORE_LANG['superusers']['itself_destroy']
105
- redirect_to lato_core.superusers_path and return false
106
- end
107
- # controllo che l'utente da eliminare non abbia permessi maggiori o
108
- # uguali all'utente eliminatore
109
- if superuser.permission >= core_getCurrentUser.permission
110
- flash[:warning] = CORE_LANG['superusers']['permission_destroy']
111
- redirect_to lato_core.superusers_path and return false
112
- end
113
- # controllo che non ci siano stati errori durante l'eliminazione
114
- unless superuser.destroy
115
- flash[:danger] = CORE_LANG['superusers']['failed_destroy']
116
- redirect_to lato_core.superuser_path(superuser) and return false
117
- end
83
+ flash[:success] = CORE_LANG['superusers']['success_update']
84
+ redirect_to lato_core.superuser_path(superuser)
85
+ end
118
86
 
119
- flash[:success] = CORE_LANG['superusers']['success_destroy']
120
- redirect_to lato_core.superusers_path
87
+ def destroy
88
+ superuser = LatoCore::Superuser.find(params[:id])
89
+ # controllo che l'utente da eliminare esista
90
+ unless superuser
91
+ flash[:warning] = CORE_LANG['superusers']['not_found']
92
+ redirect_to lato_core.superusers_path and return false
121
93
  end
122
-
123
- # Richiama la view per la visualizzazione di un singolo utente
124
- # con lo stesso id ricevuto come parametro
125
- def show
126
- @superuser = LatoCore::Superuser.find(params[:id])
127
- # controllo che l'utente da mostrare sia esistente
128
- redirect_to lato_core.superusers_path unless @superuser
94
+ # controllo che l'utente non stia provando a eliminare se stesso
95
+ if superuser === core_getCurrentUser
96
+ flash[:warning] = CORE_LANG['superusers']['itself_destroy']
97
+ redirect_to lato_core.superusers_path and return false
129
98
  end
130
-
131
- # Richiama la view per la visualizzazione di tutti gli utenti
132
- # del sistema
133
- def index
134
- @search_superusers = LatoCore::Superuser.ransack(params[:q])
135
- # controllo che non vengano mostrati gli utenti impostati nascosti
136
- hide_settings = core_getHideUsersSettings
137
- if hide_settings && !hide_settings.blank?
138
- permissions_not_accepted = []
139
- current_user_permission = core_getCurrentUser.permission
140
- hide_settings.each do |setting|
141
- permissions_not_accepted.push(setting.first) if setting.last.to_i === current_user_permission
142
- end
143
- @superusers = @search_superusers.result.where.not(permission: permissions_not_accepted)
144
- else
145
- @superusers = @search_superusers.result
146
- end
147
- @superusers = @superusers.order(
148
- 'username ASC'
149
- ).paginate(page: params[:page], per_page: 10)
99
+ # controllo che l'utente da eliminare non abbia permessi maggiori o
100
+ # uguali all'utente eliminatore
101
+ if superuser.permission >= core_getCurrentUser.permission
102
+ flash[:warning] = CORE_LANG['superusers']['permission_destroy']
103
+ redirect_to lato_core.superusers_path and return false
150
104
  end
151
-
152
- # Definisce i parametri accettati per le azioni di aggiornamento della
153
- # tabella superusers nel database
154
- private def superuser_params
155
- params.require(:superuser).permit(:name, :username, :email, :permission,
156
- :password, :password_digest)
105
+ # controllo che non ci siano stati errori durante l'eliminazione
106
+ unless superuser.destroy
107
+ flash[:danger] = CORE_LANG['superusers']['failed_destroy']
108
+ redirect_to lato_core.superuser_path(superuser) and return false
157
109
  end
158
110
 
159
- # Imposta la voce della navbar degli utenti come attiva
160
- private def set_unique_name
161
- view_setCurrentVoice('core_superusers')
162
- end
111
+ flash[:success] = CORE_LANG['superusers']['success_destroy']
112
+ redirect_to lato_core.superusers_path
113
+ end
163
114
 
164
- # Controlla che l'utente abbia i permessi per accedere alla sezione
165
- private def control_permission
166
- redirect_to lato_core.root_path unless core_controlPermission(6)
115
+ def show
116
+ @superuser = LatoCore::Superuser.find(params[:id])
117
+ # controllo che l'utente da mostrare sia esistente
118
+ redirect_to lato_core.superusers_path unless @superuser
119
+ end
120
+
121
+ def index
122
+ @search_superusers = LatoCore::Superuser.ransack(params[:q])
123
+ # controllo che non vengano mostrati gli utenti impostati nascosti
124
+ hide_settings = core_getHideUsersSettings
125
+ if hide_settings && !hide_settings.blank?
126
+ permissions_not_accepted = []
127
+ current_user_permission = core_getCurrentUser.permission
128
+ hide_settings.each do |setting|
129
+ permissions_not_accepted.push(setting.first) if setting.last.to_i === current_user_permission
130
+ end
131
+ @superusers = @search_superusers.result.where.not(permission: permissions_not_accepted)
132
+ else
133
+ @superusers = @search_superusers.result
167
134
  end
135
+ @superusers = @superusers.order(
136
+ 'username ASC'
137
+ ).paginate(page: params[:page], per_page: 10)
138
+ end
168
139
 
140
+ # This function set default params accepted for user.
141
+ private def superuser_params
142
+ params.require(:superuser).permit(:name, :username, :email, :permission,
143
+ :password, :password_digest)
169
144
  end
170
145
 
171
146
  end