lato_core 1.1.1 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,10 +1,9 @@
1
- # Includo l'interfaccia di lato_core
2
- include LatoCore::Interface
3
-
4
1
  module LatoCore
5
- # Classe base di gestione dei mailers
2
+ # This class is the default class for mailers.
6
3
  class ApplicationMailer < ActionMailer::Base
4
+ # set default email
7
5
  default from: core_getApplicationServiceEmail
6
+ # set lato mailer layout
8
7
  layout 'lato_core/mailers/layouts/mailer'
9
8
  end
10
9
  end
@@ -1,9 +1,8 @@
1
1
  module LatoCore
2
- # Mailer utilizzato per la comunicazione con l'utente amministratore tramite email
2
+ # This class is used for superusers mail actions.
3
3
  class SuperusersMailer < ApplicationMailer
4
4
 
5
- # Prende in input un utente, un titolo e un testo per notificare l'utente
6
- # con il messaggio richiesto
5
+ # This function send a normal notification message to users.
7
6
  def notify(user, title, message)
8
7
  # imposto i dati come variabili di classe
9
8
  @title = title
@@ -12,17 +11,16 @@ module LatoCore
12
11
  subject = "#{CORE_LANG['mailers']['notify_subject']} #{core_getApplicationName}"
13
12
  # invio l'email di notifica all'utente
14
13
  mail(to: user.email, subject: subject,
15
- template_path: 'lato_core/mailers/superusers')
14
+ template_path: 'lato_core/mailers/superusers')
16
15
  end
17
16
 
18
- # Prende in input un utente e un codice speciale.
19
- # Invia all'utente l'email per il recupero password contenente il codice speciale
17
+ # This function send a recover password request to user.
20
18
  def recover_password(email, code_url)
21
19
  # identifico codice completo per l'utente
22
20
  @recover_url = core_getApplicationURL + lato_core.password_edit_path(code_url)
23
21
  # invio l'email all'utente
24
22
  mail(to: email, subject: CORE_LANG['recover_password']['email_subject'],
25
- template_path: 'lato_core/mailers/superusers')
23
+ template_path: 'lato_core/mailers/superusers')
26
24
  end
27
25
 
28
26
  end
@@ -1,41 +1,49 @@
1
1
  module LatoCore
2
- # Modello che si riferisce agli utenti con accesso al pannello di amministrazione
2
+ # This class is the model for superusers.
3
3
  class Superuser < ActiveRecord::Base
4
4
 
5
- # Lista validazioni
5
+ # Validations
6
+ ############################################################################
7
+
6
8
  validates :name, presence: true, length: { maximum: 50 }
7
9
 
8
- validates :username, presence: true,
9
- length: { maximum: 50 },
10
- uniqueness: { case_sensitive: false }
10
+ validates :username, presence: true, length: { maximum: 50 },
11
+ uniqueness: { case_sensitive: false }
11
12
 
12
- validates :email, presence: true,
13
- length: { maximum: 255 },
14
- format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i },
15
- uniqueness: { case_sensitive: false }
13
+ validates :email, presence: true, length: { maximum: 255 },
14
+ format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i },
15
+ uniqueness: { case_sensitive: false }
16
16
 
17
- validates :permission, presence: true,
18
- length: { minimum: 1, maximum: 10 }
17
+ validates :permission, presence: true, length: { minimum: 1, maximum: 10 }
19
18
 
20
- validates :password, presence: true,
21
- length: { minimum: 6, maximum: 50 },
22
- on: :create
19
+ validates :password, presence: true, length: { minimum: 6, maximum: 50 }, on: :create
23
20
 
24
21
  has_secure_password
25
22
 
26
- # Azioni prima del salvataggio
27
- before_save do
23
+ # Before db update
24
+ ############################################################################
25
+
26
+ before_create do
28
27
  username.downcase!
29
28
  email.downcase!
30
29
 
31
30
  set_admin_permission
32
31
  end
33
32
 
34
- # Funzione che imposta i permessi dell'utente amministratore al
35
- # massimo livello
33
+ before_update do
34
+ username.downcase!
35
+ email.downcase!
36
+
37
+ set_admin_permission
38
+ end
39
+
40
+ # Private functions
41
+ ############################################################################
42
+
43
+ # This function set permission to 10 for first superuser.
36
44
  private def set_admin_permission
37
45
  first_user = LatoCore::Superuser.first
38
- self.permission = 10 if first_user && id === first_user.id
46
+ self.permission = 10 if first_user && self.id === first_user.id
39
47
  end
40
48
 
41
49
  end
@@ -1,6 +1,7 @@
1
1
 
2
2
  <div class="main-content login">
3
- <% # Stampa i flash ricevuti dai controller %>
3
+
4
+ <!-- Login flash messages -->
4
5
  <%= render 'lato_view/layout/flash' %>
5
6
 
6
7
  <ul class="bg-bubbles">
@@ -16,27 +17,29 @@
16
17
  <li></li>
17
18
  </ul>
18
19
 
19
- <!-- Blocco Login Utente -->
20
+ <!-- Login block -->
20
21
  <div class="content-login">
22
+
21
23
  <% if(login_logo = view_getLoginLogo) %>
22
24
  <div class="login-logo"><%= image_tag login_logo %></div>
23
25
  <% end %>
26
+
24
27
  <%= form_tag(lato_core.exec_login_path, method: "post", class: 'lato-form') do %>
25
- <%=raw view(:input).new(type: 'text',
26
- name: 'username',
27
- label: CORE_LANG['vocabolary']['username']) %>
28
28
 
29
- <%=raw view(:input).new(type: 'password',
30
- name: 'password',
31
- label: CORE_LANG['vocabolary']['password']) %>
29
+ <%=raw view(:input, :text).new(name: 'username',
30
+ label: CORE_LANG['vocabolary']['username']) %>
31
+
32
+ <%=raw view(:input, :password).new(name: 'password',
33
+ label: CORE_LANG['vocabolary']['password']) %>
32
34
 
33
35
  <%= submit_tag("Login", class: 'lato-button') %>
34
36
 
35
37
  <% if core_getRecoveryPasswordPermission %>
36
38
  <%= link_to CORE_LANG['vocabolary']['password_forget'], lato_core.password_forget_path, class: 'link-password-forget' %>
37
39
  <% end %>
38
-
40
+
39
41
  <% end %>
42
+
40
43
  </div>
41
44
 
42
45
  </div>
@@ -1,7 +1,6 @@
1
- <% block = view(:block).new(width: 'large-4', custom_class: 'flying-block') %>
2
-
3
1
  <div class="main-content login">
4
- <% # Stampa i flash ricevuti dai controller %>
2
+
3
+ <!-- Login flash messages -->
5
4
  <%= render 'lato_view/layout/flash' %>
6
5
 
7
6
  <ul class="bg-bubbles">
@@ -17,25 +16,20 @@
17
16
  <li></li>
18
17
  </ul>
19
18
 
20
- <!-- Blocco recupero password -->
19
+ <!-- Login block -->
21
20
  <div class="content-login">
21
+
22
22
  <p class="recover-guide"><%= CORE_LANG['recover_password']['recover_guide_psw'] %></p>
23
23
 
24
24
  <%= form_tag(lato_core.password_update_path, method: "post", class: 'lato-form') do %>
25
25
 
26
- <%=raw view(:input).new(type: 'password',
27
- value: '',
28
- name: 'password',
29
- label: CORE_LANG['vocabolary']['password'],
30
- width: 'large',
26
+ <%=raw view(:input, :password).new(value: '', name: 'password',
27
+ label: CORE_LANG['vocabolary']['password'], width: 'large',
31
28
  required: true) %>
32
29
 
33
- <%=raw view(:input).new(type: 'password',
34
- value: '',
35
- name: 'password_confirmation',
30
+ <%=raw view(:input, :password).new(value: '', name: 'password_confirmation',
36
31
  label: CORE_LANG['vocabolary']['password_confirmation'],
37
- width: 'large',
38
- custom_class: 'confirm-password',
32
+ width: 'large', custom_class: 'confirm-password',
39
33
  required: true) %>
40
34
 
41
35
 
@@ -45,6 +39,7 @@
45
39
  <%= submit_tag(CORE_LANG['vocabolary']['send'], class: 'lato-button') %>
46
40
 
47
41
  <% end %>
42
+
48
43
  </div>
49
44
 
50
45
  </div>
@@ -1,37 +1,36 @@
1
- <% block = view(:block).new(width: 'large-4', custom_class: 'flying-block') %>
1
+ <div class="main-content login">
2
2
 
3
- <div class="main-content login">
4
- <% # Stampa i flash ricevuti dai controller %>
5
- <%= render 'lato_view/layout/flash' %>
3
+ <!-- Login flash messages -->
4
+ <%= render 'lato_view/layout/flash' %>
6
5
 
7
- <ul class="bg-bubbles">
8
- <li></li>
9
- <li></li>
10
- <li></li>
11
- <li></li>
12
- <li></li>
13
- <li></li>
14
- <li></li>
15
- <li></li>
16
- <li></li>
17
- <li></li>
18
- </ul>
6
+ <ul class="bg-bubbles">
7
+ <li></li>
8
+ <li></li>
9
+ <li></li>
10
+ <li></li>
11
+ <li></li>
12
+ <li></li>
13
+ <li></li>
14
+ <li></li>
15
+ <li></li>
16
+ <li></li>
17
+ </ul>
19
18
 
20
- <!-- Blocco recupero password -->
21
- <div class="content-login">
22
- <p class="recover-guide"><%= CORE_LANG['recover_password']['recover_guide'] %></p>
19
+ <!-- Login block -->
20
+ <div class="content-login">
23
21
 
24
- <%= form_tag(lato_core.password_recover_path, method: "post", class: 'lato-form') do %>
22
+ <p class="recover-guide"><%= CORE_LANG['recover_password']['recover_guide'] %></p>
25
23
 
26
- <%=raw view(:input).new(type: 'email',
27
- name: 'email',
28
- label: CORE_LANG['vocabolary']['email']) %>
24
+ <%= form_tag(lato_core.password_recover_path, method: "post", class: 'lato-form') do %>
29
25
 
30
- <%= submit_tag(CORE_LANG['vocabolary']['send'], class: 'lato-button') %>
26
+ <%=raw view(:input, :email).new(name: 'email', label: CORE_LANG['vocabolary']['email']) %>
31
27
 
32
- <%= link_to CORE_LANG['vocabolary']['login'], lato_core.login_path, class: 'link-back-login' %>
28
+ <%= submit_tag(CORE_LANG['vocabolary']['send'], class: 'lato-button') %>
33
29
 
34
- <% end %>
35
- </div>
30
+ <%= link_to CORE_LANG['vocabolary']['login'], lato_core.login_path, class: 'link-back-login' %>
31
+
32
+ <% end %>
36
33
 
37
34
  </div>
35
+
36
+ </div>
@@ -1,17 +1,17 @@
1
1
  <%
2
2
 
3
- # Definisco blocco principale
4
- block = view(:block).new()
3
+ # set default block
4
+ block = view(:layout, :block).new()
5
5
 
6
- # Definisco actionbar
7
- actionbar = view(:actionbar).new(title: CORE_LANG['vocabolary']['dashboard'])
6
+ # set actionbar
7
+ actionbar = view(:layout, :actionbar).new(title: CORE_LANG['vocabolary']['dashboard'])
8
8
 
9
9
  %>
10
10
 
11
11
  <%=raw actionbar %>
12
12
 
13
13
  <div class="content-row">
14
- <%=raw block.open(width: 'medium-12 large-6') %>
14
+ <%=raw block.open(width: 'medium-12 large-12') %>
15
15
 
16
16
  <p><b><%= CORE_LANG['welcome'] %></b></p>
17
17
  <p><%= CORE_LANG['dashboard'] %></p>
@@ -1,7 +1,16 @@
1
- <% block = view(:block).new %>
1
+ <%
2
2
 
3
- <%= raw view(:actionbar).new(title: "#{CORE_LANG['vocabolary']['edit']} #{@superuser.username}",
4
- links: [[CORE_LANG['vocabolary']['users'], lato_core.superusers_path]]) %>
3
+ block = view(:layout, :block).new
4
+
5
+ back_button = view(:component, :button).new(title: 'Back', url: lato_core.superusers_path,
6
+ size: 'small')
7
+
8
+ actionbar = view(:layout, :actionbar).new(title: "#{CORE_LANG['vocabolary']['edit']} #{@superuser.username}",
9
+ widgets: [{component: back_button, align: 'right'}])
10
+
11
+ %>
12
+
13
+ <%= raw actionbar %>
5
14
 
6
15
  <div class="content-row">
7
16
  <%= raw block.open %>
@@ -1,23 +1,33 @@
1
- <% block = view(:block).new %>
1
+ <%
2
2
 
3
- <% searchbar = view(:searchbar).new(elements: @search_superusers,
4
- url: lato_core.superusers_path,
5
- filter: :username_cont,
6
- style: :rounded) %>
3
+ block = view(:layout, :block).new
7
4
 
8
- <%=raw view(:actionbar).new(links: [[CORE_LANG['vocabolary']['new'], lato_core.new_superuser_path]],
9
- title: CORE_LANG['vocabolary']['users'],
10
- widgets: [[searchbar, :right]]) %>
5
+ searchbar = view(:component, :searchbar).new(elements: @search_superusers,
6
+ url: lato_core.superusers_path, filter: :username_cont,
7
+ style: :rounded)
8
+
9
+ new_button = view(:component, :button).new(title: CORE_LANG['vocabolary']['new'],
10
+ url: lato_core.new_superuser_path, size: :small)
11
+
12
+ actionbar = view(:layout, :actionbar).new(title: CORE_LANG['vocabolary']['users'],
13
+ widgets: [
14
+ {component: searchbar, align: :right},
15
+ {component: new_button, align: :right}
16
+ ])
17
+
18
+ index = view(:layout, :index).new(head: [CORE_LANG['vocabolary']['username'], CORE_LANG['vocabolary']['email']],
19
+ elements: @superusers, attributes: ['username', 'email'], link: lato_core.superusers_path,
20
+ show_link: false)
21
+
22
+ %>
23
+
24
+ <%=raw actionbar %>
11
25
 
12
26
  <div class="content-row">
13
27
  <%=raw block.open %>
14
28
 
15
29
 
16
- <%=raw view(:index).new(head: [CORE_LANG['vocabolary']['username'], CORE_LANG['vocabolary']['email']],
17
- elements: @superusers,
18
- attributes: ['username', 'email'],
19
- link: lato_core.superusers_path,
20
- show_link: false) %>
30
+ <%=raw index %>
21
31
 
22
32
  <%= will_paginate @superusers %>
23
33
 
@@ -1,7 +1,16 @@
1
- <% block = view(:block).new %>
1
+ <%
2
2
 
3
- <%=raw view(:actionbar).new(title: CORE_LANG['vocabolary']['new'],
4
- links: [[CORE_LANG['vocabolary']['users'], lato_core.superusers_path]]) %>
3
+ block = view(:layout, :block).new
4
+
5
+ back_button = view(:component, :button).new(title: 'Back', url: lato_core.superusers_path,
6
+ size: 'small')
7
+
8
+ actionbar = view(:layout, :actionbar).new(title: CORE_LANG['vocabolary']['new'],
9
+ widgets: [{component: back_button, align: 'right'}])
10
+
11
+ %>
12
+
13
+ <%=raw actionbar %>
5
14
 
6
15
  <div class="content-row">
7
16
  <%=raw block.open %>
@@ -6,12 +6,9 @@
6
6
 
7
7
  <div class="form-group">
8
8
 
9
- <%=raw view(:input).new(type: 'text',
10
- value: @superuser.name,
11
- name: 'superuser[name]',
12
- label: CORE_LANG['vocabolary']['name'],
13
- width: 'half',
14
- required: true) %>
9
+ <%=raw view(:input, :text).new(value: @superuser.name, name: 'superuser[name]',
10
+ label: CORE_LANG['vocabolary']['name'],
11
+ width: 'half', required: true) %>
15
12
 
16
13
  <%=raw view(:input).new(type: 'text',
17
14
  value: @superuser.username,
data/config/config.yml CHANGED
@@ -1,4 +1,4 @@
1
- # Impostazione voci del menu
1
+ # Menu voices
2
2
  menu:
3
3
  core_superusers:
4
4
  name: Admin
data/config/example.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  # Basic informations
2
- # -----------------------------------------------------------------------------
2
+ ################################################################################
3
3
  # Please, set a correct value for these informations
4
4
 
5
5
  # Set the application name.
@@ -22,7 +22,7 @@ root_url: http://localhost:3000
22
22
  service_email: service@lato.com
23
23
 
24
24
  # Usage informations
25
- # -----------------------------------------------------------------------------
25
+ ################################################################################
26
26
 
27
27
  # Add custom voices to the sidebar.
28
28
  # Custom voices are sections on sidebar used for the navigation inside the Lato panel.
@@ -41,7 +41,7 @@ service_email: service@lato.com
41
41
  # login_home: "/example"
42
42
 
43
43
  # Users settings
44
- # -----------------------------------------------------------------------------
44
+ ################################################################################
45
45
 
46
46
  # Hide users with permission value to users with others permission value
47
47
  # You can hide users on users section. For example '1 to 2' means that users with
@@ -1,16 +1,15 @@
1
1
  include LatoCore::Interface
2
2
 
3
- # IMPOSTAZIONE VARIABILE PER ACCESSO ALLE LINGUE
3
+ # Set default languages
4
4
 
5
5
  CORE_LANG = core_loadModuleLanguages('lato_core')
6
6
 
7
- # CREAZIONE UTENTE AMMINISTRATORE
7
+ # Create first user if not exist
8
8
 
9
9
  if ActiveRecord::Base.connection.table_exists? 'lato_core_superusers'
10
10
 
11
11
  LatoCore::Superuser.create(name: 'Admin', username: 'lato',
12
- email: 'lato@mail.com', permission: 10,
13
- password: 'password',
14
- password_confirmation: 'password')
12
+ email: 'lato@mail.com', permission: 10, password: 'password',
13
+ password_confirmation: 'password')
15
14
 
16
15
  end